···
-
{ config, lib, pkgs, ... }:
-
# the fonts that will be included with the waybar package
-
fontPackages = [ pkgs.ubuntu_font_family pkgs.material-design-icons ];
-
package' = let super = package;
-
inherit (super) name pname version meta;
-
paths = [ super ] ++ fontPackages;
-
compileSCSS = name: source:
-
pkgs.runCommandLocal name { } ''
-
${lib.getExe pkgs.sassc} -t expanded '${source}' > $out/${name}.css
-
# TODO when using store paths to executables, they do not inherit the user's
-
# environment (at least with systemd) and therefore GUIs use the default theme
-
slight = "${lib.getExe pkgs.slight}";
-
hyprctl = "${config.wayland.windowManager.hyprland.package}/bin/hyprctl";
-
# TODO this is duplicated from the hyprland config, make it a module
-
kbFns = lib.getExe config.utilities.osd-functions.package;
-
pavucontrol = lib.getExe pkgs.lxqt.pavucontrol-qt;
-
blueman-manager = "${pkgs.blueman}/bin/blueman-manager";
-
bluetoothctl = "${pkgs.bluez}/bin/bluetoothctl";
-
systemctl = "${pkgs.systemd}/bin/systemctl";
-
iwgtk = lib.getExe pkgs.iwgtk;
-
backlightUp = "${slight} inc 5% -t 150ms";
-
backlightDown = "${slight} dec 5% -t 150ms";
-
# TODO --tab no longer works, what is the identifier to use?
-
outputSoundSettings = "${pavucontrol} --tab 'Output Devices'";
-
outputVolumeMute = "${kbFns} output mute";
-
outputVolumeUp = "${kbFns} output +0.05";
-
outputVolumeDown = "${kbFns} output -0.05";
-
# TODO --tab no longer works, what is the identifier to use?
-
inputSoundSettings = "${pavucontrol} --tab 'Input Devices'";
-
inputVolumeMute = "${kbFns} input mute";
-
# inputVolumeUp = "${kbFns} input +0.05";
-
# inputVolumeDown = "${kbFns} input -0.05";
-
bluetoothSettings = (pkgs.writeShellScript "waybar-bluetooth-settings" ''
-
(with pkgs; [ coreutils gawk util-linux bluez nettools blueman ])
-
awk '/Name: '"$(hostname)"'$/{p=1} p && /Powered: yes/{print "true"; exit} END{if(!NR || !p) print "false"}'
-
if [[ $is_powered_on == 'true' ]]; then
-
rfkill unblock bluetooth && sleep 1 || true
-
bluetoothToggle = (pkgs.writeShellScript "waybar-bluetooth-toggle" ''
-
(with pkgs; [ coreutils gawk util-linux bluez nettools ])
-
awk '/Name: '"$(hostname)"'$/{p=1} p && /Powered: yes/{print "true"; exit} END{if(!NR || !p) print "false"}'
-
if [[ $is_powered_on == 'true' ]]; then
-
rfkill unblock bluetooth && sleep 1 || true
-
"rfkill block bluetooth && ${systemctl} restart bluetooth.service";
-
bluetoothOff = "${bluetoothctl} power off";
-
wirelessSettings = iwgtk;
-
workspaceSwitchPrev = "${hyprctl} dispatch workspace m-1";
-
workspaceSwitchNext = "${hyprctl} dispatch workspace m+1";
-
programs.waybar.enable = true;
-
programs.waybar.package = package';
-
programs.waybar.systemd.enable = true;
-
programs.waybar.style =
-
builtins.readFile (compileSCSS "waybar-style" ./waybar.scss);
-
programs.waybar.settings = {
-
# Causes tooltips to be shown behind windows.
-
# Hyprland dropped support unfortunately.
-
# sort-by-number = true;
-
# on-click = "activate";
-
# on-scroll-up = commands.workspaceSwitchPrev;
-
# on-scroll-down = commands.workspaceSwitchNext;
-
"hyprland/workspaces" = {
-
# sort-by-number = true;
-
# on-click = "activate";
-
on-scroll-up = commands.workspaceSwitchPrev;
-
on-scroll-down = commands.workspaceSwitchNext;
-
show-passive-items = true;
-
format = "{status_icon} {dynamic}";
-
dynamic-separator = " — ";
-
dynamic-order = [ "title" "artist" "position" "length" ];
-
dynamic-importance = [ "position" "title" "artist" ];
-
tooltip-format = lib.trim ''
-
<b>Player:</b> {player} ({status})
-
<b>Artist:</b> {artist}
-
<b>Length:</b> {position}/{length}
-
"hyprland/window" = { max-length = 50; };
-
"clock#time" = { format = "{:%I:%M %p}"; };
-
"clock#date" = { format = "{:%A, %B %d}"; };
-
"pulseaudio#output" = {
-
format = "{icon} {volume}%";
-
format-muted = " {volume}%";
-
default = [ "" "" "" ];
-
# anything below 100% is "safe" volume levels,
-
# the default style will be used,
-
# anything higher than this will have no CSS class,
-
# that will be considered "warning" state
-
# `#pulseaudio.output:not(.safe)`
-
states = { safe = 100; };
-
ignored-sinks = [ "Easy Effects Sink" ];
-
on-click = commands.outputSoundSettings;
-
on-click-right = commands.outputVolumeMute;
-
on-scroll-up = commands.outputVolumeUp;
-
on-scroll-down = commands.outputVolumeDown;
-
format = "{format_source}";
-
# format-source = " {volume}%";
-
# format-source-muted = " {volume}%";
-
format-source-muted = "";
-
on-click = commands.inputSoundSettings;
-
on-click-right = commands.inputVolumeMute;
-
# on-scroll-up = commands.inputVolumeUp;
-
# on-scroll-down = commands.inputVolumeDown;
-
format = "{icon} {percent}%";
-
# format-icons = ["" "" "" "" ""];
-
format-icons = [ "" "" "" "" "" "" "" "" "" "" ];
-
on-scroll-up = commands.backlightUp;
-
on-scroll-down = commands.backlightDown;
-
format = " {used:.2g}/{total:.2g}GiB";
-
hwmon-path-abs = "/sys/devices/pci0000:00/0000:00:18.3/hwmon";
-
input-filename = "temp1_input";
-
90; # 15C lower than Tjmax <https://www.amd.com/en/product/9686>
-
format = "{icon} {temperatureC}°C";
-
format-critical = " {temperatureC}°C";
-
# 4x low, 2x mid, 3x high, for 0-90
-
format-icons = [ "" "" "" "" "" "" "" "" "" ];
-
<b>Address:</b> {ipaddr}
-
<b>Netmask:</b> {netmask}
-
<b>Gateway:</b> {gwaddr}
-
<b>Speeds:</b> {bandwidthUpBytes} UL, {bandwidthDownBytes} DL
-
format-ethernet = " {bandwidthDownBytes}";
-
format-wifi = "{icon} {bandwidthDownBytes}";
-
format-linked = " {bandwidthDownBytes}";
-
format-disconnected = "";
-
format-icons = [ "" "" "" "" ];
-
tooltip-format = lib.trim ''
-
<b>Interface</b>: {ifname}
-
tooltip-format-wifi = lib.trim ''
-
<b>Strength:</b> {signaldBm} dBmW ({signalStrength}%)
-
<b>Frequency:</b> {frequency} GHz
-
tooltip-format-disconnected = "Network disconnected.";
-
on-click = commands.wirelessSettings;
-
controller = "C0:3C:59:02:25:C3";
-
format-connected = " {num_connections}";
-
format-connected-battery =
-
" {device_alias} ({device_battery_percentage}%) ({num_connections})";
-
on-click = commands.bluetoothSettings;
-
on-click-middle = commands.bluetoothKill;
-
on-click-right = commands.bluetoothToggle;
-
format = "{icon} {capacity}%";
-
format-icons = [ "" "" "" "" "" "" "" "" "" "" ];
-
# <https://github.com/Alexays/Waybar/issues/1938>
-
# the wiki lies about this, does not match
-
# /sys/class/power_supply/BAT0/status
-
format-plugged = " AC";
-
format-charging-battery-10 = " {capacity}%";
-
format-charging-battery-20 = " {capacity}%";
-
format-charging-battery-30 = " {capacity}%";
-
format-charging-battery-40 = " {capacity}%";
-
format-charging-battery-50 = " {capacity}%";
-
format-charging-battery-60 = " {capacity}%";
-
format-charging-battery-70 = " {capacity}%";
-
format-charging-battery-80 = " {capacity}%";
-
format-charging-battery-90 = " {capacity}%";
-
format-charging-battery-100 = " {capacity}%";
-
tooltip-format-activated =
-
"Idle timer inhibited, device will not sleep.";
-
tooltip-format-deactivated =
-
"Idle timer enabled, device will sleep when not in use.";
-
(lib.mkIf config.programs.waybar.systemd.enable {
-
xdg.configFile."waybar/config".onChange = lib.mkOverride 90 ''
-
if [ -z "''${_reloaded_waybar-}" ]; then
-
${pkgs.systemd}/bin/systemctl --user restart waybar.service
-
xdg.configFile."waybar/style.css".onChange = lib.mkOverride 90 ''
-
if [ -z "''${_reloaded_waybar-}" ]; then
-
${pkgs.systemd}/bin/systemctl --user restart waybar.service