From 20bbc9736c0d244c86c0594e3bc44bedb9128fd3 Mon Sep 17 00:00:00 2001 From: Anthony Rodriguez Date: Tue, 26 Nov 2024 15:38:03 +0100 Subject: [PATCH] programs/waybar: simplify styling and move generateGtkColors to lib --- home/programs/waybar/default.nix | 10 ++- home/programs/waybar/style.css | 91 +++++++++++++++++++++++++ home/programs/waybar/style.nix | 111 ------------------------------- lib/default.nix | 7 +- 4 files changed, 105 insertions(+), 114 deletions(-) create mode 100644 home/programs/waybar/style.css delete mode 100644 home/programs/waybar/style.nix diff --git a/home/programs/waybar/default.nix b/home/programs/waybar/default.nix index 530c213..4d446f2 100644 --- a/home/programs/waybar/default.nix +++ b/home/programs/waybar/default.nix @@ -1,16 +1,22 @@ { pkgs, lib, + lib', osConfig, config, ... }: let - inherit (lib) getExe mkMerge mkIf; + inherit (lib) getExe mkMerge mkIf optionalString; + inherit (lib') generateGtkColors; + inherit (osConfig.theme.scheme) palette; + inherit (builtins) readFile; in { - imports = [./style.nix]; programs.waybar = { enable = true; systemd.enable = true; + style = + optionalString osConfig.theme.enable generateGtkColors lib palette + + readFile ./style.css; settings = { mainBar = mkMerge [ { diff --git a/home/programs/waybar/style.css b/home/programs/waybar/style.css new file mode 100644 index 0000000..52150ec --- /dev/null +++ b/home/programs/waybar/style.css @@ -0,0 +1,91 @@ +* { + /* `otf-font-awesome` is required to be installed for icons */ + border: none; + border-radius: 0px; + min-height: 0; +} + +window#waybar { + border-radius: 2em; + font-family: "Symbols Nerd Font", Inter, sans-serif; + font-size: 16px; + font-style: normal; + background: alpha( + @base00, + 0.9999999 + ); /* niri issue workaround, thanks https://github.com/oatmealine/nix-config/blob/bfdddd2cb36ef659bcddc28e0dbb542b6db8b3bc/modules/desktop/themes/catppuccin/waybar.css#L14 */ + color: @base05; +} + +#workspaces, +.modules-right box { + background: @base02; + padding: 0.15em 0.25em; + border-radius: 1em; + margin: 0 0.25em; +} + +#workspaces { + padding: 0; + background: @base02; +} + +#workspaces button:nth-child(1) { + border-top-left-radius: 1em; + border-bottom-left-radius: 1em; +} +#workspaces button:nth-last-child(1) { + border-top-right-radius: 1em; + border-bottom-right-radius: 1em; +} + +#workspaces button { + padding: 0 0.5em; + background-color: transparent; +} + +#workspaces button:hover { + background: rgba(255, 255, 255, 0.1); + box-shadow: none; +} + +#workspaces button.active { + background: @base0E; + color: @base02; +} + +#workspaces button.urgent { + background: @base08; +} + +#window { + margin-left: 1em; +} + +.modules-left, +.modules-right { + margin: 0.4em 0.5em; +} + +#battery, +#clock, +#network, +#pulseaudio, +#tray, +#power-profiles-daemon { + padding: 0 0.5em; +} + +.modules-left, +.modules-right { + margin: 0.4em 0.5em; +} + +#custom-power { + padding: 0 1.2em; + color: @base08; +} + +#custom-notification { + padding: 0 1.2em; +} diff --git a/home/programs/waybar/style.nix b/home/programs/waybar/style.nix deleted file mode 100644 index 904807c..0000000 --- a/home/programs/waybar/style.nix +++ /dev/null @@ -1,111 +0,0 @@ -{ - lib, - osConfig, - ... -}: let - inherit (osConfig.theme.scheme) palette; - inherit (lib) mapAttrsToList concatLines optionalString; - - generateGtkColors = palette: (concatLines - (mapAttrsToList - (name: color: "@define-color ${name} ${color};") - palette)); -in { - programs.waybar.style = - optionalString osConfig.theme.enable generateGtkColors palette - + '' - * { - /* `otf-font-awesome` is required to be installed for icons */ - border: none; - border-radius: 0px; - min-height: 0; - } - - window#waybar { - border-radius: 2em; - font-family: "Symbols Nerd Font", Inter, sans-serif; - font-size: 16px; - font-style: normal; - background: alpha( - @base00, - 0.9999999 - ); /* niri issue workaround, thanks https://github.com/oatmealine/nix-config/blob/bfdddd2cb36ef659bcddc28e0dbb542b6db8b3bc/modules/desktop/themes/catppuccin/waybar.css#L14 */ - color: @base05; - } - - #workspaces, - .modules-right box { - background: @base02; - padding: 0.15em 0.25em; - border-radius: 1em; - margin: 0 0.25em; - } - - #workspaces { - padding: 0; - background: @base02; - } - - #workspaces button:nth-child(1) { - border-top-left-radius: 1em; - border-bottom-left-radius: 1em; - } - #workspaces button:nth-last-child(1) { - border-top-right-radius: 1em; - border-bottom-right-radius: 1em; - } - - #workspaces button { - padding: 0 0.5em; - background-color: transparent; - } - - #workspaces button:hover { - background: rgba(255, 255, 255, 0.1); - box-shadow: none; - } - - #workspaces button.active { - background: @base0E; - color: @base02; - } - - #workspaces button.urgent { - background: @base08; - } - - #window { - margin-left: 1em; - } - - .modules-left, - .modules-right { - margin: 0.4em 0.5em; - } - - #battery, - #clock, - #network, - #pulseaudio, - #tray, - #power-profiles-daemon - { - padding: 0 0.5em; - } - - .modules-left, - .modules-right { - margin: 0.4em 0.5em; - } - - - #custom-power { - padding: 0 1.2em; - color: @base08; - } - - #custom-notification { - padding: 0 1.2em; - } - ''; -} diff --git a/lib/default.nix b/lib/default.nix index 3f17696..35b3d3f 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -50,6 +50,11 @@ let '' magick ${path} -gaussian-blur 0x12 "$out" ''; + + generateGtkColors = lib: palette: (lib.concatLines + (lib.mapAttrsToList + (name: color: "@define-color ${name} ${color};") + palette)); in { - inherit blurImage rgba; + inherit blurImage generateGtkColors rgba; }