diff --git a/README.md b/README.md index 6f5557c..59b7dd6 100644 --- a/README.md +++ b/README.md @@ -19,4 +19,3 @@ - Fix kitty bell disable not working - Add Gruvbox switching support - kitty theme is "Gruvbox Dark", [see the full list](https://github.com/kovidgoyal/kitty-themes/blob/master/themes.json). -- Somehow remove redundant color definitions in [`hosts/elnupad/polybar.nix`](hosts/elnupad/polybar.nix) diff --git a/hosts/elnupad/polybar.nix b/hosts/elnupad/polybar.nix index ac6f18b..4c5b799 100644 --- a/hosts/elnupad/polybar.nix +++ b/hosts/elnupad/polybar.nix @@ -1,13 +1,7 @@ { pkgs, lib, ... }: let - # TODO: eliminate redundant color definitions - background = "#2e3440"; - background-alt = "#3b4252"; - foreground = "#eceff4"; - primary = "#8fbcbb"; - alert = "#bf616a"; - disabled = "#434c5e"; + colors = import ../../polybar/colors.nix; in { home.packages = with pkgs; [ lm_sensors ]; @@ -26,12 +20,12 @@ in format-low = " "; - label-charging = "%{F${primary}}AC%{F-} %percentage%%"; - label-discharging = "%{F${primary}}BAT%{F-} %percentage%%"; - label-full = "%{F${primary}}AC%{F-}"; + label-charging = "%{F${colors.primary}}AC%{F-} %percentage%%"; + label-discharging = "%{F${colors.primary}}BAT%{F-} %percentage%%"; + label-full = "%{F${colors.primary}}AC%{F-}"; - animation-low-0 = "%{F${primary}}BAT%{F-}"; - animation-low-1 = "%{F${alert}}LOW%{F-}"; + animation-low-0 = "%{F${colors.primary}}BAT%{F-}"; + animation-low-1 = "%{F${colors.alert}}LOW%{F-}"; full-at = 96; low-at = 10; # default diff --git a/polybar/colors.nix b/polybar/colors.nix new file mode 100644 index 0000000..ed74183 --- /dev/null +++ b/polybar/colors.nix @@ -0,0 +1,8 @@ +{ + background = "#2e3440"; + background-alt = "#3b4252"; + foreground = "#eceff4"; + primary = "#8fbcbb"; + alert = "#bf616a"; + disabled = "#434c5e"; +} diff --git a/polybar/default.nix b/polybar/default.nix index 1872f01..d90171e 100644 --- a/polybar/default.nix +++ b/polybar/default.nix @@ -1,12 +1,7 @@ { pkgs, lib, ... }: let - background = "#2e3440"; - background-alt = "#3b4252"; - foreground = "#eceff4"; - primary = "#8fbcbb"; - alert = "#bf616a"; - disabled = "#434c5e"; + colors = import ./colors.nix; in { # Dependencies @@ -28,8 +23,8 @@ in "bar/top" = { font-0 = "Noto Sans Mono;2"; font-1 = "Noto Sans CJK JP;2"; - background = "${background}"; - foreground = "${foreground}"; + background = "${colors.background}"; + foreground = "${colors.foreground}"; width = "100%"; height = "24pt"; @@ -37,7 +32,7 @@ in padding-right = 1; module-margin = 1; separator = "|"; - separator-foreground = "${disabled}"; + separator-foreground = "${colors.disabled}"; cursor-click = "pointer"; cursor-scroll = "ns-resize"; modules-left = [ @@ -59,16 +54,16 @@ in "module/xworkspaces" = { type = "internal/xworkspaces"; - label-active-background = "${background-alt}"; - label-active-underline = "${primary}"; + label-active-background = "${colors.background-alt}"; + label-active-underline = "${colors.primary}"; label-active-padding-right = 1; label-occupied-padding-right = 1; - label-urgent-background = "${alert}"; + label-urgent-background = "${colors.alert}"; label-urgent-padding-right = 1; - label-empty-foreground = "${disabled}"; + label-empty-foreground = "${colors.disabled}"; label-empty-padding-right = 1; }; "module/xwindow" = { @@ -98,16 +93,16 @@ in label-mounted = "%{F#88c0d0}%mountpoint%%{F-} %percentage_used%%"; label-unmounted = "%mountpoint% not mounted"; - label-unmounted-foreground = "${disabled}"; + label-unmounted-foreground = "${colors.disabled}"; }; "module/pulseaudio" = { type = "internal/pulseaudio"; format-volume-prefix = "VOL "; - format-volume-prefix-foreground = "${primary}"; + format-volume-prefix-foreground = "${colors.primary}"; label-muted = "muted"; - label-muted-foreground = "${disabled}"; + label-muted-foreground = "${colors.disabled}"; }; "module/memory" = { type = "internal/memory"; @@ -115,7 +110,7 @@ in interval = 2; format-prefix = "RAM "; - format-prefix-foreground = "${primary}"; + format-prefix-foreground = "${colors.primary}"; }; "module/cpu" = { type = "internal/cpu"; @@ -123,7 +118,7 @@ in interval = 2; format-prefix = "CPU "; - format-prefix-foreground = "${primary}"; + format-prefix-foreground = "${colors.primary}"; }; "module/date" = { type = "internal/date"; @@ -133,7 +128,7 @@ in date = "%H:%M"; date-alt = "%Y-%m-%d %H:%M:%S"; - label-foreground = "${primary}"; + label-foreground = "${colors.primary}"; }; }; };