feat: add wob overlay for volume and brightness keys

Move FIFO setup and percentage emission into helper scripts so the
Hyprland config has no raw $VAR references — Hyprland's parser
substitutes $varname at parse time, which mangled awk's $2 and
$HYPRLAND_INSTANCE_SIGNATURE and left binds broken after reload.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jeena 2026-05-14 12:03:43 +00:00
parent c351285963
commit 7b99932299
5 changed files with 51 additions and 4 deletions

17
hypr/scripts/wob-brightness.sh Executable file
View file

@ -0,0 +1,17 @@
#!/usr/bin/env bash
# Adjust backlight and emit current percentage to the wob overlay FIFO.
# Usage: wob-brightness.sh up|down
set -u
case "${1:-}" in
up) brightnessctl -e4 -n2 set 5%+ >/dev/null ;;
down) brightnessctl -e4 -n2 set 5%- >/dev/null ;;
*) echo "usage: $0 up|down" >&2; exit 2 ;;
esac
fifo="${XDG_RUNTIME_DIR:-/tmp}/hypr-wob.${HYPRLAND_INSTANCE_SIGNATURE:-default}"
[[ -p "$fifo" ]] || exit 0
current=$(brightnessctl get)
max=$(brightnessctl max)
awk -v c="$current" -v m="$max" 'BEGIN { printf "%d\n", (c/m)*100 }' > "$fifo"

14
hypr/scripts/wob-daemon.sh Executable file
View file

@ -0,0 +1,14 @@
#!/usr/bin/env bash
# Run by Hyprland exec-once. Creates a per-instance FIFO and pipes it to wob
# so volume/brightness binds can show an on-screen overlay.
set -u
command -v wob >/dev/null 2>&1 || exit 0
fifo="${XDG_RUNTIME_DIR:-/tmp}/hypr-wob.${HYPRLAND_INSTANCE_SIGNATURE:-default}"
rm -f "$fifo"
mkfifo "$fifo"
trap 'rm -f "$fifo"' EXIT
tail -f "$fifo" | wob

15
hypr/scripts/wob-volume.sh Executable file
View file

@ -0,0 +1,15 @@
#!/usr/bin/env bash
# Adjust volume and emit current percentage to the wob overlay FIFO.
# Usage: wob-volume.sh up|down
set -u
case "${1:-}" in
up) wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+ ;;
down) wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- ;;
*) echo "usage: $0 up|down" >&2; exit 2 ;;
esac
fifo="${XDG_RUNTIME_DIR:-/tmp}/hypr-wob.${HYPRLAND_INSTANCE_SIGNATURE:-default}"
[[ -p "$fifo" ]] || exit 0
wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{printf "%d\n", $2*100}' > "$fifo"