1
0
mirror of https://github.com/HorlogeSkynet/archey4 synced 2025-05-08 08:00:13 +02:00

[CORE] Adds (Nerd Fonts) icons for entries (#144)

Co-authored-by: Michael Bromilow <12384431+ingrinder@users.noreply.github.com>
Co-authored-by: Samuel FORESTIER <samuel+dev@forestier.app>
This commit is contained in:
Tobilike 2024-01-14 18:54:08 +01:00 committed by GitHub
parent d3a08e6ff0
commit 121b1cc796
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 56 additions and 2 deletions

@ -270,9 +270,15 @@ Below stand further descriptions for each available (default) option :
// For example, "retro" would show the retro styled Apple logo on Darwin platforms.
// Note that the `--logo-style` argument overrides this setting.
"logo_style": "",
// Enable icons for entries.
// A terminal "nerd font" is required to display the icons. Otherwise, these are simply missing and a placeholder will be seen.
// You can also refer to : <https://github.com/ryanoasis/nerd-fonts>.
// Make sure that your system locale supports UTF-8.
"entries_icon": false,
// Entries list.
// Add a `disabled` option set to `true` to temporary hide one.
// You may change entry displayed name by adding a `name` option.
// You may change entry displayed icon by adding an `icon` option.
// You may re-order the entries list as you wish.
"entries": [
{ "type": "User" },
@ -436,8 +442,9 @@ Below stand further descriptions for each available (default) option :
{
"type": "Custom",
// `command` option is mandatory. `shell` option defaults to `false`.
// Don't forget to set a `name` !
// Don't forget to set a `name` (and optionally an icon) !
"name": "GPU",
"icon": "\ue735",
// The custom shell command to execute.
"shell": true,
"command": "lshw -C display 2> /dev/null | rg product | cut -d ':' -f 2",

@ -16,6 +16,7 @@ DEFAULT_CONFIG: Dict[str, Any] = {
"suppress_warnings": False,
"entries_color": "",
"honor_ansi_color": True,
"entries_icon": False,
"default_strings": {
"latest": "latest",
"available": "available",

@ -19,6 +19,8 @@ class CPU(Entry):
Each `dict` **SHOULD** contain only one entry (CPU model name as key and cores count as value).
"""
_ICON = "\uf4bc" # oct_cpu
_MODEL_NAME_REGEXP = re.compile(
r"^model name\s*:\s*(.*)$",
flags=re.IGNORECASE | re.MULTILINE,

@ -14,6 +14,8 @@ from archey.entry import Entry
class Custom(Entry):
"""Custom entry gathering info based on configuration options"""
_ICON = "\uf013" # fa_cog
def __new__(cls, *_, **kwargs):
# Don't load this entry if a configuration file has too broad permissions.
# We want to mitigate LPE attacks, as arbitrary commands could be run from a configuration

@ -26,6 +26,7 @@ class DesktopEnvironment(Entry):
If not, rely on the `XDG_CURRENT_DESKTOP` environment variable.
"""
_ICON = "\ue23c" # fae_restore
_PRETTY_NAME = "Desktop Environment"
def __init__(self, *args, **kwargs):

@ -13,6 +13,8 @@ from archey.entry import Entry
class Disk(Entry):
"""Uses `df` to compute disk usage across devices"""
_ICON = "\U000f16df" # md_tape_drive
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

@ -11,6 +11,8 @@ from archey.entry import Entry
class Distro(Entry):
"""Uses `distro` and `platform` modules to retrieve distribution and architecture information"""
_ICON = "\uf17c" # fa_linux
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

@ -11,6 +11,8 @@ from archey.entry import Entry
class GPU(Entry):
"""Relies on `lspci` or `pciconf` to retrieve graphical device(s) information"""
_ICON = "\ue735" # dev_html5_3d_effects
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

@ -9,6 +9,8 @@ from archey.entry import Entry
class Hostname(Entry):
"""Read system file with fallback on `platform` module to retrieve the system host-name"""
_ICON = "\U000f0318" # md_lan_connect
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

@ -18,6 +18,8 @@ class Kernel(Entry):
[GNU/LINUX] If user-enabled, implement a version comparison against upstream data.
"""
_ICON = "\uf305" # linux_coreos
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

@ -15,6 +15,7 @@ from archey.entry import Entry
class LanIP(Entry):
"""Relies on the `netifaces` module to detect LAN IP addresses"""
_ICON = "\U000f0a60" # md_ip_network
_PRETTY_NAME = "LAN IP"
def __init__(self, *args, **kwargs):

@ -10,6 +10,7 @@ from archey.entry import Entry
class LoadAverage(Entry):
"""System load average detection entry"""
_ICON = "\U000f051f" # md_timer_sand
_PRETTY_NAME = "Load Average"
def __init__(self, *args, **kwargs):

@ -13,6 +13,8 @@ from archey.entry import Entry
class Model(Entry):
"""Uses multiple methods to retrieve some information about the host hardware"""
_ICON = "\ueabe" # cod_circuit_board
LINUX_DMI_SYS_PATH = "/sys/devices/virtual/dmi/id"
def __init__(self, *args, **kwargs):

@ -48,6 +48,8 @@ PACKAGES_TOOLS = (
class Packages(Entry):
"""Relies on the first found packages manager to list the installed packages"""
_ICON = "\ueb29" # cod_package
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

@ -9,6 +9,8 @@ class Processes(Entry):
Simple wrapper to `archey.processes` to provide the number of running processes as an entry.
"""
_ICON = "\ueba2" # cod_server_process
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

@ -18,6 +18,8 @@ class RAM(Entry):
If not available, falls back on the parsing of `/proc/meminfo` file.
"""
_ICON = "\U000f035b" # md_memory
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

@ -13,6 +13,8 @@ class Shell(Entry):
the local administrative database.
"""
_ICON = "\U000f018d" # md_console
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

@ -20,6 +20,8 @@ class Temperature(Entry):
On Raspberry devices, retrieves temperature from the `vcgencmd` binary.
"""
_ICON = "\U000f1a45" # md_heat_wave
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

@ -60,6 +60,8 @@ class Terminal(Entry):
It also displays the colors palette afterwards.
"""
_ICON = "\uf120" # fa_terminal
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

@ -13,6 +13,8 @@ from archey.exceptions import ArcheyException
class Uptime(Entry):
"""Returns a pretty-formatted string representing the host uptime"""
_ICON = "\U000f1925" # md_timer_cog
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

@ -8,6 +8,8 @@ from archey.entry import Entry
class User(Entry):
"""Retrieves the session name of the current logged in user"""
_ICON = "\uf007" # fa_user
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

@ -13,6 +13,7 @@ from archey.environment import Environment
class WanIP(Entry):
"""Uses different ways to retrieve the public IPv{4,6} addresses"""
_ICON = "\U000f0a60" # md_ip_network
_PRETTY_NAME = "WAN IP"
def __init__(self, *args, **kwargs):

@ -60,6 +60,7 @@ class WindowManager(Entry):
If not available, fall back on a simple iteration over the processes.
"""
_ICON = "\ueae4" # cod_empty_window
_PRETTY_NAME = "Window Manager"
def __init__(self, *args, **kwargs):

@ -11,6 +11,7 @@ from archey.configuration import Configuration
class Entry(AbstractBaseClass):
"""Module base class"""
_ICON: Optional[str] = None
_PRETTY_NAME: Optional[str] = None
def __new__(cls, *_, **kwargs):
@ -22,6 +23,8 @@ class Entry(AbstractBaseClass):
@abstractmethod
def __init__(self, name: Optional[str] = None, value=None, options: Optional[dict] = None):
configuration = Configuration()
# Each entry will have always have the following attributes...
# `name`: key (defaults to the instantiated entry class name);
# `value`: value of entry as an appropriate object;
@ -30,8 +33,13 @@ class Entry(AbstractBaseClass):
self.value = value
self.options = options or {}
# optionally prepend entry name with an icon
icon = self.options.get("icon", self._ICON)
if icon is not None and configuration.get("entries_icon"):
self.name = f"{icon} {self.name}"
# Propagates a reference to default strings specified in `Configuration`.
self._default_strings = Configuration().get("default_strings")
self._default_strings = configuration.get("default_strings")
# Provision a logger for each entry.
self._logger = logging.getLogger(self.__module__)

@ -5,6 +5,7 @@
"entries_color": "",
"honor_ansi_color": true,
"logo_style": "",
"entries_icon": false,
"entries": [
{ "type": "User" },
{ "type": "Hostname" },