{ config, lib, pkgs, ... }: let # waybar-systemd = pkgs.writeShellApplication { # name = "waybar-systemd.sh"; # runtimeInputs = [ ]; # text = '' # failed_user="$(systemctl --plain --no-legend --user list-units --state=failed | awk '{ print $1 }')" # failed_system="$(systemctl --plain --no-legend list-units --state=failed | awk '{ print $1 }')" # failed_systemd_count="$(echo -n "$failed_system" | grep -c '^')" # failed_user_count="$(echo -n "$failed_user" | grep -c '^')" # text=$(( failed_systemd_count + failed_user_count )) # if [ "$text" -eq 0 ]; then # printf '{"text": ""}\n' # else # tooltip="" # [ -n "$failed_system" ] && tooltip="Failed system services:\n\n${failed_system}\n\n${tooltip}" # [ -n "$failed_user" ] && tooltip="Failed user services:\n\n${failed_user}\n\n${tooltip}" # tooltip="$(printf "%s" "$tooltip" | perl -pe 's/\n/\\n/g' | perl -pe 's/(?:\\n)+$//')" # printf '{"text": "%s", "tooltip": "%s" }\n' "$text" "$tooltip" # fi # ''; # }; in { programs.waybar = { enable = true; systemd.enable = true; settings = [{ layer = "bottom"; height = 25; position = "top"; margin-top = 0; margin-left = 0; margin-right = 0; margin-bottom = 0; modules-left = [ "sway/workspaces" "sway/mode" ]; modules-right = [ "pulseaudio" "network" "battery" "clock" "tray" ]; "sway/workspaces" = { format = "{name}"; disable-scroll = true; }; "sway/mode" = { format = "{}"; }; tray = { spacing = 10; }; clock = { format = "{: %a %b %d %R}"; }; battery = { states = { warning = 30; critical = 15; }; format = "ac:{capacity}%"; tooltip = true; tooltip-format = "{timeTo} ({capacity}%)"; }; # "custom/systemd" = { # exec = "${waybarSystemd}/bin/waybar-systemd"; # return-type = "json"; # interval = 10; # }; pulseaudio = { format = "vol:{volume}%"; format-bluetooth = "bt:{volume}%"; format-bluetooth-muted = "bt:{volume}%"; format-muted = "vol:{volume}%"; on-click = "pavucontrol"; }; "network" = { format-wifi = "{essid}:{signalStrength}%"; format-ethernet = "{ipaddr}/{cidr}"; format-linked = "{ifname} (No IP)"; format-disconnected = "network unavailable"; format-alt = "{ifname}: {ipaddr}/{cidr}"; tooltip = false; }; }]; }; programs.waybar.style = pkgs.writeText "style.css" '' * { border-radius: 0; border: none; font-family: Source Code Pro; font-size: 15px; color: #C5C8C6; min-height: 24px; } window#waybar { background-color: #282A2E; color: #C5C8C6; } #window { font-weight: bold; font-family: Source Code Pro; } #workspaces button { padding: 0 5px; background-color: transparent; color: #C5C8C6; } #workspaces button.focused { background-color: #373B41; border-bottom: 2px solid #F0C674; } #clock, #battery, #network, #pulseaudio, #tray, #mode { padding: 0 6px; margin: 0 3px; } #battery.discharging { color: #f0c674; } #battery.warning { border-bottom: 2px solid #efc673; } #battery.critical { border-bottom: 2px solid #ef8773; } #network { /* No styles */ } #network.disconnected { color: #efc673; } #pulseaudio { /* No styles */ } #pulseaudio.muted { color: #8c8f91; } ''; }