split waybar into multiple files

This commit is contained in:
Lucy Hochkamp 2025-10-06 21:29:04 +02:00
parent 53c7532351
commit 7cff7f09c3
No known key found for this signature in database
29 changed files with 953 additions and 617 deletions

View file

@ -29,7 +29,8 @@ in
theme = "gruvbox-dark";
settings = {
main = {
font = "JetBrainsMono Nerd Font:size=11";
font = "JetBrainsMono Nerd Font:size=11, Noto Color Emoji:size=10";
term = "foot";
};
scrollback = {
lines = 100000;

View file

@ -102,8 +102,9 @@ in
binds {
Mod+D { spawn "${cfg.launcher}"; }
Mod+Alt+L { spawn "lock"; }
Mod+T { spawn "${cfg.term}"; }
Mod+Y { spawn "${cfg.term}" "--app-id" "floating-alacritty" "yazi"; }
Mod+T { spawn "${cfg.term}" "tmux" "new-session" "-t" "main"; }
Mod+Shift+T { spawn "${cfg.term}"; }
Mod+Y { spawn "${cfg.term}" "--app-id" "floating-alacritty" "-W" "120x37" "yazi"; }
Mod+P { spawn "keepassxc"; }
Mod+S { spawn "qalculate-qt"; }
Mod+Shift+N { spawn "makoctl" "dismiss" "-a"; }
@ -417,7 +418,7 @@ in
keyboard {
xkb {
layout "eu"
// options "compose:lalt"
options "compose:caps,mod_led:compose"
}
}
touchpad {

View file

@ -1,451 +0,0 @@
{
pkgs,
config,
lib,
...
}:
let
cfg = config.xyno.desktop.waybar;
json = pkgs.formats.json { };
waybarCfg = {
layer = "top";
position = "top";
height = 20;
modules-left =
(lib.optionals (cfg.mode == "river") [
"river/tags"
"river/layout"
"river/window"
])
++ (lib.optionals (cfg.mode == "niri") [
"niri/workspaces"
"niri/window"
]);
modules-right = [
"tray"
"idle_inhibitor"
"wireplumber"
"battery"
"power-profiles-daemon"
"backlight"
"temperature"
"cpu"
"memory"
"disk"
"network"
"clock"
];
"power-profiles-daemon" = {
format = "{icon} ";
tooltip-format = "Power profile: {profile}\nDriver: {driver}";
tooltip = true;
format-icons = {
"default" = "";
"performance" = "";
"balanced" = "";
"power-saver" = "";
};
};
"river/window" = {
max-length = 40;
};
"niri/window" = {
max-length = 80;
};
wireplumber = {
"format" = "{icon} {volume:.2f} dB";
"format-muted" = " -inf dB";
# "on-click" = "${pkgs.pwvucontrol}/bin/pwvucontrol";
"on-click" = "${pkgs.pavucontrol}/bin/pavucontrol";
"on-click-right" = "${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle";
"on-scroll-up" = "${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ -l 1 1%+";
"on-scroll-down" = "${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ -l 1 1%-";
"format-icons" = [
""
""
""
];
};
"backlight" = {
"device" = "amdgpu_bl1";
"format" = "{icon} {percent}%";
"format-icons" = [
"󰃚"
"󰃛"
"󰃜"
"󰃝"
"󰃞"
"󰃟"
"󰃠"
];
"on-scroll-up" = "${pkgs.light}/bin/light -A 5";
"on-scroll-down" = "${pkgs.light}/bin/light -U 5";
};
"idle_inhibitor" = {
format = "{icon} ";
format-icons = {
"activated" = "󰅶";
"deactivated" = "󰾪";
};
};
battery = {
"states" = {
"warning" = 30;
"critical" = 15;
};
"format" = "{icon} {capacity}%";
"format-icons" = [
""
""
""
""
""
];
"tooltip-format" = "Capacity: {capacity}%\nPower Draw: {power:0.2f}W\n{timeTo}\nCycles: {cycles}";
"max-length" = 25;
};
"cpu" = {
"interval" = 10;
"format" = " {:0.0f}%";
"max-length" = 10;
};
"temperature" = {
"format" = " {temperatureC}°C";
};
memory = {
interval = 30;
format = " {used:0.0f}/{total:0.0f}GB";
};
clock = {
interval = 1;
format = "{:%a %Y-%m-%dT%H:%M:%S%z}";
"tooltip-format" = "<tt><small>{calendar}</small></tt>";
"calendar" = {
"mode" = "year";
"mode-mon-col" = 3;
"weeks-pos" = "right";
"on-scroll" = 1;
"format" = {
"months" = "<span color='#ffead3'><b>{}</b></span>";
"days" = "<span color='#ecc6d9'><b>{}</b></span>";
"weeks" = "<span color='#99ffdd'><b>W{}</b></span>";
"weekdays" = "<span color='#ffcc66'><b>{}</b></span>";
"today" = "<span color='#ff6699'><b><u>{}</u></b></span>";
};
};
"actions" = {
"on-click-right" = "mode";
"on-scroll-up" = "shift_up";
"on-scroll-down" = "shift_down";
};
};
disk = {
format = "󰋊 {specific_used:0.1f}/{specific_total:0.1f}TB";
unit = "TB";
path = "/";
};
"network" = {
"on-click" =
"${pkgs.alacritty}/bin/alacritty --class floating-alacritty -e ${pkgs.impala}/bin/impala";
"format" = "{ifname}";
"format-wifi" = "󰖩 {essid}";
"format-ethernet" = "󰈀 {ifname}";
"format-disconnected" = "󰖪 ";
"tooltip-format" = "{ifname} via {gwaddr}\n{ipaddr}/{cidr}";
"tooltip-format-wifi" = "{essid} ({signaldBm} dBm) {frequency} GHz\n{ipaddr}/{cidr}";
"tooltip-format-ethernet" = "{ifname}\n{ipaddr}/{cidr}";
"tooltip-format-disconnected" = "Disconnected";
"max-length" = 50;
};
};
waybarCfgFile = json.generate "waybar-config.json" waybarCfg;
waybarStyleCss = ''
* {
/* `otf-font-awesome` is required to be installed for icons */
font-family: "Source Sans 3";
font-size: 11px;
}
window#waybar {
color: #a89984;
background-color: #1d2021;
}
window#waybar.hidden {
opacity: 0.2;
}
/*
window#waybar.empty {
background-color: transparent;
}
window#waybar.solo {
background-color: #FFFFFF;
}
*/
/*window#waybar.termite {
background-color: #3F3F3F;
}
window#waybar.chromium {
background-color: #000000;
border: none;
}*/
#workspaces button {
padding: 0 2px;
background-color: #1d2021;
color: #ebdbb2;
/* Use box-shadow instead of border so the text isn't offset */
box-shadow: inset 0 -3px transparent;
/* Avoid rounded borders under each workspace name */
border: none;
border-radius: 0;
}
/* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */
#workspaces button:hover {
background: rgba(0, 0, 0, 0.2);
/* box-shadow: inset 0 -3px #fbf1c7;
*/
background-color: #3c3836;
}
#workspaces button.focused {
/* box-shadow: inset 0 -3px #fbf1c7;
*/
background-color: #3c3836;
color: #ebdbb2;
}
#workspaces button.occupied {
color: #d3869b;
}
#workspaces button.urgent {
background-color: #cc241d;
color: #ebdbb2;
}
#mode {
background-color: #64727D;
border-bottom: 3px solid #fbf1c7;
}
#clock,
#battery,
#cpu,
#memory,
#disk,
#temperature,
#backlight,
#network,
#pulseaudio,
#custom-media,
#tray,
#mode,
#idle_inhibitor,
#custom-poweroff,
#custom-suspend,
#mpd {
padding: 0 2px;
background-color: #1d2021;
color: #ebdbb2;
}
#window,
#workspaces,
#tags {
margin: 0 2px;
}
/* If workspaces is the leftmost module, omit left margin */
.modules-left > widget:first-child > #workspaces {
margin-left: 0;
}
/* If workspaces is the rightmost module, omit right margin */
.modules-right > widget:last-child > #workspaces {
margin-right: 0;
}
#battery {
color: #d3869b;
}
#battery.charging, #battery.plugged {
color: #98971a;
}
@keyframes blink {
to {
background-color: #fbf1c7;
color: #df3f71;
}
}
#battery.critical:not(.charging) {
background-color: #1d2021;
color: #d3869b;
animation-name: blink;
animation-duration: 0.5s;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
label:focus {
background-color: #000000;
}
#backlight {
color: #458588;
}
#temperature {
color: #fabd2f;
}
#temperature.critical {
background-color: #fbf1c7;
color: #b57614;
}
#memory {
color: #FCF434; /* enby yellow */
}
#disk {
color: #FFFFFF; /* enby white */
}
#network {
color: #b8bb26; /* enby green */
}
#clock {
color: #9C59D1; /* enby purple */
/*color: #2C2C2C; enby black */
}
#network.disconnected {
background-color: #fbf1c7;
color: #9d0006;
}
#wireplumber {
color: #fe8019;
}
#tray {
}
#tray > .needs-attention {
background-color: #fbf1c7;
color: #3c3836;
}
#idle_inhibitor {
background-color: #1d2021;
color: #ebdbb2;
}
#idle_inhibitor.activated {
background-color: #fbf1c7;
color: #3c3836;
}
#custom-media {
background-color: #66cc99;
color: #2a5c45;
min-width: 100px;
}
#custom-media.custom-spotify {
background-color: #66cc99;
}
#custom-media.custom-vlc {
background-color: #ffa000;
}
#mpd {
background-color: #66cc99;
color: #2a5c45;
}
#mpd.disconnected {
background-color: #f53c3c;
}
#mpd.stopped {
background-color: #90b1b1;
}
#mpd.paused {
background-color: #51a37a;
}
#language {
background: #00b093;
color: #740864;
padding: 0 5px;
margin: 0 5px;
min-width: 16px;
}
#keyboard-state {
background: #97e1ad;
color: #000000;
padding: 0 0px;
margin: 0 5px;
min-width: 16px;
}
#keyboard-state > label {
padding: 0 5px;
}
#keyboard-state > label.locked {
background: rgba(0, 0, 0, 0.2);
}
'';
waybarCssFile = pkgs.writeText "waybar.css" waybarStyleCss;
in
{
options.xyno.desktop.waybar.enable = lib.mkEnableOption "enable mako notification daemon";
options.xyno.desktop.waybar.wantedBy = lib.mkOption {
type = lib.types.str;
default = "niri.service";
};
options.xyno.desktop.waybar.package = lib.mkOption {
type = lib.types.package;
default = pkgs.unstable.waybar;
};
options.xyno.desktop.waybar.mode = lib.mkOption {
type = lib.types.str;
default = "niri";
};
config = lib.mkIf cfg.enable {
programs.waybar.enable = true;
programs.waybar.package = cfg.package.overrideAttrs (super: {
# version = super.version + "-patched";
patches = [
./waybar-wireplumber-db.patch
];
});
programs.light.enable = true;
systemd.user.services.waybar.wantedBy = lib.mkForce [ cfg.wantedBy ];
systemd.user.services.waybar.restartTriggers = [
waybarCfgFile
waybarCssFile
];
environment.etc."xdg/waybar/config".source = waybarCfgFile;
environment.etc."xdg/waybar/style.css".source = waybarCssFile;
};
}

