Add more waybar modules and revamp styles

This commit is contained in:
Riley Apeldoorn 2023-06-13 14:34:51 +02:00 committed by Riley Apeldoorn
parent bb2c9ab5e6
commit 253f8a5bb6
2 changed files with 153 additions and 55 deletions

View file

@ -21,6 +21,11 @@ in {
type = bool; type = bool;
default = true; default = true;
}; };
battery.name = lib.mkOption {
type = str;
default = "";
};
bluetooth.enable = lib.mkEnableOption "bluetooth";
}; };
config = { config = {
@ -35,19 +40,27 @@ in {
modules-left = [ modules-left = [
"sway/workspaces" "sway/workspaces"
"sway/mode" "sway/mode"
"mpd"
]; ];
modules-right = lib.flatten [ modules-right = with lib; flatten [
"cpu" "cpu"
"disk" "disk"
(lib.optional (cfg.network.wifi != "") "network#wifi") (optional (cfg.battery.name != "") "battery")
(lib.optional (cfg.network.eth != "") "network#eth") (optional (cfg.bluetooth.enable != "") "bluetooth")
(lib.optional (cfg.network.vpn != "") "network#vpn") (optional (cfg.network.wifi != "") "network#wifi")
(optional (cfg.network.eth != "") "network#eth")
(optional (cfg.network.vpn != "") "network#vpn")
(if cfg.audio.wireplumber (if cfg.audio.wireplumber
then "wireplumber" then "wireplumber"
else "pulseaudio") else "pulseaudio")
"clock#date" "clock#date"
"clock#time" "clock#time"
]; ];
"mpd" = {
"format" = "{artist} | {title}";
"format-stopped" = "";
"format-disconnected" = "";
};
"clock#time" = { "clock#time" = {
"format" = "{:%H:%M:%S}"; "format" = "{:%H:%M:%S}";
"interval" = 1; "interval" = 1;
@ -65,15 +78,51 @@ in {
"network#vpn" = { "network#vpn" = {
"interface" = cfg.network.vpn; "interface" = cfg.network.vpn;
}; };
"pulseaudio" = {
"format" = "{desc}: {volume}%";
};
"wireplumber" = { "wireplumber" = {
"format" = "{node_name}: {volume}%"; "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" = { "disk" = {
"format" = "{used} :: {free}"; "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-family: 'Fira Code';
font-weight: 700; font-weight: 700;
@ -84,77 +133,125 @@ in {
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 { #workspaces {
margin-left: 5px; margin-left: 5px;
background-color: rgba(0, 0, 0, 0.6);
padding: 0; padding: 0;
margin: 5px; margin: 5px;
border-radius: 200px; border-radius: 200px;
background-color: rgba(0, 0, 0, 0.4);
} }
#workspaces button { #workspaces button {
color: #ffffff;
margin: 0; margin: 0;
padding: 0 5px; padding: 0 5px;
border-radius: 100px; border-radius: 100px;
font-size: 0; color: #ffffff;
background-color: rgba(0, 0, 0, 0.4); background-color: rgba(0, 0, 0, 0.4);
} }
#workspaces button.visible.focused { #workspaces button.visible.focused {
background-color: #ff4787; color: #212121;
background-color: ${green};
} }
#workspaces button.visible { #workspaces button.visible {
color: #ffffff; color: ${green};
background-color: rgba(207, 207, 207, 0.4);
} }
#mode { #mode {
padding: 2px 10px; background-color: ${teal};
margin: 5px;
border-radius: 100px;
background-color: #1bcf9c;
font-weight: 600;
} }
/* Clock chips */
#clock { #clock {
padding: 2px 10px;
margin: 5px;
border-radius: 100px;
color: #ffffff; color: #ffffff;
background-color: #3988e3;
}
#clock.date {
background-color: transparent; background-color: transparent;
} }
#clock.date { padding-right: 0; }
#clock.time { padding-left: 0; }
/* Radio chips */
#network { #network {
padding: 2px 10px; background-color: ${green};
margin: 5px;
border-radius: 100px;
background-color: #27e67a;
} }
#wireplumber, #pulseaudio { #network.disconnected {
padding: 2px 10px; ${disabled}
margin: 5px;
border-radius: 100px;
background-color: #edd340;
} }
#wireplumber.muted, #pulseaudio.muted { #bluetooth.connected {
background-color: ${blue};
}
/* Audio chip */
#pulseaudio,
#wireplumber
{
background-color: ${yellow};
}
#pulseaudio.muted,
#wireplumber.muted
{
${disabled}
}
/* Battery chip */
#battery.discharging {
color: #ffffff; color: #ffffff;
background-color: rgba(207, 207, 207, 0.4); background-color: ${violet};
} }
#cpu, #disk { #battery.charging {
padding: 2px 10px; background-color: ${lime};
margin: 5px; }
border-radius: 100px;
#battery.critical {
background-color: ${red};
}
/* MPD chip */
#mpd.playing {
color: #ffffff; color: #ffffff;
background-color: rgba(0, 0, 0, 0.4); }
#mpd.paused {
${disabled}
} }
''; '';

View file

@ -17,6 +17,7 @@
network.wifi = "wlp0s20f3"; network.wifi = "wlp0s20f3";
network.vpn = "wg-dev"; network.vpn = "wg-dev";
audio.wireplumber = false; audio.wireplumber = false;
battery.name = "BAT0";
}; };
}; };