fix(waybar): dont depend on pulseaudio

This commit is contained in:
Barrett Ruth 2026-02-14 17:30:53 -05:00
parent 136ac9fba0
commit ee1df8983a
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
4 changed files with 55 additions and 69 deletions

View file

@ -100,6 +100,50 @@ audio)
;;
esac
;;
brightness)
require brightnessctl notify-send
BRIGHT_STEP=5
case "$2" in
up) brightnessctl set "$BRIGHT_STEP"%+ ;;
down) brightnessctl set "$BRIGHT_STEP"%- ;;
*) echo "Usage: ctl brightness {up|down}" >&2; exit 1 ;;
esac
pct=$(awk -v cur="$(brightnessctl get)" -v max="$(brightnessctl max)" 'BEGIN { printf "%d", cur * 100 / max }')
filled=$((pct / 5))
empty=$((20 - filled))
bar=""
i=0; while [ "$i" -lt "$filled" ]; do bar="${bar}━"; i=$((i + 1)); done
i=0; while [ "$i" -lt "$empty" ]; do bar="${bar}─"; i=$((i + 1)); done
notify-send -a ctl -t 2500 -r 5555 "☼ $bar"
;;
volume)
require wpctl notify-send
SINK="@DEFAULT_AUDIO_SINK@"
VOL_STEP=5
get_vol() { wpctl get-volume "$SINK" | awk '{printf "%d", $2 * 100}'; }
case "$2" in
up) wpctl set-volume "$SINK" "${VOL_STEP}%+" --limit 1.0 ;;
down) wpctl set-volume "$SINK" "${VOL_STEP}%-" ;;
toggle) wpctl set-mute "$SINK" toggle ;;
*) echo "Usage: ctl volume {up|down|toggle}" >&2; exit 1 ;;
esac
vol=$(get_vol)
filled=$((vol / 5))
empty=$((20 - filled))
bar=""
i=0; while [ "$i" -lt "$filled" ]; do bar="${bar}━"; i=$((i + 1)); done
i=0; while [ "$i" -lt "$empty" ]; do bar="${bar}─"; i=$((i + 1)); done
if wpctl get-volume "$SINK" | grep -q MUTED; then
icon="󰖁"
elif [ "$vol" -le 33 ]; then
icon="󰕿"
elif [ "$vol" -le 66 ]; then
icon="󰖀"
else
icon="󰕾"
fi
notify-send -a ctl -t 2500 -r 5556 "$icon $bar"
;;
power)
require fuzzel
lock="󰌾 Lock"
@ -117,7 +161,7 @@ power)
esac
;;
*)
echo "Usage: ctl {screenshot|ocr|keyboard|audio|power}" >&2
echo "Usage: ctl {screenshot|ocr|keyboard|audio|brightness|volume|power}" >&2
exit 1
;;
esac

View file

@ -14,8 +14,6 @@ usage() {
Usage: hypr <subcommand> [app] [args...]
Commands:
volume {up,down,toggle} Adjust volume accordingly and notify
brightness {up,down} Adjust brightness accordingly and notify
spawnfocus <app> [args...] Focus existing window or spawn app with args
pull [app] Pull window to current workspace (picker if no app)
windowrules Apply dynamic window rules
@ -46,61 +44,6 @@ exit)
hyprctl dispatch exit
exit 0
;;
brightness)
require brightnessctl notify-send
BRIGHT_STEP=5
case "$1" in
up) brightnessctl set "$BRIGHT_STEP"%+ ;;
down) brightnessctl set "$BRIGHT_STEP"%- ;;
*) echo "Invalid subcommand: $1" >&2; exit 1 ;;
esac
pct=$(awk -v cur="$(brightnessctl get)" -v max="$(brightnessctl max)" 'BEGIN { printf "%d", cur * 100 / max }')
filled=$((pct / 5))
empty=$((20 - filled))
bar=""
i=0; while [ "$i" -lt "$filled" ]; do bar="${bar}━"; i=$((i + 1)); done
i=0; while [ "$i" -lt "$empty" ]; do bar="${bar}─"; i=$((i + 1)); done
notify-send -a hypr -t 2500 -r 5555 "☼ $bar"
;;
volume)
require wpctl notify-send
SINK="@DEFAULT_AUDIO_SINK@"
VOL_STEP=5
get_vol() { wpctl get-volume "$SINK" | awk '{printf "%d", $2 * 100}'; }
case "$1" in
up)
wpctl set-volume "$SINK" "${VOL_STEP}%+" --limit 1.0
;;
down)
wpctl set-volume "$SINK" "${VOL_STEP}%-"
;;
toggle)
wpctl set-mute "$SINK" toggle
;;
*)
echo "Invalid subcommand: $1" >&2
exit 1
;;
esac
vol=$(get_vol)
filled=$((vol / 5))
empty=$((20 - filled))
bar=""
i=0; while [ "$i" -lt "$filled" ]; do bar="${bar}━"; i=$((i + 1)); done
i=0; while [ "$i" -lt "$empty" ]; do bar="${bar}─"; i=$((i + 1)); done
if wpctl get-volume "$SINK" | grep -q MUTED; then
icon="󰖁"
elif [ "$vol" -le 33 ]; then
icon="󰕿"
elif [ "$vol" -le 66 ]; then
icon="󰖀"
else
icon="󰕾"
fi
notify-send -a hypr -t 2500 -r 5556 "$icon $bar"
;;
pull)
require hyprctl jq fuzzel
APP="$1"