View file

@ -0,0 +1,93 @@
{
pkgs,
config,
lib,
...
}:
with lib;
let
calwatcher =
(pkgs.writeShellApplication {
name = "calwatcher";
runtimeInputs = [
pkgs.inotify-tools
pkgs.khal
pkgs.jq
];
text = ''
# in parts ripped from https://git.sr.ht/~whynothugo/dotfiles/tree/3768ec57/item/home/.local/lib/waybar-khal
render() {
# Find events starting in two minutes.
# So if my current event ends in two minutes and another one starts, the
# widget is already updated with what's upcoming.
SINCE="$(date -d 'now +2 min' '+%FT%H:%M:%S')"
UNTIL="1d"
EVENT="$(
khal list "$SINCE" "$UNTIL" \
--day-format 'SKIPME' \
--format "{start-end-time-style} {title:.31}{repeat-symbol}" |
grep -v SKIPME | # filter out headers
grep -v -P '| |' | # filter out continuing all day events
grep -v '^ ' | # exclude full-day events
head -n 1 # show just the first
)"
if [ -z "$EVENT" ]; then
TEXT=" (nothing upcoming)"
CLASS="no-event"
else
TEXT=" $EVENT"
CLASS="event"
fi
jq --compact-output \
--null-input \
--arg text "$TEXT" \
--arg class "$CLASS" \
--arg tooltip "$(khal list today 7d --day-format '<span color="#ffead3"><b>{name} {date-long}</b></span>')" \
'{"text": $text, "class": $class, "tooltip": $tooltip}'
}
render # Render once for initial state.
# In order to make sure events are updated as time passes, this re-renderes
# every two minutes. That aside, whenever a calendar event changes, we alreays
# re-render immediately.
#
# It would be ideal to determine _when_ the current event ends, and set the
# timeout accordinly. That would require parsing khal's output a bit more.
while true; do
(inotifywait \
--event modify \
--event create \
--event delete \
--event close_write \
--event moved_to \
--event move \
--monitor \
--timeout 120 \
--recursive \
"$HOME/.calendars" 2> /dev/null) || true | \
while read -r _; do
render
timeout 3 cat || true # debounce for 3s, https://stackoverflow.com/a/69945839
done
done
'';
})
+ "/bin/calwatcher";
in
lib.mkIf (config.xyno.user-services.khal.enable) {
xyno.desktop.waybar.config = {
"custom/cal" = {
exec = calwatcher;
restart-interval = 5;
return-type = "json";
"on-click" = "${pkgs.foot}/bin/footclient --app-id floating-alacritty ${pkgs.khal}/bin/ikhal";
};
modules-right = mkOrder 1999 [ "custom/cal" ]; # left of clock, right of everything else
};
}

