diff --git a/README.md b/README.md index bafa8c39..05441a89 100644 --- a/README.md +++ b/README.md @@ -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 : . + // 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", diff --git a/archey/configuration.py b/archey/configuration.py index 3271c370..ea89ba41 100644 --- a/archey/configuration.py +++ b/archey/configuration.py @@ -16,6 +16,7 @@ "suppress_warnings": False, "entries_color": "", "honor_ansi_color": True, + "entries_icon": False, "default_strings": { "latest": "latest", "available": "available", diff --git a/archey/entries/cpu.py b/archey/entries/cpu.py index ccec9297..75ca9e08 100644 --- a/archey/entries/cpu.py +++ b/archey/entries/cpu.py @@ -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, diff --git a/archey/entries/custom.py b/archey/entries/custom.py index 10a4d0bf..191a7045 100644 --- a/archey/entries/custom.py +++ b/archey/entries/custom.py @@ -14,6 +14,8 @@ 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 diff --git a/archey/entries/desktop_environment.py b/archey/entries/desktop_environment.py index d4787a50..306e2b9f 100644 --- a/archey/entries/desktop_environment.py +++ b/archey/entries/desktop_environment.py @@ -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): diff --git a/archey/entries/disk.py b/archey/entries/disk.py index f48cb38d..abafc3ec 100644 --- a/archey/entries/disk.py +++ b/archey/entries/disk.py @@ -13,6 +13,8 @@ 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) diff --git a/archey/entries/distro.py b/archey/entries/distro.py index 12bc4c98..263d1033 100644 --- a/archey/entries/distro.py +++ b/archey/entries/distro.py @@ -11,6 +11,8 @@ 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) diff --git a/archey/entries/gpu.py b/archey/entries/gpu.py index 89b0c718..26f30ce7 100644 --- a/archey/entries/gpu.py +++ b/archey/entries/gpu.py @@ -11,6 +11,8 @@ 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) diff --git a/archey/entries/hostname.py b/archey/entries/hostname.py index cbc48c4c..234b16a7 100644 --- a/archey/entries/hostname.py +++ b/archey/entries/hostname.py @@ -9,6 +9,8 @@ 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) diff --git a/archey/entries/kernel.py b/archey/entries/kernel.py index 03a13832..30647cf1 100644 --- a/archey/entries/kernel.py +++ b/archey/entries/kernel.py @@ -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) diff --git a/archey/entries/lan_ip.py b/archey/entries/lan_ip.py index a68f76d9..5f31e79b 100644 --- a/archey/entries/lan_ip.py +++ b/archey/entries/lan_ip.py @@ -15,6 +15,7 @@ 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): diff --git a/archey/entries/load_average.py b/archey/entries/load_average.py index d648f8ba..1d76fa0a 100644 --- a/archey/entries/load_average.py +++ b/archey/entries/load_average.py @@ -10,6 +10,7 @@ class LoadAverage(Entry): """System load average detection entry""" + _ICON = "\U000f051f" # md_timer_sand _PRETTY_NAME = "Load Average" def __init__(self, *args, **kwargs): diff --git a/archey/entries/model.py b/archey/entries/model.py index 6bc42705..681ef089 100644 --- a/archey/entries/model.py +++ b/archey/entries/model.py @@ -13,6 +13,8 @@ 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): diff --git a/archey/entries/packages.py b/archey/entries/packages.py index 982866a7..8633ddbf 100644 --- a/archey/entries/packages.py +++ b/archey/entries/packages.py @@ -48,6 +48,8 @@ def get_homebrew_cellar_path() -> str: 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) diff --git a/archey/entries/processes.py b/archey/entries/processes.py index f2c83581..3fe3153a 100644 --- a/archey/entries/processes.py +++ b/archey/entries/processes.py @@ -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) diff --git a/archey/entries/ram.py b/archey/entries/ram.py index 79877a5a..ba87f0bb 100644 --- a/archey/entries/ram.py +++ b/archey/entries/ram.py @@ -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) diff --git a/archey/entries/shell.py b/archey/entries/shell.py index d00037c8..4050d25c 100644 --- a/archey/entries/shell.py +++ b/archey/entries/shell.py @@ -13,6 +13,8 @@ class Shell(Entry): the local administrative database. """ + _ICON = "\U000f018d" # md_console + def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) diff --git a/archey/entries/temperature.py b/archey/entries/temperature.py index 442a3384..4b878645 100644 --- a/archey/entries/temperature.py +++ b/archey/entries/temperature.py @@ -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) diff --git a/archey/entries/terminal.py b/archey/entries/terminal.py index 0d5919b5..3b5648ce 100644 --- a/archey/entries/terminal.py +++ b/archey/entries/terminal.py @@ -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) diff --git a/archey/entries/uptime.py b/archey/entries/uptime.py index 873a0e31..09b02224 100644 --- a/archey/entries/uptime.py +++ b/archey/entries/uptime.py @@ -13,6 +13,8 @@ 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) diff --git a/archey/entries/user.py b/archey/entries/user.py index 9a3eebd4..be4b48aa 100644 --- a/archey/entries/user.py +++ b/archey/entries/user.py @@ -8,6 +8,8 @@ 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) diff --git a/archey/entries/wan_ip.py b/archey/entries/wan_ip.py index 4b031686..5b6b96e8 100644 --- a/archey/entries/wan_ip.py +++ b/archey/entries/wan_ip.py @@ -13,6 +13,7 @@ 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): diff --git a/archey/entries/window_manager.py b/archey/entries/window_manager.py index 77e16630..3a9e9e8c 100644 --- a/archey/entries/window_manager.py +++ b/archey/entries/window_manager.py @@ -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): diff --git a/archey/entry.py b/archey/entry.py index e4bc1bca..539bbd6b 100644 --- a/archey/entry.py +++ b/archey/entry.py @@ -11,6 +11,7 @@ class Entry(AbstractBaseClass): """Module base class""" + _ICON: Optional[str] = None _PRETTY_NAME: Optional[str] = None def __new__(cls, *_, **kwargs): @@ -22,6 +23,8 @@ def __new__(cls, *_, **kwargs): @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 @@ def __init__(self, name: Optional[str] = None, value=None, options: Optional[dic 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__) diff --git a/config.json b/config.json index 4c6e24b8..d858dbf6 100644 --- a/config.json +++ b/config.json @@ -5,6 +5,7 @@ "entries_color": "", "honor_ansi_color": true, "logo_style": "", + "entries_icon": false, "entries": [ { "type": "User" }, { "type": "Hostname" },