os/shared/home/gui/waybar.nix

262 lines
5.4 KiB
Nix
Raw Normal View History

2023-06-13 11:30:19 +02:00
{ config, lib, ... }:
let cfg = config.custom.gui.bar;
in {
options.custom.gui.bar = with lib; with types; {
network.wifi = lib.mkOption {
type = str;
default = "";
2023-06-06 19:54:12 +02:00
};
2023-06-13 11:30:19 +02:00
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";
2023-06-13 11:30:19 +02:00
};
config = {
programs.waybar = {
enable = true;
systemd = {
enable = true;
target = "sway-session.target";
2023-06-06 19:54:12 +02:00
};
2023-06-13 11:30:19 +02:00
settings = [{
layer = "top";
modules-left = [
"sway/workspaces"
"sway/mode"
"mpd"
2023-06-13 11:30:19 +02:00
];
modules-right = with lib; flatten [
2023-06-13 11:30:19 +02:00
"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")
2023-06-13 11:30:19 +02:00
(if cfg.audio.wireplumber
then "wireplumber"
else "pulseaudio")
"clock#date"
"clock#time"
];
"mpd" = {
"format" = "{artist} | {title}";
"format-stopped" = "";
"format-disconnected" = "";
};
2023-06-13 11:30:19 +02:00
"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}%";
};
2023-06-13 11:30:19 +02:00
"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}";
};
2023-06-13 11:30:19 +02:00
"disk" = {
"format" = "{used} :: {free}";
};
"sway/workspaces" = {
"all-outputs" = true;
};
2023-06-13 11:30:19 +02:00
}];
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 */
2023-06-13 11:30:19 +02:00
* {
font-family: 'Fira Code';
font-weight: 700;
font-size: 12px;
2023-06-13 11:30:19 +02:00
}
window#waybar {
background-color: rgba(0, 0, 0, 0.7);
2023-06-13 11:30:19 +02:00
}
#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 */
2023-06-13 11:30:19 +02:00
#workspaces {
margin-left: 5px;
padding: 0;
margin: 5px;
border-radius: 200px;
background-color: rgba(0, 0, 0, 0.4);
2023-06-13 11:30:19 +02:00
}
#workspaces button {
margin: 0;
padding: 0 5px;
border-radius: 100px;
color: #ffffff;
background-color: rgba(0, 0, 0, 0.4);
2023-06-13 11:30:19 +02:00
}
#workspaces button.visible.focused {
color: #212121;
background-color: ${green};
2023-06-13 11:30:19 +02:00
}
#workspaces button.visible {
color: ${green};
2023-06-13 11:30:19 +02:00
}
#mode {
background-color: ${teal};
2023-06-13 11:30:19 +02:00
}
/* Clock chips */
2023-06-13 11:30:19 +02:00
#clock {
color: #ffffff;
background-color: transparent;
2023-06-13 11:30:19 +02:00
}
#clock.date { padding-right: 0; }
#clock.time { padding-left: 0; }
/* Radio chips */
2023-06-13 11:30:19 +02:00
#network {
background-color: ${green};
2023-06-13 11:30:19 +02:00
}
#network.disconnected {
${disabled}
2023-06-13 11:30:19 +02:00
}
#bluetooth.connected {
background-color: ${blue};
2023-06-13 11:30:19 +02:00
}
/* Audio chip */
#pulseaudio,
#wireplumber
{
background-color: ${yellow};
}
#pulseaudio.muted,
#wireplumber.muted
{
${disabled}
}
/* Battery chip */
#battery.discharging {
color: #ffffff;
background-color: ${violet};
2023-06-13 11:30:19 +02:00
}
#battery.charging {
background-color: ${lime};
}
#battery.critical {
background-color: ${red};
}
/* MPD chip */
#mpd.playing {
color: #ffffff;
}
#mpd.paused {
${disabled}
}
2023-06-13 11:30:19 +02:00
'';
};
2023-06-06 19:54:12 +02:00
};
2023-06-13 11:30:19 +02:00
2023-06-06 19:54:12 +02:00
}