View file

@ -0,0 +1,250 @@
{
pkgs,
config,
lib,
...
}:
with lib;
let
cfg = config.xyno.desktop.waybar;
json = pkgs.formats.json { };
in
{
options.xyno.desktop.waybar.enable = mkEnableOption "enable mako notification daemon";
options.xyno.desktop.waybar.wantedBy = mkOption {
type = types.str;
default = "niri.service";
};
options.xyno.desktop.waybar.package = mkOption {
type = types.package;
default = pkgs.unstable.waybar;
};
options.xyno.desktop.waybar.config = mkOption {
type = json.type;
default = { modules-left = []; modules-right = []; };
};
options.xyno.desktop.waybar.style = mkOption {
type = types.lines;
default = "";
};
imports = [
./cal.nix
./kmonad.nix
./laptop.nix
./niri.nix
];
config = mkIf cfg.enable {
programs.waybar.enable = true;
programs.waybar.package = cfg.package.overrideAttrs (super: {
# version = super.version + "-patched";
patches = [
./waybar-wireplumber-db.patch
];
});
systemd.user.services.waybar.wantedBy = mkForce [ cfg.wantedBy ];
environment.etc."xdg/waybar/config".source = json.generate "waybar-config.json" cfg.config;
environment.etc."xdg/waybar/style.css".source = pkgs.writeText "waybar.css" cfg.style;
xyno.desktop.waybar.config = {
layer = "top";
position = "top";
height = 20;
modules-right = mkMerge [
(mkBefore [
"tray"
"idle_inhibitor"
"wireplumber"
])
(mkAfter [
"temperature"
"cpu"
"memory"
"disk"
"network"
])
(mkOrder 2000 [ "clock" ])
];
wireplumber = {
"format" = "{icon} {volume:.2f} dB";
"format-muted" = " -inf dB";
# "on-click" = "${pkgs.pwvucontrol}/bin/pwvucontrol";
"on-click" = "${pkgs.pavucontrol}/bin/pavucontrol";
"on-click-right" = "${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle";
"on-scroll-up" = "${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ -l 1 1%+";
"on-scroll-down" = "${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ -l 1 1%-";
"format-icons" = [
""
""
""
];
};
"idle_inhibitor" = {
format = "{icon} ";
format-icons = {
"activated" = "󰅶";
"deactivated" = "󰾪";
};
};
"cpu" = {
"interval" = 10;
"format" = " {:0.0f}%";
"max-length" = 10;
};
"temperature" = {
"format" = " {temperatureC}°C";
};
memory = {
interval = 30;
format = " {used:0.0f}/{total:0.0f}GB";
};
clock = {
interval = 1;
format = "{:%a %Y-%m-%dT%H:%M:%S%z}";
"tooltip-format" = "<tt><small>{calendar}</small></tt>";
"calendar" = {
"mode" = "year";
"mode-mon-col" = 3;
"weeks-pos" = "right";
"on-scroll" = 1;
"format" = {
"months" = "<span color='#ffead3'><b>{}</b></span>";
"days" = "<span color='#ecc6d9'><b>{}</b></span>";
"weeks" = "<span color='#99ffdd'><b>W{}</b></span>";
"weekdays" = "<span color='#ffcc66'><b>{}</b></span>";
"today" = "<span color='#ff6699'><b><u>{}</u></b></span>";
};
};
"actions" = {
"on-click-right" = "mode";
"on-scroll-up" = "shift_up";
"on-scroll-down" = "shift_down";
};
};
disk = {
format = "󰋊 {specific_used:0.1f}/{specific_total:0.1f}TB";
unit = "TB";
path = "/";
};
"network" = {
"on-click" = "${pkgs.foot}/bin/footclient --app-id floating-alacritty ${pkgs.impala}/bin/impala";
"format" = "{ifname}";
"format-wifi" = "󰖩 {essid}";
"format-ethernet" = "󰈀 {ifname}";
"format-disconnected" = "󰖪 ";
"tooltip-format" = "{ifname} via {gwaddr}\n{ipaddr}/{cidr}";
"tooltip-format-wifi" = "{essid} ({signaldBm} dBm) {frequency} GHz\n{ipaddr}/{cidr}";
"tooltip-format-ethernet" = "{ifname}\n{ipaddr}/{cidr}";
"tooltip-format-disconnected" = "Disconnected";
"max-length" = 50;
};
};
xyno.desktop.waybar.style = ''
* {
/* `otf-font-awesome` is required to be installed for icons */
font-family: "Source Sans 3";
font-size: 11px;
}
window#waybar {
color: #a89984;
background-color: #1d2021;
}
window#waybar.hidden {
opacity: 0.2;
}
/*
window#waybar.empty {
background-color: transparent;
}
window#waybar.solo {
background-color: #FFFFFF;
}
*/
/*window#waybar.termite {
background-color: #3F3F3F;
}
window#waybar.chromium {
background-color: #000000;
border: none;
}*/
#clock,
#battery,
#cpu,
#memory,
#disk,
#temperature,
#backlight,
#network,
#pulseaudio,
#tray,
#mode,
#idle_inhibitor,
#mpd {
padding: 0 2px;
background-color: #1d2021;
color: #ebdbb2;
}
label:focus {
background-color: #000000;
}
#temperature {
color: #fabd2f;
}
#temperature.critical {
background-color: #fbf1c7;
color: #b57614;
}
#memory {
color: #FCF434; /* enby yellow */
}
#disk {
color: #FFFFFF; /* enby white */
}
#network {
color: #b8bb26; /* enby green */
}
#clock {
color: #9C59D1; /* enby purple */
/*color: #2C2C2C; enby black */
}
#network.disconnected {
background-color: #fbf1c7;
color: #9d0006;
}
#wireplumber {
color: #fe8019;
}
#tray > .needs-attention {
background-color: #fbf1c7;
color: #3c3836;
}
#idle_inhibitor {
background-color: #1d2021;
color: #ebdbb2;
}
#idle_inhibitor.activated {
background-color: #fbf1c7;
color: #3c3836;
}
'';
};
}

