From 8b6e8fb9364e9acdf6b13119c426108dfe364c86 Mon Sep 17 00:00:00 2001 From: alejandro-angulo Date: Fri, 2 Aug 2024 20:25:59 -0700 Subject: [PATCH] Converted waybar to a home module --- modules/home/programs/waybar/default.nix | 171 +++++++++++++++++ .../programs}/waybar/waybar_style.css | 0 .../nixos/desktop/addons/waybar/default.nix | 175 ------------------ modules/nixos/desktop/sway/default.nix | 1 - systems/x86_64-linux/gospel/default.nix | 3 +- 5 files changed, 173 insertions(+), 177 deletions(-) create mode 100644 modules/home/programs/waybar/default.nix rename modules/{nixos/desktop/addons => home/programs}/waybar/waybar_style.css (100%) delete mode 100644 modules/nixos/desktop/addons/waybar/default.nix diff --git a/modules/home/programs/waybar/default.nix b/modules/home/programs/waybar/default.nix new file mode 100644 index 0000000..b6dcd5e --- /dev/null +++ b/modules/home/programs/waybar/default.nix @@ -0,0 +1,171 @@ +{ + pkgs, + config, + lib, + namespace, + ... +}: let + inherit (lib) mkIf mkEnableOption mkOption types; + + cfg = config.${namespace}.programs.waybar; +in { + options.aa.programs.waybar = { + enable = mkEnableOption "waybar"; + + thermal-zone = mkOption { + type = types.int; + default = 0; + description = "The thermal zone, as in `/sys/class/thermal/`."; + }; + }; + + config = mkIf cfg.enable { + programs.waybar = { + enable = true; + systemd.enable = true; + + style = builtins.readFile ./waybar_style.css; + + settings = [ + { + layer = "top"; + position = "bottom"; + height = 20; + modules-left = ["sway/workspaces"]; + modules-center = ["clock"]; + modules-right = [ + "idle_inhibitor" + "temperature" + "cpu" + "pulseaudio" + "battery" + "memory" + "backlight" + "network" + "custom/notification" + "tray" + ]; + + "sway/workspaces" = { + disable-scroll = false; + all-outputs = true; + format = "{icon}"; + format-icons = { + "1" = "q"; + "2" = "w"; + "3" = "e"; + "4" = "r"; + "5" = "t"; + "6" = "y"; + "7" = "u"; + "8" = "i"; + "9" = "o"; + }; + }; + + idle_inhibitor = { + format = "{icon}"; + format-icons = { + activated = " "; + deactivated = " "; + }; + }; + + temperature = { + critical-threshold = 80; + format = "{icon}{temperatureC}°C"; + format-icons = [" " " " " "]; + thermal-zone = cfg.thermal-zone; + }; + + cpu = { + format = " {usage}%"; + tooltip = false; + }; + + pulseaudio = { + format = "{icon} {volume}% {format_source}"; + format-bluetooth = "{icon} {volume}% {format_source}"; + format-bluetooth-muted = "  {volume}% {format_source}"; + format-muted = " {format_source}"; + format-source = " "; + format-source-muted = " "; + format-icons = { + headphone = " "; + hands-free = " "; + headset = " "; + phone = " "; + portable = " "; + car = " "; + default = [" " " " " "]; + }; + tooltip-format = "{desc}, {volume}%"; + # TODO: Figure out how to get pactl binary? + on-click = "pactl set-sink-mute @DEFAULT_SINK@ toggle"; + on-click-right = "pactl set-source-mute @DEFAULT_SOURCE@ toggle"; + on-click-middle = "pavucontrol"; + }; + + battery = { + states = { + warning = 30; + critical = 1; + }; + format = "{icon} {capacity}%"; + tooltip-format = "{timeTo}, {capacity}%"; + format-charging = "󰂄 {capacity}%"; + format-plugged = " "; + format-alt = "{time} {icon}"; + format-icons = [" " " " " " " " " "]; + }; + + memory = { + format = " {}%"; + }; + + backlight = { + format = "{icon} {percent}%"; + format-icons = ["󰃞`" "󰃚"]; + on-scroll-up = "light -A 1"; + on-scroll-down = "light -U 1"; + }; + + network = { + format-wifi = " "; + format-ethernet = "{ifname}: {ipaddr}/{cidr} 󰈀 "; + format-linked = "{ifname} (No IP)  "; + format-disconnected = "睊 "; + format-alt = "{ifname}: {ipaddr}/{cidr}"; + tooltip-format = "{essid} {signalStrength}%"; + }; + + "custom/notification" = mkIf config.${namespace}.services.swaync.enable { + tooltip = false; + format = "{icon} {}"; + format-icons = { + notification = ""; + none = ""; + dnd-notification = ""; + dnd-none = ""; + inhibited-notification = ""; + inhibited-none = ""; + dnd-inhibited-notification = ""; + dnd-inhibited-none = ""; + }; + return-type = "json"; + exec = "${pkgs.swaynotificationcenter}/bin/swaync-client -swb"; + on-click = "${pkgs.swaynotificationcenter}/bin/swaync-client -t -sw"; + on-click-right = "${pkgs.swaynotificationcenter}/bin/swaync-client -d -sw"; + escape = true; + }; + + tray = { + spacing = 10; + }; + } + ]; + }; + + wayland.windowManager.sway.config.bars = []; + }; +} diff --git a/modules/nixos/desktop/addons/waybar/waybar_style.css b/modules/home/programs/waybar/waybar_style.css similarity index 100% rename from modules/nixos/desktop/addons/waybar/waybar_style.css rename to modules/home/programs/waybar/waybar_style.css diff --git a/modules/nixos/desktop/addons/waybar/default.nix b/modules/nixos/desktop/addons/waybar/default.nix deleted file mode 100644 index 4202e08..0000000 --- a/modules/nixos/desktop/addons/waybar/default.nix +++ /dev/null @@ -1,175 +0,0 @@ -{ - pkgs, - config, - lib, - ... -}: -with lib; let - cfg = config.aa.desktop.addons.waybar; -in { - options.aa.desktop.addons.waybar = with types; { - enable = mkEnableOption "waybar"; - - thermal-zone = mkOption { - type = int; - default = 0; - description = "The thermal zone, as in `/sys/class/thermal/`."; - }; - }; - - config = mkIf cfg.enable { - aa.system.fonts.enable = true; - - aa.home = { - extraOptions = { - programs.waybar = { - enable = true; - systemd.enable = true; - - style = builtins.readFile ./waybar_style.css; - - settings = [ - { - layer = "top"; - position = "bottom"; - height = 20; - modules-left = ["sway/workspaces"]; - modules-center = ["clock"]; - modules-right = [ - "idle_inhibitor" - "temperature" - "cpu" - "pulseaudio" - "battery" - "memory" - "backlight" - "network" - "custom/notification" - "tray" - ]; - - "sway/workspaces" = { - disable-scroll = false; - all-outputs = true; - format = "{icon}"; - format-icons = { - "1" = "q"; - "2" = "w"; - "3" = "e"; - "4" = "r"; - "5" = "t"; - "6" = "y"; - "7" = "u"; - "8" = "i"; - "9" = "o"; - }; - }; - - idle_inhibitor = { - format = "{icon}"; - format-icons = { - activated = " "; - deactivated = " "; - }; - }; - - temperature = { - critical-threshold = 80; - format = "{icon}{temperatureC}°C"; - format-icons = [" " " " " "]; - thermal-zone = cfg.thermal-zone; - }; - - cpu = { - format = " {usage}%"; - tooltip = false; - }; - - pulseaudio = { - format = "{icon} {volume}% {format_source}"; - format-bluetooth = "{icon} {volume}% {format_source}"; - format-bluetooth-muted = "  {volume}% {format_source}"; - format-muted = " {format_source}"; - format-source = " "; - format-source-muted = " "; - format-icons = { - headphone = " "; - hands-free = " "; - headset = " "; - phone = " "; - portable = " "; - car = " "; - default = [" " " " " "]; - }; - tooltip-format = "{desc}, {volume}%"; - # TODO: Figure out how to get pactl binary? - on-click = "pactl set-sink-mute @DEFAULT_SINK@ toggle"; - on-click-right = "pactl set-source-mute @DEFAULT_SOURCE@ toggle"; - on-click-middle = "pavucontrol"; - }; - - battery = { - states = { - warning = 30; - critical = 1; - }; - format = "{icon} {capacity}%"; - tooltip-format = "{timeTo}, {capacity}%"; - format-charging = "󰂄 {capacity}%"; - format-plugged = " "; - format-alt = "{time} {icon}"; - format-icons = [" " " " " " " " " "]; - }; - - memory = { - format = " {}%"; - }; - - backlight = { - format = "{icon} {percent}%"; - format-icons = ["󰃞`" "󰃚"]; - on-scroll-up = "light -A 1"; - on-scroll-down = "light -U 1"; - }; - - network = { - format-wifi = " "; - format-ethernet = "{ifname}: {ipaddr}/{cidr} 󰈀 "; - format-linked = "{ifname} (No IP)  "; - format-disconnected = "睊 "; - format-alt = "{ifname}: {ipaddr}/{cidr}"; - tooltip-format = "{essid} {signalStrength}%"; - }; - - # "custom/notification" = mkIf config.aa.desktop.addons.swaync.enable { - # tooltip = false; - # format = "{icon} {}"; - # format-icons = { - # notification = ""; - # none = ""; - # dnd-notification = ""; - # dnd-none = ""; - # inhibited-notification = ""; - # inhibited-none = ""; - # dnd-inhibited-notification = ""; - # dnd-inhibited-none = ""; - # }; - # return-type = "json"; - # exec = "${pkgs.swaynotificationcenter}/bin/swaync-client -swb"; - # on-click = "${pkgs.swaynotificationcenter}/bin/swaync-client -t -sw"; - # on-click-right = "${pkgs.swaynotificationcenter}/bin/swaync-client -d -sw"; - # escape = true; - # }; - - tray = { - spacing = 10; - }; - } - ]; - }; - - wayland.windowManager.sway.config.bars = []; - }; - }; - }; -} diff --git a/modules/nixos/desktop/sway/default.nix b/modules/nixos/desktop/sway/default.nix index 7b6cc90..f4a5088 100644 --- a/modules/nixos/desktop/sway/default.nix +++ b/modules/nixos/desktop/sway/default.nix @@ -42,7 +42,6 @@ in { rofi.enable = true; swayidle.enable = true; swaylock.enable = true; - waybar.enable = true; # TODO # light diff --git a/systems/x86_64-linux/gospel/default.nix b/systems/x86_64-linux/gospel/default.nix index c7370e5..099d3a9 100644 --- a/systems/x86_64-linux/gospel/default.nix +++ b/systems/x86_64-linux/gospel/default.nix @@ -17,7 +17,8 @@ workstation.enable = true; }; - desktop.addons.waybar.thermal-zone = 1; + # TODO: How to inform a home manager module about this? + # desktop.addons.waybar.thermal-zone = 1; suites.gaming.enable = true;