os/shared/home/gui/waybar.nix

261 lines
5.4 KiB
Nix

{ 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;
};
battery.name = lib.mkOption {
type = str;
default = "";
};
bluetooth.enable = lib.mkEnableOption "bluetooth";
};
config = {
programs.waybar = {
enable = true;
systemd = {
enable = true;
target = "sway-session.target";
};
settings = [{
layer = "top";
modules-left = [
"sway/workspaces"
"sway/mode"
"mpd"
];
modules-right = with lib; flatten [
"cpu"
"disk"
(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;
};
"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;
};
"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 = 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;
}
window#waybar {
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;
padding: 0;
margin: 5px;
border-radius: 200px;
background-color: rgba(0, 0, 0, 0.4);
}
#workspaces button {
margin: 0;
padding: 0 5px;
border-radius: 100px;
color: #ffffff;
background-color: rgba(0, 0, 0, 0.4);
}
#workspaces button.visible.focused {
color: #212121;
background-color: ${green};
}
#workspaces button.visible {
color: ${green};
}
#mode {
background-color: ${teal};
}
/* Clock chips */
#clock {
color: #ffffff;
background-color: transparent;
}
#clock.date { padding-right: 0; }
#clock.time { padding-left: 0; }
/* Radio chips */
#network {
background-color: ${green};
}
#network.disconnected {
${disabled}
}
#bluetooth.connected {
background-color: ${blue};
}
/* 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}
}
'';
};
};
}