View file

@ -0,0 +1,35 @@
{
pkgs,
config,
lib,
...
}:
with lib;
mkIf (config.xyno.hardware.kmonad.enable) {
xyno.desktop.waybar.config = {
"custom/kmonad" = {
exec =
(pkgs.writeShellApplication {
name = "kmonad-layer-watcher";
runtimeInputs = [ pkgs.inotify-tools ];
text = ''
cat /tmp/kmonad-layer;
while inotifywait -qq -e modify /tmp/kmonad-layer; do
cat /tmp/kmonad-layer;
done
'';
})
+ "/bin/kmonad-layer-watcher";
restart-interval = 5;
};
modules-left = mkBefore [ "custom/kmonad" ];
};
xyno.desktop.waybar.style = ''
#custom-kmonad {
color: #84929D;
margin-left: 4px;
border-bottom: 3px solid #fbf1c7;
}
'';
}

View file

@ -0,0 +1,87 @@
{
pkgs,
config,
lib,
...
}:
lib.mkIf (true) {
xyno.desktop.waybar.config = {
battery = {
"states" = {
"warning" = 30;
"critical" = 15;
};
"format" = "{icon} {capacity}%";
"format-icons" = [
""
""
""
""
""
];
"tooltip-format" = "Capacity: {capacity}%\nPower Draw: {power:0.2f}W\n{timeTo}\nCycles: {cycles}";
"max-length" = 25;
};
backlight = {
"device" = "amdgpu_bl1";
"format" = "{icon} {percent}%";
"format-icons" = [
"󰃚"
"󰃛"
"󰃜"
"󰃝"
"󰃞"
"󰃟"
"󰃠"
];
"on-scroll-up" = "${pkgs.light}/bin/light -A 5";
"on-scroll-down" = "${pkgs.light}/bin/light -U 5";
};
"power-profiles-daemon" = {
format = "{icon} ";
tooltip-format = "Power profile: {profile}\nDriver: {driver}";
tooltip = true;
format-icons = {
"default" = "";
"performance" = "";
"balanced" = "";
"power-saver" = "";
};
};
modules-right = [
"battery"
"power-profiles-daemon"
"backlight"
];
};
programs.light.enable = true;
xyno.desktop.waybar.style = ''
#battery {
color: #d3869b;
}
#battery.critical:not(.charging) {
background-color: #1d2021;
animation-name: blink;
animation-duration: 0.5s;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
@keyframes blink {
to {
background-color: #fbf1c7;
color: #df3f71;
}
}
#battery.critical:not(.charging) {
background-color: #1d2021;
}
#battery.charging, #battery.plugged {
color: #98971a;
}
#backlight {
color: #458588;
}
'';
}

