From 5b644e1fd2f616f7bb146b92d25846cd6cc5793a Mon Sep 17 00:00:00 2001 From: alexion Date: Sun, 11 Oct 2026 20:08:20 -0400 Subject: [PATCH] refactor(waybar): store rendered window icons --- configs/nixos/AGENTS.md | 4 ++-- configs/nixos/modules/desktop/apps/firefox.nix | 2 +- configs/nixos/modules/desktop/apps/ghostty.nix | 2 +- configs/nixos/modules/desktop/apps/obsidian.nix | 2 +- configs/nixos/modules/desktop/apps/signal.nix | 2 +- configs/nixos/modules/desktop/apps/steam.nix | 2 +- configs/nixos/modules/desktop/apps/vencord.nix | 2 +- configs/nixos/modules/desktop/session/hyprland/default.nix | 7 ++----- configs/nixos/registry/window-icon.nix | 4 ++-- 9 files changed, 12 insertions(+), 15 deletions(-) diff --git a/configs/nixos/AGENTS.md b/configs/nixos/AGENTS.md index 2f538cf..867195c 100644 --- a/configs/nixos/AGENTS.md +++ b/configs/nixos/AGENTS.md @@ -2,10 +2,10 @@ ## Desktop -- TODO: Verify this path after the NixOS configuration is migrated. - When adding a graphical application, add a `window-rewrite` icon mapping in `modules/desktop/session/waybar.nix`. +- When adding a graphical application, register its workspace icon in `registry.window-icon`. The workspace indicator uses this mapping to show an application icon instead of the generic default glyph. Match the mapping on the window class. + Store the icon as the rendered string. Run `hyprctl clients -j | jq -r '.[].class' | sort -u` to list classes in the running session. - TODO: Verify this path after the NixOS configuration is migrated. Set Hyprland session environment variables in `modules/desktop/session/hyprland/default.nix` with `env = KEY,VALUE`. diff --git a/configs/nixos/modules/desktop/apps/firefox.nix b/configs/nixos/modules/desktop/apps/firefox.nix index 5021d13..0f5e768 100644 --- a/configs/nixos/modules/desktop/apps/firefox.nix +++ b/configs/nixos/modules/desktop/apps/firefox.nix @@ -28,7 +28,7 @@ in config = lib.mkIf cfg.enable { registry.window-icon.${config.networking.hostName}.firefox = { class = ".*[Ff]irefox.*"; - icon = "f269"; + icon = builtins.fromJSON ''"\uf269"''; }; home-manager.users.${config.user.name} = hm: { diff --git a/configs/nixos/modules/desktop/apps/ghostty.nix b/configs/nixos/modules/desktop/apps/ghostty.nix index 05d2ba6..2813299 100644 --- a/configs/nixos/modules/desktop/apps/ghostty.nix +++ b/configs/nixos/modules/desktop/apps/ghostty.nix @@ -22,7 +22,7 @@ in registry.window-icon.${config.networking.hostName}.ghostty = { class = "com.mitchellh.ghostty"; - icon = "f120"; + icon = builtins.fromJSON ''"\uf120"''; }; home-manager.users.${user}.home.packages = [ pkgs.ghostty ]; diff --git a/configs/nixos/modules/desktop/apps/obsidian.nix b/configs/nixos/modules/desktop/apps/obsidian.nix index fb018cd..e62fd4d 100644 --- a/configs/nixos/modules/desktop/apps/obsidian.nix +++ b/configs/nixos/modules/desktop/apps/obsidian.nix @@ -17,7 +17,7 @@ in registry.window-icon.${config.networking.hostName}.obsidian = { class = "obsidian"; - icon = "f02d"; + icon = builtins.fromJSON ''"\uf02d"''; }; }; } diff --git a/configs/nixos/modules/desktop/apps/signal.nix b/configs/nixos/modules/desktop/apps/signal.nix index a28387f..bf3ca0d 100644 --- a/configs/nixos/modules/desktop/apps/signal.nix +++ b/configs/nixos/modules/desktop/apps/signal.nix @@ -16,7 +16,7 @@ in registry.window-icon.${config.networking.hostName}.signal = { class = "[Ss]ignal"; - icon = "f4ad"; + icon = builtins.fromJSON ''"\uf4ad"''; }; }; } diff --git a/configs/nixos/modules/desktop/apps/steam.nix b/configs/nixos/modules/desktop/apps/steam.nix index 6b111ed..d952f00 100644 --- a/configs/nixos/modules/desktop/apps/steam.nix +++ b/configs/nixos/modules/desktop/apps/steam.nix @@ -26,7 +26,7 @@ registry.window-icon.${config.networking.hostName}.steam = { class = "[Ss]team"; - icon = "f1b6"; + icon = builtins.fromJSON ''"\uf1b6"''; }; }; } diff --git a/configs/nixos/modules/desktop/apps/vencord.nix b/configs/nixos/modules/desktop/apps/vencord.nix index 79d9824..90edaa0 100644 --- a/configs/nixos/modules/desktop/apps/vencord.nix +++ b/configs/nixos/modules/desktop/apps/vencord.nix @@ -17,7 +17,7 @@ in registry.window-icon.${config.networking.hostName}.vesktop = { class = "[Vv]esktop"; - icon = "f1ff"; + icon = builtins.fromJSON ''"\uf1ff"''; }; }; } diff --git a/configs/nixos/modules/desktop/session/hyprland/default.nix b/configs/nixos/modules/desktop/session/hyprland/default.nix index 769e751..284e406 100644 --- a/configs/nixos/modules/desktop/session/hyprland/default.nix +++ b/configs/nixos/modules/desktop/session/hyprland/default.nix @@ -4,9 +4,6 @@ ... }: # The Hyprland compositor. -let - glyph = code: builtins.fromJSON ''"\u${code}"''; -in { options.modules.desktop.session.hyprland.enable = lib.mkEnableOption "the Hyprland compositor"; @@ -238,9 +235,9 @@ in on-click = "activate"; format = "{id} {windows}"; format-window-separator = " "; - window-rewrite-default = glyph "f2d0"; + window-rewrite-default = builtins.fromJSON ''"\uf2d0"''; window-rewrite = lib.mapAttrs' ( - _name: windowIcon: lib.nameValuePair "class<${windowIcon.class}>" (glyph windowIcon.icon) + _name: windowIcon: lib.nameValuePair "class<${windowIcon.class}>" windowIcon.icon ) (lib.attrByPath [ config.networking.hostName ] { } config.registry.window-icon); }; }; diff --git a/configs/nixos/registry/window-icon.nix b/configs/nixos/registry/window-icon.nix index 76ffa09..574ae94 100644 --- a/configs/nixos/registry/window-icon.nix +++ b/configs/nixos/registry/window-icon.nix @@ -10,9 +10,9 @@ }; icon = lib.mkOption { - description = "Sets the Nerd Font codepoint shown for matching windows."; + description = "Sets the icon shown for matching windows."; type = lib.types.str; - example = "f269"; + example = ""; }; }; };