From cabf188ae487120d4b9ac1fe21fff45403a787b4 Mon Sep 17 00:00:00 2001 From: Ryan Schanzenbacher Date: Mon, 24 Aug 2026 01:09:49 -0400 Subject: various fixes to guix --- users/ryan/linux/waybar/config | 112 ++++++++++++++++++++--------- users/ryan/linux/waybar/modules/storage.sh | 77 +++++++++++++++----- users/ryan/linux/waybar/style.css | 2 +- 3 files changed, 140 insertions(+), 51 deletions(-) (limited to 'users/ryan/linux/waybar') diff --git a/users/ryan/linux/waybar/config b/users/ryan/linux/waybar/config index 62e6b20..4459ce7 100644 --- a/users/ryan/linux/waybar/config +++ b/users/ryan/linux/waybar/config @@ -5,50 +5,69 @@ "modules-left": ["hyprland/workspaces", "hyprland/submap"], "modules-center": ["hyprland/window"], - "modules-right": ["tray", "custom/spotify", "privacy", "custom/weather", "custom/mail", "custom/storage", "backlight", "bluetooth", "pulseaudio", "network", "idle_inhibitor", "battery", "battery#num2", "clock"], + "modules-right": ["tray", "privacy", "custom/weather", "custom/mail", "custom/storage", "backlight", "bluetooth", "pulseaudio", "network", "idle_inhibitor", "battery", "battery#num2", "clock"], + "hyprland/submap": { "format": " {}" }, + "hyprland/workspaces": { "format": "{id}", "all-outputs": false, "disable-scroll": true }, + "hyprland/window": { "max-length": 80, "tooltip": false, "separate-outputs": true }, + "clock": { "format": "{:%a %d %b %H:%M}", "tooltip": false }, + "battery": { "format": "{capacity}% {icon}", "format-alt": "{time} {icon}", - "format-icons": ["", "", "", "", ""], - "format-charging": "{capacity}% ", + "format-icons": [ + "󰁺", + "󰁻", + "󰁼", + "󰁽", + "󰁹" + ], + "format-charging": "{capacity}% 󰂄", "interval": 30, "states": { "warning": 25, "critical": 10 }, "tooltip": false, - "bat":"BAT0" + "bat": "BAT0" }, + "battery#num2": { "format": "{capacity}% {icon}", "format-alt": "{time} {icon}", - "format-icons": ["", "", "", "", ""], - "format-charging": "{capacity}% ", + "format-icons": [ + "󰁺", + "󰁻", + "󰁼", + "󰁽", + "󰁹" + ], + "format-charging": "{capacity}% 󰂄", "interval": 30, "states": { "warning": 25, "critical": 10 }, "tooltip": false, - "bat":"BAT1" + "bat": "BAT1" }, + "bluetooth": { "format": "󰂯", "format-disabled": "󰂲", @@ -56,60 +75,75 @@ "format-connected-battery": "󰂱 {device_battery_percentage}%", "on-click": "foot bluetui", "tooltip-format": "{controller_alias}\t{controller_address}\n\n{num_connections} connected", - "tooltip-format-connected": "{controller_alias}\t{controller_address}\n\n{num_connections} connected\n\n{device_enumerate}", - "tooltip-format-enumerate-connected": "{device_alias}\t{device_address}", - "tooltip-format-enumerate-connected-battery": "{device_alias}\t{device_address}\t{device_battery_percentage}%" + "tooltip-format-connected": "{controller_alias}\t{controller_address}\n\n{num_connections} connected\n\n{device_enumerate}", + "tooltip-format-enumerate-connected": "{device_alias}\t{device_address}", + "tooltip-format-enumerate-connected-battery": "{device_alias}\t{device_address}\t{device_battery_percentage}%" }, + "network": { "format-alt": "{ipaddr}/{cidr} {icon} {bandwidthTotalBytes}󰹹", "format": "{ipaddr}/{cidr} {icon}", "format-alt-click": "click-right", "format-icons": { - "wifi": ["󰤟", "󰤢" ,"󰤥", "󰤨"], - "ethernet": [""], - "disconnected": ["󰤭"] + "wifi": [ + "󰤟", + "󰤢", + "󰤥", + "󰤨" + ], + "ethernet": [ + "󰈀" + ], + "disconnected": [ + "󰤭" + ] }, "on-click": "foot -t alacritty doas nmtui", "tooltip": false }, + "privacy": { - "icon-spacing":4, - "icon-size":18, - "transition-duration":250, + "icon-spacing": 4, + "icon-size": 18, + "transition-duration": 250, "modules": [ { - "type":"screenshare", - "tooltip":true, - "tooltip-icon-size":24 + "type": "screenshare", + "tooltip": true, + "tooltip-icon-size": 24 }, { - "type":"audio-in", - "tooltip":true, - "tooltip-icon-size":24 + "type": "audio-in", + "tooltip": true, + "tooltip-icon-size": 24 } ] }, + "pulseaudio": { "format-alt": "{icon}", "format": "{volume} {icon}", "format-alt-click": "click-right", "format-muted": "", "format-icons": { - "phone": [" ", " ", " ", " "], - "default": ["", "", "", ""] + "phone": [ + " ", + " ", + " ", + " " + ], + "default": [ + "", + "", + "", + "" + ] }, "scroll-step": 1, "on-click": "pavucontrol", "tooltip": false }, - "custom/spotify": { - "interval": 2, - "return-type": "json", - "exec": "~/.config/waybar/modules/spotify.sh", - "exec-if": "~/.config/waybar/modules/check-for-music.sh", - "escape": true, - "on-click": "playerctl play-pause" - }, + "custom/storage": { "format-alt": "{} ", "format": "{percentage}% ", @@ -118,14 +152,19 @@ "interval": 60, "exec": "~/.config/waybar/modules/storage.sh" }, + "backlight": { "format-alt": "{icon}", "format": "{percent}% {icon}", "format-alt-click": "click-right", - "format-icons": ["", ""], + "format-icons": [ + "", + "󰃞" + ], "on-scroll-up": "light -A 1", "on-scroll-down": "light -U 1" }, + "custom/weather_OLD": { "format-alt": "{}", "format": "{alt}: {}", @@ -136,14 +175,16 @@ "exec": "~/.config/waybar/modules/weather.sh", "exec-if": "ping wttr.in -c1" }, + "custom/weather": { "format": "{} °F", "tooltip": true, "interval": 3600, - "exec": "exit=101; while [ $exit = 101 ]; do wttrbar --main-indicator temp_F --fahrenheit; exit=$(echo $?); sleep 1; done", + "exec": "exit=101; while [ $exit = 101 ]; do wttrbar --main-indicator temp_F --fahrenheit --nerd; exit=$(echo $?); sleep 1; done", "on-click": "foot -a ala-wttr -H curl https://v2.wttr.in", "return-type": "json" }, + "idle_inhibitor": { "format": "{icon}", "format-icons": { @@ -152,6 +193,7 @@ }, "tooltip": false }, + "custom/mail": { "format": "", "format-alt": "{alt} ", @@ -161,7 +203,9 @@ "exec": "~/.config/waybar/modules/mail.py", "tooltip": false }, + "tray": { "icon-size": 18 } } + diff --git a/users/ryan/linux/waybar/modules/storage.sh b/users/ryan/linux/waybar/modules/storage.sh index 90cc3dc..7cb7249 100755 --- a/users/ryan/linux/waybar/modules/storage.sh +++ b/users/ryan/linux/waybar/modules/storage.sh @@ -1,25 +1,70 @@ #!/bin/sh -mount="/" +set -eu + +mountpoint="/" warning=20 critical=10 -df -h -P -l "$mount" | awk -v warning=$warning -v critical=$critical ' -/\/.*/ { - text=$4 - tooltip="Filesystem: "$1"\rSize: "$2"\rUsed: "$3"\rAvail: "$4"\rUse%: "$5"\rMounted on: "$6 - use=$5 - exit 0 +error() { + jq -cn --arg message "$1" '{ + text: "N/A", + percentage: 0, + tooltip: $message, + class: "critical" + }' + exit 0 } -END { - class="" - gsub(/%$/,"",use) - if ((100 - use) < critical) { + +line=$(df -hP -l "$mountpoint" 2>/dev/null | tail -n 1) || + error "Unable to read filesystem statistics" + +# df -P guarantees a single line per filesystem. +set -- $line + +[ "$#" -ge 6 ] || error "Unable to parse filesystem statistics" + +filesystem=$1 +size=$2 +used=$3 +available=$4 +use=${5%\%} +mounted=$6 + +case "$use" in + ''|*[!0-9]*) error "Invalid filesystem usage percentage: $use%" ;; +esac + +free=$((100 - use)) + +if [ "$free" -le "$critical" ]; then class="critical" - } else if ((100 - use) < warning) { +elif [ "$free" -le "$warning" ]; then class="warning" - } - print "{\"text\":\""text"\", \"percentage\":"use",\"tooltip\":\""tooltip"\", \"class\":\""class"\"}" -} -' +else + class="" +fi + +jq -cn \ + --arg text "${use}%" \ + --argjson percentage "$use" \ + --arg filesystem "$filesystem" \ + --arg size "$size" \ + --arg used "$used" \ + --arg available "$available" \ + --arg mounted "$mounted" \ + --arg class "$class" \ + '{ + text: $text, + percentage: $percentage, + tooltip: ( + "Filesystem: " + $filesystem + + "\rSize: " + $size + + "\rUsed: " + $used + + "\rAvail: " + $available + + "\rUse%: " + $text + + "\rMounted on: " + $mounted + ), + class: $class + }' diff --git a/users/ryan/linux/waybar/style.css b/users/ryan/linux/waybar/style.css index 682a14e..ac78984 100644 --- a/users/ryan/linux/waybar/style.css +++ b/users/ryan/linux/waybar/style.css @@ -1,7 +1,7 @@ * { border: none; border-radius: 0; - font-family: AnonymicePro Nerd Font; + font-family: FiraCode Nerd Font; font-size: 15px; box-shadow: none; text-shadow: none; -- cgit v1.3.1