From 369ad06b76f702f01aac4ce2a747fd53a55f3d6f Mon Sep 17 00:00:00 2001 From: Riley Apeldoorn Date: Tue, 13 Jun 2023 11:30:19 +0200 Subject: [PATCH] Make waybar more configurable --- shared/home/gui/waybar.nix | 289 +++++++++++++++++++++---------------- system/dev-lt-63/home.nix | 9 +- system/strawberry/home.nix | 7 +- 3 files changed, 175 insertions(+), 130 deletions(-) diff --git a/shared/home/gui/waybar.nix b/shared/home/gui/waybar.nix index 96ab82e..e74f895 100644 --- a/shared/home/gui/waybar.nix +++ b/shared/home/gui/waybar.nix @@ -1,131 +1,164 @@ -{ ... }: { - programs.waybar = { - enable = true; - systemd = { - enable = true; - target = "sway-session.target"; +{ config, lib, ... }: + +let cfg = config.custom.gui.bar; + +in { + + options.custom.gui.bar = with lib; with types; { + network.wifi = lib.mkOption { + type = str; + default = ""; + }; + network.eth = lib.mkOption { + type = str; + default = ""; + }; + network.vpn = lib.mkOption { + type = str; + default = ""; + }; + audio.wireplumber = lib.mkOption { + type = bool; + default = true; }; - settings = [{ - layer = "top"; - modules-left = [ - "sway/workspaces" - "sway/mode" - ]; - modules-right = [ - "cpu" - "disk" - "wireplumber" - "network#wifi" - "network#eth" - "clock#date" - "clock#time" - ]; - "clock#time" = { - "format" = "{:%H:%M:%S}"; - "interval" = 1; - }; - "clock#date" = { - "format" = "{:%Y-%m-%d}"; - "interval" = 60; - }; - "network#wifi" = { - "interface" = "wlp6s0"; - }; - "network#eth" = { - "interface" = "enp9s0"; - }; - "wireplumber" = { - "format" = "{node_name}: {volume}%"; - }; - "disk" = { - "format" = "{used} :: {free}"; - }; - }]; - - style = '' - * { - font-family: 'Fira Code'; - font-weight: 700; - font-size: 12px; - } - - window#waybar { - background-color: rgba(0,0,0,0.7); - } - - #workspaces { - margin-left: 5px; - background-color: rgba(0, 0, 0, 0.6); - padding: 0; - margin: 5px; - border-radius: 200px; - } - - #workspaces button { - color: #ffffff; - margin: 0; - padding: 0 5px; - border-radius: 100px; - font-size: 0; - background-color: rgba(0, 0, 0, 0.4); - } - - #workspaces button.visible.focused { - background-color: #ff4787; - } - - #workspaces button.visible { - color: #ffffff; - background-color: rgba(207, 207, 207, 0.4); - } - - #mode { - padding: 2px 10px; - margin: 5px; - border-radius: 100px; - background-color: #1bcf9c; - font-weight: 600; - } - - #clock { - padding: 2px 10px; - margin: 5px; - border-radius: 100px; - color: #ffffff; - background-color: #3988e3; - } - - #clock.date { - background-color: transparent; - } - - #network { - padding: 2px 10px; - margin: 5px; - border-radius: 100px; - background-color: #27e67a; - } - - #wireplumber { - padding: 2px 10px; - margin: 5px; - border-radius: 100px; - background-color: #edd340; - } - - #wireplumber.muted { - color: #ffffff; - background-color: rgba(207, 207, 207, 0.4); - } - - #cpu, #disk { - padding: 2px 10px; - margin: 5px; - border-radius: 100px; - color: #ffffff; - background-color: rgba(0, 0, 0, 0.4); - } - - ''; }; + + config = { + programs.waybar = { + enable = true; + systemd = { + enable = true; + target = "sway-session.target"; + }; + settings = [{ + layer = "top"; + modules-left = [ + "sway/workspaces" + "sway/mode" + ]; + modules-right = lib.flatten [ + "cpu" + "disk" + (lib.optional (cfg.network.wifi != "") "network#wifi") + (lib.optional (cfg.network.eth != "") "network#eth") + (lib.optional (cfg.network.vpn != "") "network#vpn") + (if cfg.audio.wireplumber + then "wireplumber" + else "pulseaudio") + "clock#date" + "clock#time" + ]; + "clock#time" = { + "format" = "{:%H:%M:%S}"; + "interval" = 1; + }; + "clock#date" = { + "format" = "{:%Y-%m-%d}"; + "interval" = 60; + }; + "network#wifi" = { + "interface" = cfg.network.wifi; + }; + "network#eth" = { + "interface" = cfg.network.eth; + }; + "network#vpn" = { + "interface" = cfg.network.vpn; + }; + "wireplumber" = { + "format" = "{node_name}: {volume}%"; + }; + "disk" = { + "format" = "{used} :: {free}"; + }; + }]; + + style = '' + * { + font-family: 'Fira Code'; + font-weight: 700; + font-size: 12px; + } + + window#waybar { + background-color: rgba(0,0,0,0.7); + } + + #workspaces { + margin-left: 5px; + background-color: rgba(0, 0, 0, 0.6); + padding: 0; + margin: 5px; + border-radius: 200px; + } + + #workspaces button { + color: #ffffff; + margin: 0; + padding: 0 5px; + border-radius: 100px; + font-size: 0; + background-color: rgba(0, 0, 0, 0.4); + } + + #workspaces button.visible.focused { + background-color: #ff4787; + } + + #workspaces button.visible { + color: #ffffff; + background-color: rgba(207, 207, 207, 0.4); + } + + #mode { + padding: 2px 10px; + margin: 5px; + border-radius: 100px; + background-color: #1bcf9c; + font-weight: 600; + } + + #clock { + padding: 2px 10px; + margin: 5px; + border-radius: 100px; + color: #ffffff; + background-color: #3988e3; + } + + #clock.date { + background-color: transparent; + } + + #network { + padding: 2px 10px; + margin: 5px; + border-radius: 100px; + background-color: #27e67a; + } + + #wireplumber, #pulseaudio { + padding: 2px 10px; + margin: 5px; + border-radius: 100px; + background-color: #edd340; + } + + #wireplumber.muted, #pulseaudio.muted { + color: #ffffff; + background-color: rgba(207, 207, 207, 0.4); + } + + #cpu, #disk { + padding: 2px 10px; + margin: 5px; + border-radius: 100px; + color: #ffffff; + background-color: rgba(0, 0, 0, 0.4); + } + + ''; + }; + }; + } diff --git a/system/dev-lt-63/home.nix b/system/dev-lt-63/home.nix index e663517..ff10454 100644 --- a/system/dev-lt-63/home.nix +++ b/system/dev-lt-63/home.nix @@ -11,7 +11,14 @@ home-manager.enable = false; }; - custom.gui.enable = true; + custom.gui = { + enable = true; + bar = { + network.wifi = "wlp0s20f3"; + network.vpn = "wg-dev"; + audio.wireplumber = false; + }; + }; xdg.systemDirs.data = [ "/usr/share" "/usr/local/share" ]; fonts.fontconfig.enable = true; diff --git a/system/strawberry/home.nix b/system/strawberry/home.nix index 86261ed..5705ff7 100644 --- a/system/strawberry/home.nix +++ b/system/strawberry/home.nix @@ -1,5 +1,10 @@ { ... }: { - custom.gui.enable = true; + custom.gui = { + enable = true; + bar = { + network.eth = "enp9s0"; + }; + }; } \ No newline at end of file