From f5a893550799286c04b9c5340e311eeddb50e58f Mon Sep 17 00:00:00 2001 From: Noa Aarts Date: Sun, 23 Mar 2025 22:46:00 +0100 Subject: [PATCH] waybar redo --- common/colors.nix | 1 + common/home/default.nix | 7 +-- modules/waybar/battery.nix | 79 ++++++++++++++++++++++++++++++++++ modules/waybar/bluetooth.nix | 34 +++++++++++++++ modules/waybar/clock.nix | 18 ++++---- modules/waybar/cpu.nix | 10 ++--- modules/waybar/default.nix | 22 +++++++++- modules/waybar/memory.nix | 10 ++--- modules/waybar/network.nix | 24 ++++++----- modules/waybar/spotify.nix | 14 +++--- modules/waybar/temperature.nix | 35 ++++++++++----- modules/waybar/tray.nix | 11 +++-- modules/waybar/wireplumber.nix | 20 +++++---- modules/waybar/workspaces.nix | 10 ++--- 14 files changed, 223 insertions(+), 72 deletions(-) create mode 100644 modules/waybar/battery.nix create mode 100644 modules/waybar/bluetooth.nix diff --git a/common/colors.nix b/common/colors.nix index 8cc1060..f8c5a98 100644 --- a/common/colors.nix +++ b/common/colors.nix @@ -37,6 +37,7 @@ base16 = "#d6acff"; # bright blue base17 = "#ff92df"; # bright purple taskbarText = base04; + taskbarBackground = base10; background_paper = "#000000"; foreground_paper = "#26052e"; }; diff --git a/common/home/default.nix b/common/home/default.nix index 26369e6..87be166 100644 --- a/common/home/default.nix +++ b/common/home/default.nix @@ -194,12 +194,13 @@ in "custom/spotify" ]; right = [ - "custom/vpn" - "wireplumber" + "custom/bluetooth" + "battery" "network" + "wireplumber" "cpu" "memory" - "custom/poweroff" + "temperature" ]; }; enable = lib.mkDefault enableGraphical; diff --git a/modules/waybar/battery.nix b/modules/waybar/battery.nix new file mode 100644 index 0000000..69bb000 --- /dev/null +++ b/modules/waybar/battery.nix @@ -0,0 +1,79 @@ +{ + lib, + config, + ... +}: +let + name = "battery"; +in +{ + options.modules.waybar.modules = import ./addname.nix lib name; + options.modules.waybar.enabled.${name} = { + enable = lib.mkEnableOption "enable ${name} waybar module"; + }; + config = lib.mkIf config.modules.waybar.enabled.${name}.enable { + programs.waybar = { + settings.mainBar.${name} = { + states = { + full = 100; + good = 99; + warning = 30; + critical = 15; + }; + format = "{capacity}% {icon}"; + format-charging = "{capacity}% {icon}"; + format-plugged = "{capacity}% {icon}"; + format-alt = "{time} {icon}"; + + interval = 1; + format-full = ""; + format-icons = [ + "󰂎" + "󰁻" + "󰁾" + "󰂀" + "󰁹" + ]; + }; + style = '' + #battery { + color: #${config.colorScheme.palette.taskbarText}; + margin: 5px 2px; + padding: 0 12px; + border-radius: 999px; + min-width: 40px; + transition: all 0.3s; + background-color: #${config.colorScheme.palette.taskbarBackground}; + } + + #battery.charging, + #battery.plugged, + #battery.full { + color: #${config.colorScheme.palette.taskbarText}; + background-color: #${config.colorScheme.palette.taskbarBackground}; + box-shadow: none; + } + + #battery.critical:not(.charging) { + background-color: transparent; + animation: batteryCritical 1.2s linear 0s infinite normal forwards; + } + + @keyframes batteryCritical { + 0% { + background-color: #${config.colorScheme.palette.base08}; + color: #${config.colorScheme.palette.base06}; + } + 50% { + background-color: #${config.colorScheme.palette.base02}; + color: #${config.colorScheme.palette.base08}; + } + 100% { + background-color: #${config.colorScheme.palette.base08}; + color: #${config.colorScheme.palette.base06}; + } + } + ''; + }; + }; +} diff --git a/modules/waybar/bluetooth.nix b/modules/waybar/bluetooth.nix new file mode 100644 index 0000000..87a6534 --- /dev/null +++ b/modules/waybar/bluetooth.nix @@ -0,0 +1,34 @@ +{ + lib, + config, + pkgs, + ... +}: +let + name = "custom/bluetooth"; +in +{ + options.modules.waybar = { + modules = import ./addname.nix lib name; + enabled.${name} = { + enable = lib.mkEnableOption "enable ${name} waybar module"; + }; + }; + config = lib.mkIf config.modules.waybar.enabled.${name}.enable { + programs.waybar = { + settings.mainBar."${name}" = { + format = ""; + on-click = lib.meta.getExe' pkgs.blueberry "blueberry"; + }; + style = '' + #custom-bluetooth { + color: #${config.colorScheme.palette.taskbarText}; + margin: 5px 0px; + padding: 0 8px; + background-color: #${config.colorScheme.palette.taskbarBackground}; + border-radius: 999px 0 0 999px; + } + ''; + }; + }; +} diff --git a/modules/waybar/clock.nix b/modules/waybar/clock.nix index 099f57a..8e7eddd 100644 --- a/modules/waybar/clock.nix +++ b/modules/waybar/clock.nix @@ -19,25 +19,23 @@ in interval = 1; format = "{:%H:%M:%S}"; format-alt = "{:%Y-%m-%d %H:%M:%S}"; - on-click-middle = "gnome-clocks"; + on-click-middle = lib.meta.getExe' pkgs.gnome-clocks "gnome-clocks"; calendar = { weeks-pos = "left"; format = { - today = "{}"; # TODO: use nix-colors - weeks = "{}"; # TODO: use nix-colors + today = "{}"; # TODO: use nix-colors + weeks = "{}"; # TODO: use nix-colors }; }; - home.packages = [ - pkgs.gnome-clocks - ]; }; style = '' #clock { color: #${config.colorScheme.palette.taskbarText}; - margin: 0px 2px; - padding: 0 15px; - - border-radius: 999px; + background-color: #${config.colorScheme.palette.taskbarBackground}; + margin: 5px 0px; + margin-right: 2px; + padding: 0 12px; + border-radius: 999px 0 0 999px; box-shadow: none; } ''; diff --git a/modules/waybar/cpu.nix b/modules/waybar/cpu.nix index e5b1a3b..9dee631 100644 --- a/modules/waybar/cpu.nix +++ b/modules/waybar/cpu.nix @@ -12,17 +12,15 @@ in config = lib.mkIf config.modules.waybar.enabled.${name}.enable { programs.waybar = { settings.mainBar."${name}" = { - format = "cpu: {usage}%"; + format = " {usage}%"; tooltip = false; }; style = '' #cpu { color: #${config.colorScheme.palette.taskbarText}; - margin: 0px 0px; - padding: 0 15px; - - border-radius: 999px 0px 0px 999px; - box-shadow: inset 0 0 0 1px #${config.colorScheme.palette.base01}; + margin: 5px 0px; + padding: 0 8px; + background-color: #${config.colorScheme.palette.taskbarBackground}; } ''; }; diff --git a/modules/waybar/default.nix b/modules/waybar/default.nix index c282d01..bceacd2 100644 --- a/modules/waybar/default.nix +++ b/modules/waybar/default.nix @@ -48,6 +48,8 @@ in ./temperature.nix ./wireplumber.nix ./spotify.nix + ./battery.nix + ./bluetooth.nix ../../common/colors.nix ]; @@ -94,7 +96,25 @@ in style = '' * { font-family: "Maple Mono NF"; - font-size: 14px; + font-size: 12px; + } + + window#waybar { + background-color: transparent; + color: #${config.colorScheme.palette.taskbarText}; + transition-property: background-color; + transition-duration: 0.5s; + } + window#waybar.hidden { + opacity: 0.2; + } + + window#waybar.termite { + background-color: transparent; + } + + window#waybar.chromium { + background-color: transparent; } button { diff --git a/modules/waybar/memory.nix b/modules/waybar/memory.nix index 38cd55c..d709b36 100644 --- a/modules/waybar/memory.nix +++ b/modules/waybar/memory.nix @@ -12,17 +12,15 @@ in config = lib.mkIf config.modules.waybar.enabled.${name}.enable { programs.waybar = { settings.mainBar."${name}" = { - format = "mem: {}%"; + format = " {}%"; tooltip = false; }; style = '' #memory { - border-radius: 0px 999px 999px 0px; - padding: 0 10px; color: #${config.colorScheme.palette.taskbarText}; - margin: 0px; - box-shadow: inset 0px 2px 0 -1px #${config.colorScheme.palette.base01}, - inset 0px -2px 0 -1px #${config.colorScheme.palette.base01}; + margin: 5px 0px; + padding: 0 8px; + background-color: #${config.colorScheme.palette.taskbarBackground}; } ''; }; diff --git a/modules/waybar/network.nix b/modules/waybar/network.nix index 76b9177..ed01334 100644 --- a/modules/waybar/network.nix +++ b/modules/waybar/network.nix @@ -12,23 +12,25 @@ in config = lib.mkIf config.modules.waybar.enabled.${name}.enable { programs.waybar = { settings.mainBar."${name}" = { - format-wifi = "{essid} ({signalStrength}%) 󰖩"; - format-ethernet = "{ipaddr}/{cidr} 󰛳"; - tooltip-format = "{ifname} via {gwaddr} 󰛳"; - format-linked = "{ifname} (No IP) 󰛳"; - format-disconnected = "Disconnected "; - format-alt = "{ifname}: {ipaddr}/{cidr}"; + format-wifi = "󰖩"; + format-ethernet = "󰲝"; + tooltip-format = "ssid : {essid}\naddr : {ipaddr}/{cidr}\ngate : {gwaddr}\ndev : {ifname}"; + format-linked = "󰲝"; + format-disconnected = ""; + format-alt = "{ipaddr}/{cidr}"; }; style = '' #network { color: #${config.colorScheme.palette.taskbarText}; - margin: 0px 2px; - padding: 0 15px; - border-radius: 999px; - box-shadow: inset 0 0 0 1px #${config.colorScheme.palette.base01}; + margin: 5px 0px; + padding: 0 8px; + background-color: #${config.colorScheme.palette.taskbarBackground}; } - #network.disconnected, + #network.disconnected { + transition: all 0.2s; + color: #${config.colorScheme.palette.base02}; + } ''; }; }; diff --git a/modules/waybar/spotify.nix b/modules/waybar/spotify.nix index 1fa8036..dc8a901 100644 --- a/modules/waybar/spotify.nix +++ b/modules/waybar/spotify.nix @@ -17,16 +17,20 @@ in config = lib.mkIf config.modules.waybar.enabled.${name}.enable { programs.waybar = { settings.mainBar.${name} = { - exec = ''${pkgs.playerctl}/bin/playerctl metadata --player=spotify -F -f "{{ status }}: {{ artist }} - {{ title }}"''; + exec = ''${lib.meta.getExe pkgs.playerctl} metadata --player=spotify -F -f "{{ status }}: {{ artist }} - {{ title }}"''; format = "{}"; - on-click = "${pkgs.playerctl}/bin/playerctl --player=spotify play-pause"; - on-scroll-up = "${pkgs.playerctl}/bin/playerctl --player=spotify volume 0.01+"; - on-scroll-down = "${pkgs.playerctl}/bin/playerctl --player=spotify volume 0.01-"; + on-click = "${lib.meta.getExe pkgs.playerctl} --player=spotify play-pause"; + on-click-middle = lib.meta.getExe' pkgs.spotify "spotify"; + on-scroll-up = "${lib.meta.getExe pkgs.playerctl} --player=spotify volume 0.01+"; + on-scroll-down = "${lib.meta.getExe pkgs.playerctl} --player=spotify volume 0.01-"; }; style = '' #custom-spotify { color: #${config.colorScheme.palette.base14}; - margin-right: 10px; + margin: 5px 0px; + padding: 0 8px; + background-color: #${config.colorScheme.palette.taskbarBackground}; + border-radius: 0 999px 999px 0; } ''; }; diff --git a/modules/waybar/temperature.nix b/modules/waybar/temperature.nix index 7a43c2f..b87fe63 100644 --- a/modules/waybar/temperature.nix +++ b/modules/waybar/temperature.nix @@ -10,16 +10,31 @@ in }; }; config = lib.mkIf config.modules.waybar.enabled.${name}.enable { - programs.waybar.settings.mainBar."${name}" = { - thermal-zone = 2; - hwmon-path = "/sys/class/hwmon/hwmon3/temp1_input"; - critical-threshold = 80; - format = "{temperatureC}°C {icon}"; - format-icons = [ - "" - "" - "" - ]; + programs.waybar = { + settings.mainBar."${name}" = { + thermal-zone = 2; + hwmon-path = "/sys/class/hwmon/hwmon3/temp1_input"; + critical-threshold = 80; + format = "{icon} {temperatureC}°C"; + format-icons = [ + "" + "" + "" + ]; + }; + style = '' + #temperature { + color: #${config.colorScheme.palette.taskbarText}; + margin: 5px 0px; + padding: 0 8px; + background-color: #${config.colorScheme.palette.taskbarBackground}; + border-radius: 0 999px 999px 0; + } + + #temperature.critcal { + color: #${config.colorScheme.palette.base08}; + } + ''; }; }; } diff --git a/modules/waybar/tray.nix b/modules/waybar/tray.nix index b401cb9..cdd916e 100644 --- a/modules/waybar/tray.nix +++ b/modules/waybar/tray.nix @@ -17,17 +17,16 @@ in style = '' #tray { color: #${config.colorScheme.palette.taskbarText}; - margin: 0px 2px; + margin: 5px 0px; padding: 4px 10px; - border-radius: 999px 999px 999px 999px; - box-shadow: inset 0px 0px 0 1px #${config.colorScheme.palette.base01}; + border-radius: 999px; + background-color: #${config.colorScheme.palette.taskbarBackground}; } - #tray { - background-color: transparent; + #tray > * { + padding: 0 20px; } - #tray > .passive { -gtk-icon-effect: dim; } diff --git a/modules/waybar/wireplumber.nix b/modules/waybar/wireplumber.nix index 3e14238..f7b6248 100644 --- a/modules/waybar/wireplumber.nix +++ b/modules/waybar/wireplumber.nix @@ -1,4 +1,9 @@ -{ lib, config, ... }: +{ + lib, + config, + pkgs, + ... +}: let name = "wireplumber"; in @@ -12,22 +17,21 @@ in config = lib.mkIf config.modules.waybar.enabled.${name}.enable { programs.waybar = { settings.mainBar."${name}" = { - format = "{volume}% {icon}"; - format-muted = ""; - on-click = "helvum"; + format = "{icon} {volume}%"; + format-muted = "󰝟"; format-icons = [ "" "" "" ]; + on-click = lib.meta.getExe' pkgs.helvum "helvum"; }; style = '' #wireplumber { color: #${config.colorScheme.palette.taskbarText}; - margin: 0px 2px; - padding: 0 15px; - border-radius: 999px; - box-shadow: inset 0 0 0 1px #${config.colorScheme.palette.base01}; + margin: 5px 0px; + padding: 0 8px; + background-color: #${config.colorScheme.palette.taskbarBackground}; } ''; }; diff --git a/modules/waybar/workspaces.nix b/modules/waybar/workspaces.nix index c8e35c2..a89670e 100644 --- a/modules/waybar/workspaces.nix +++ b/modules/waybar/workspaces.nix @@ -17,9 +17,9 @@ in sort-by = "id"; }; style = '' - #workspaces button { + #workspaces button { transition: all 0.2s; - padding: 3px 3px 3px 5px; + padding: 4px 4px 4px 5px; margin: 3px; min-width: 15px; min-height: 15px; @@ -41,11 +41,9 @@ in background-color: #${config.colorScheme.palette.base08}; } - #workspaces { - margin: 0 4px; - padding: 4px 4px; + #workspaces { + padding: 4px 4px; border-radius: 999px; - box-shadow: inset 0px 0px 0 1px #${config.colorScheme.palette.base01}; } ''; };