View file

@ -0,0 +1,71 @@
{
pkgs,
config,
lib,
...
}:
with lib;
mkIf (config.xyno.desktop.niri.enable) {
xyno.desktop.waybar.config = {
"niri/window" = {
max-length = 80;
};
modules-left = [
"niri/workspaces"
"niri/window"
];
};
xyno.desktop.waybar.style = ''
#window,
#workspaces,
#tags {
margin: 0 2px;
}
/* If workspaces is the leftmost module, omit left margin */
.modules-left > widget:first-child > #workspaces {
margin-left: 0;
}
/* If workspaces is the rightmost module, omit right margin */
.modules-right > widget:last-child > #workspaces {
margin-right: 0;
}
#workspaces button {
padding: 0 2px;
background-color: #1d2021;
color: #ebdbb2;
/* Use box-shadow instead of border so the text isn't offset */
box-shadow: inset 0 -3px transparent;
/* Avoid rounded borders under each workspace name */
border: none;
border-radius: 0;
}
/* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */
#workspaces button:hover {
background: rgba(0, 0, 0, 0.2);
/* box-shadow: inset 0 -3px #fbf1c7;
*/
background-color: #3c3836;
}
#workspaces button.focused {
/* box-shadow: inset 0 -3px #fbf1c7;
*/
background-color: #3c3836;
color: #ebdbb2;
}
#workspaces button.occupied {
color: #d3869b;
}
#workspaces button.urgent {
background-color: #cc241d;
color: #ebdbb2;
}
'';
}