fix(waybar): dont depend on pulseaudio
This commit is contained in:
parent
136ac9fba0
commit
ee1df8983a
4 changed files with 55 additions and 69 deletions
46
scripts/ctl
46
scripts/ctl
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue