feat: optimized sbar, gammastep asia, wpdef

This commit is contained in:
ange 2025-04-30 02:41:45 +00:00
parent f48e958d44
commit 395119a0fe
Signed by: ange
GPG key ID: 9E0C4157BB7BEB1D
19 changed files with 159 additions and 157 deletions

View file

@ -3,50 +3,43 @@
case "$1" in
s)
DEV='@DEFAULT_AUDIO_SINK@'
SIG=34
;;
m)
DEV='@DEFAULT_AUDIO_SOURCE@'
SIG=35
;;
*)
exit 1
;;
esac
shift
function update_vol() {
case "$1" in
+*|-*)
# shellcheck disable=SC2017
CUR=$((CUR + $1 - CUR % $1 + CUR % $1 * 10 / $1 / 5 * $1))
if [ "$CUR" -lt 0 ]; then
CUR=0
elif [ "$CUR" -gt 300 ]; then
CUR=300
fi
;;
*)
CUR="$1"
esac
wpctl set-volume "$DEV" "$CUR%"
wpctl set-volume -l 3 "$DEV" "$CUR%"
}
read -r _ CUR MUTE < <(wpctl get-volume "$DEV")
CUR=$((10#${CUR/./}))
if [ -z "$1" ]; then
if [ -z "$2" ]; then
echo "$CUR"
exit
elif [ "$1" == 'm' ] && [ -z "$MUTE" ]; then
fi
if [ "$2" == 'm' ] && [ -z "$MUTE" ]; then
wpctl set-mute "$DEV" 1
else
if [[ "$1" =~ [0-9] ]]; then
update_vol "$1"
if [[ "$2" =~ [0-9] ]]; then
update_vol "$2"
fi
if [ -n "$MUTE" ]; then
wpctl set-mute "$DEV" 0
fi
fi
kill "-$SIG" "$(cat "$XDG_CACHE_HOME/sbar/pid")"
kill -34 "$(cat "$XDG_RUNTIME_DIR/sbar/pid")"