From 253f8a5bb6931a95c7a081a092985e38ba3df7e4 Mon Sep 17 00:00:00 2001 From: Riley Apeldoorn Date: Tue, 13 Jun 2023 14:34:51 +0200 Subject: [PATCH] Add more waybar modules and revamp styles --- shared/home/gui/waybar.nix | 207 +++++++++++++++++++++++++++---------- system/dev-lt-63/home.nix | 1 + 2 files changed, 153 insertions(+), 55 deletions(-) diff --git a/shared/home/gui/waybar.nix b/shared/home/gui/waybar.nix index e74f895..bef1f17 100644 --- a/shared/home/gui/waybar.nix +++ b/shared/home/gui/waybar.nix @@ -21,6 +21,11 @@ in { type = bool; default = true; }; + battery.name = lib.mkOption { + type = str; + default = ""; + }; + bluetooth.enable = lib.mkEnableOption "bluetooth"; }; config = { @@ -35,19 +40,27 @@ in { modules-left = [ "sway/workspaces" "sway/mode" + "mpd" ]; - modules-right = lib.flatten [ + modules-right = with 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") + (optional (cfg.battery.name != "") "battery") + (optional (cfg.bluetooth.enable != "") "bluetooth") + (optional (cfg.network.wifi != "") "network#wifi") + (optional (cfg.network.eth != "") "network#eth") + (optional (cfg.network.vpn != "") "network#vpn") (if cfg.audio.wireplumber then "wireplumber" else "pulseaudio") "clock#date" "clock#time" ]; + "mpd" = { + "format" = "{artist} | {title}"; + "format-stopped" = ""; + "format-disconnected" = ""; + }; "clock#time" = { "format" = "{:%H:%M:%S}"; "interval" = 1; @@ -65,98 +78,182 @@ in { "network#vpn" = { "interface" = cfg.network.vpn; }; + "pulseaudio" = { + "format" = "{desc}: {volume}%"; + }; "wireplumber" = { "format" = "{node_name}: {volume}%"; }; + "battery" = { + "bat" = cfg.battery.name; + "format-discharging" = "{capacity}% (battery)"; + "format-charging" = "{capacity}% (charging)"; + "format-full" = ""; + "states" = { + "critical" = 20; + }; + }; + "bluetooth" = { + "format" = ""; + "format-on" = ""; + "format-connected" = "{device_alias}"; + }; "disk" = { "format" = "{used} :: {free}"; }; + "sway/workspaces" = { + "all-outputs" = true; + }; }]; - style = '' + style = let + green = "#27e67a"; + yellow = "#edd340"; + pink = "#ff4787"; + teal = "#1bcf9c"; + blue = "#3988e3"; + violet = "#9063e6"; + lime = "#bfed5a"; + red = "#eb3b5b"; + disabled = '' + color: #ffffff; + background-color: rgba(207, 207, 207, 0.4); + ''; + in '' + + /* General/shared styles */ + * { - font-family: 'Fira Code'; - font-weight: 700; - font-size: 12px; + font-family: 'Fira Code'; + font-weight: 700; + font-size: 12px; } window#waybar { - background-color: rgba(0,0,0,0.7); + background-color: rgba(0, 0, 0, 0.7); } + #battery, + #bluetooth, + #clock, + #cpu, + #disk, + #mode, + #mpd, + #network, + #pulseaudio, + #wireplumber + { + padding: 2px 10px; + margin: 5px; + border-radius: 100px; + } + + #cpu, #disk, #bluetooth, #mpd { + color: #ffffff; + background-color: rgba(0, 0, 0, 0.4); + } + + + /* Sway chips */ + #workspaces { - margin-left: 5px; - background-color: rgba(0, 0, 0, 0.6); - padding: 0; - margin: 5px; - border-radius: 200px; + margin-left: 5px; + padding: 0; + margin: 5px; + border-radius: 200px; + background-color: rgba(0, 0, 0, 0.4); } #workspaces button { - color: #ffffff; - margin: 0; - padding: 0 5px; - border-radius: 100px; - font-size: 0; - background-color: rgba(0, 0, 0, 0.4); + margin: 0; + padding: 0 5px; + border-radius: 100px; + color: #ffffff; + background-color: rgba(0, 0, 0, 0.4); } #workspaces button.visible.focused { - background-color: #ff4787; + color: #212121; + background-color: ${green}; } #workspaces button.visible { - color: #ffffff; - background-color: rgba(207, 207, 207, 0.4); + color: ${green}; } #mode { - padding: 2px 10px; - margin: 5px; - border-radius: 100px; - background-color: #1bcf9c; - font-weight: 600; + background-color: ${teal}; } + + /* Clock chips */ + #clock { - padding: 2px 10px; - margin: 5px; - border-radius: 100px; - color: #ffffff; - background-color: #3988e3; + color: #ffffff; + background-color: transparent; } - #clock.date { - background-color: transparent; - } + #clock.date { padding-right: 0; } + #clock.time { padding-left: 0; } + + + /* Radio chips */ #network { - padding: 2px 10px; - margin: 5px; - border-radius: 100px; - background-color: #27e67a; + background-color: ${green}; } - #wireplumber, #pulseaudio { - padding: 2px 10px; - margin: 5px; - border-radius: 100px; - background-color: #edd340; + #network.disconnected { + ${disabled} } - #wireplumber.muted, #pulseaudio.muted { - color: #ffffff; - background-color: rgba(207, 207, 207, 0.4); + #bluetooth.connected { + background-color: ${blue}; } - #cpu, #disk { - padding: 2px 10px; - margin: 5px; - border-radius: 100px; - color: #ffffff; - background-color: rgba(0, 0, 0, 0.4); + + /* Audio chip */ + + #pulseaudio, + #wireplumber + { + background-color: ${yellow}; } - + + #pulseaudio.muted, + #wireplumber.muted + { + ${disabled} + } + + + /* Battery chip */ + + #battery.discharging { + color: #ffffff; + background-color: ${violet}; + } + + #battery.charging { + background-color: ${lime}; + } + + #battery.critical { + background-color: ${red}; + } + + + /* MPD chip */ + + #mpd.playing { + color: #ffffff; + } + + #mpd.paused { + ${disabled} + } + ''; }; }; diff --git a/system/dev-lt-63/home.nix b/system/dev-lt-63/home.nix index ff10454..71b6a6a 100644 --- a/system/dev-lt-63/home.nix +++ b/system/dev-lt-63/home.nix @@ -17,6 +17,7 @@ network.wifi = "wlp0s20f3"; network.vpn = "wg-dev"; audio.wireplumber = false; + battery.name = "BAT0"; }; };