soundboard: improve volume sliders

This commit is contained in:
dogeystamp 2022-10-12 20:29:42 -04:00
parent a80882c27e
commit e55fa54410
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
3 changed files with 55 additions and 12 deletions

View File

@ -22,9 +22,11 @@ super + grave
ln -sr $SB_DIR $SB_DIR/cur;\
sb-ls.sh
# list current directory contents
# list currently playing + volume
KP_Enter
sb-ls.sh
find $SB_DIR/ -name "sb-socket*" | sb-vol
# list current directory contents
# super + shift + `
super + asciitilde
sb-ls.sh
@ -52,16 +54,28 @@ ctrl + shift + KP_{Insert,End,Down,Next,Left,Begin,Right,Home,Up,Prior}
ls $SB_DIR/cur/sb-socket$snd_id-* | sb-msg "set loop inf"
# reduce volume of current dir
ctrl + KP_Subtract
ctrl + shift + KP_Subtract
snd_id="{0-9}";\
ls $SB_DIR/cur/sb-socket* | sb-msg "add volume -5";\
sb-vol
ls $SB_DIR/cur/sb-socket* | sb-vol
# increase volume of current dir
ctrl + KP_Add
ctrl + shift + KP_Add
snd_id="{0-9}";\
ls $SB_DIR/cur/sb-socket* | sb-msg "add volume +5";\
sb-vol
ls $SB_DIR/cur/sb-socket* | sb-vol
# reduce volume of specific sound
ctrl + KP_Subtract; KP_{Insert,End,Down,Next,Left,Begin,Right,Home,Up,Prior}
snd_id="{0-9}";\
ls $SB_DIR/cur/sb-socket$snd_id-* | sb-msg "add volume -10";\
ls $SB_DIR/cur/sb-socket$snd_id-* | sb-vol
# increase volume of specific sound
ctrl + KP_Add; KP_{Insert,End,Down,Next,Left,Begin,Right,Home,Up,Prior}
snd_id="{0-9}";\
ls $SB_DIR/cur/sb-socket$snd_id-* | sb-msg "add volume +10";\
ls $SB_DIR/cur/sb-socket$snd_id-* | sb-vol
# stop all sounds
shift + KP_Delete

View File

@ -2,5 +2,5 @@
# Given a list of mpv sockets through stdin, send a message to all of them
while read -r socket; do
printf "$1\n" | socat - $socket
printf "$1\n" | socat - $socket | grep "{.*"
done

View File

@ -1,10 +1,39 @@
#!/bin/sh
# Get the highest volume in the current directory, and present it as a notification.
# Get volumes of mpv sockets piped through stdin
RES=$(ls $SB_DIR/cur/sb-socket* | \
sb-msg '{ "command": ["get_property", "volume"], "request_id": 100 }' |\
jq .data | sort | head -n 1 | awk '{ printf("%.0f\n", $0) }')
SOCKETS=""
while read x; do
SOCKETS=$(printf "%s\n%s" "$SOCKETS" "$x")
done
SOCKETS=$(printf %s "$SOCKETS" | sed "/^$/d")
VOLS=$(echo "$SOCKETS" |\
sb-msg '{ "command": ["get_property", "volume"], "request_id": 1336 }' |\
jq .data | awk '{ printf("%.0f\n", $0) }')
PATHS=$(echo "$SOCKETS" |\
sb-msg '{ "command": ["get_property", "path"], "request_id": 1337 }' |\
jq -r .data)
NAMES=""
for x in $PATHS; do
NAMES="$NAMES $(basename $x)"
done
CNT=$(echo $PATHS | wc -w)
if [ "$CNT" = 0 ]; then
exit
fi
CUR_DIR="$(basename $(readlink $SB_DIR/cur))"
notify-send -a "soundboard" -r 13371337 "$(printf "%s\nVolume set to %s\n" "$CUR_DIR" "$RES")"
zip () {
awk '{for(i=1; i<=NF/2; i++) {j=NF/2+i; printf "%s %s%\n",$i,$j;}}'
}
PROMPT=$(printf '%s\n%s' "$CUR_DIR" "$(echo "$NAMES" $VOLS | zip | column --table --output-width 20)")
notify-send \
-a "soundboard" \
-r 13371337 \
"$(printf "%s" "$PROMPT")"