From fce8d778d5f67513412550cedd3b2f65bf0ce9b0 Mon Sep 17 00:00:00 2001 From: Anthony Rodriguez Date: Thu, 21 Nov 2024 09:49:00 +0100 Subject: [PATCH] treewide: add waybar configuration --- home/programs/waybar/default.nix | 148 +++++++++++++++++++++++++++++++ home/programs/waybar/style.nix | 111 +++++++++++++++++++++++ hosts/vamos/default.nix | 2 +- 3 files changed, 260 insertions(+), 1 deletion(-) create mode 100644 home/programs/waybar/default.nix create mode 100644 home/programs/waybar/style.nix diff --git a/home/programs/waybar/default.nix b/home/programs/waybar/default.nix new file mode 100644 index 0000000..92c404c --- /dev/null +++ b/home/programs/waybar/default.nix @@ -0,0 +1,148 @@ +{ + osConfig, + pkgs, + lib, + ... +}: let + inherit (lib) getExe; +in { + imports = [./style.nix]; + programs.waybar = { + enable = true; + systemd.enable = true; + settings = { + mainBar = { + layer = "top"; + position = "top"; + height = 30; + + margin-top = 6; + margin-left = 6; + margin-right = 6; + margin-bottom = 0; + + modules-left = ["niri/workspaces" "niri/window"]; + modules-center = ["group/clock"]; + modules-right = ["tray" "group/status" "group/power"]; + + battery = { + interval = 60; + states = { + warning = 30; + critical = 15; + }; + format = "{icon} {capacity}%"; + format-icons = [ + "" + "" + "" + "" + "" + ]; + max-length = 25; + }; + + "niri/window" = { + icon = true; + }; + + "pulseaudio" = { + format = "{icon} {volume}%"; + format-bluetooth = "{icon} {volume}%"; + format-muted = " "; + format-icons = { + "alsa_output.pci-0000_00_1f.3.analog-stereo" = ""; + "alsa_output.pci-0000_00_1f.3.analog-stereo-muted" = ""; + headphone = ""; + hands-free = ""; + headset = ""; + phone = ""; + phone-muted = ""; + portable = ""; + car = ""; + default = [ + "" + "" + ]; + }; + scroll-step = 1; + on-click = "pavucontrol"; + ignored-sinks = [ + "Easy Effects Sink" + ]; + }; + + "power-profiles-daemon" = { + format-icons = { + default = ""; + performance = ""; + balanced = ""; + power-saver = ""; + }; + }; + + "group/status" = { + orientation = "inherit"; + modules = [ + "pulseaudio" + "power-profiles-daemon" + "network" + "battery" + ]; + }; + + "group/power" = { + orientation = "inherit"; + modules = [ + "custom/power" + ]; + }; + + "group/clock" = { + orientation = "inherit"; + modules = [ + "clock#time" + "clock#date" + ]; + }; + + "custom/power" = { + format = ""; + tooltip = false; + on-click = getExe pkgs.wlogout; + }; + + "clock#date" = { + format = "{:%D}"; + tooltip-format = "{calendar}"; + }; + + "clock#time" = { + format = "{:%H:%M}"; + tooltip-format = "{tz_list}"; + timezones = [ + osConfig.time.timeZone + "US/Eastern" + ]; + }; + + network = { + interface = "wlp1s0"; + format = "{ifname}"; + format-wifi = "({signalStrength}%) "; + format-ethernet = "{ipaddr}/{cidr} 󰊗"; + format-disconnected = ""; + tooltip-format = "{ifname} via {gwaddr} 󰊗"; + tooltip-format-wifi = "{essid} ({signalStrength}%) "; + tooltip-format-ethernet = "{ifname} "; + tooltip-format-disconnected = "Disconnected"; + max-length = 50; + }; + }; + }; + }; + + home.packages = [ + pkgs.pavucontrol + ]; +} diff --git a/home/programs/waybar/style.nix b/home/programs/waybar/style.nix new file mode 100644 index 0000000..74174cd --- /dev/null +++ b/home/programs/waybar/style.nix @@ -0,0 +1,111 @@ +{ + inputs, + lib, + osConfig, + ... +}: let + inherit (inputs.basix.schemeData.base16.${osConfig.theme.scheme}) palette; + inherit (builtins) concatStringsSep; + inherit (lib) mapAttrsToList; + + generateGtkColors = palette: (concatStringsSep "\n" + (mapAttrsToList + (name: color: "@define-color ${name} ${color};") + palette)); +in { + programs.waybar.style = '' + ${ + if osConfig.theme.enable + then generateGtkColors palette + else "" + } + + * { + /* `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.25; + 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, + #pulseaudio, + #tray, + #power-profiles-daemon { + padding: 0 0.8em; + } + + .modules-left, + .modules-right { + margin: 0.4em 0.5em; + } + + + #custom-power { + padding: 0 1.2em; + color: @base08; + } + ''; +} diff --git a/hosts/vamos/default.nix b/hosts/vamos/default.nix index 135a692..a3a156c 100644 --- a/hosts/vamos/default.nix +++ b/hosts/vamos/default.nix @@ -34,7 +34,7 @@ in { "${home}/services/udiskie.nix" "${home}/programs/niri" - "${home}/programs/ironbar" + "${home}/programs/waybar" "${home}/programs/fuzzel.nix" "${home}/programs/swaybg.nix" "${home}/programs/swaylock.nix"