From a80882c27e21eee6f11557bf5c541ff9afb4d30f Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Sat, 8 Oct 2022 15:08:31 -0400 Subject: [PATCH] soundboard: add volume control --- src/.config/sxhkd/sxhkdrc | 17 +++++++++++++++++ src/.local/bin/deskutils/soundboard/sb-msg | 1 - src/.local/bin/deskutils/soundboard/sb-vol | 10 ++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100755 src/.local/bin/deskutils/soundboard/sb-vol diff --git a/src/.config/sxhkd/sxhkdrc b/src/.config/sxhkd/sxhkdrc index 2ea94c7..619b3d0 100644 --- a/src/.config/sxhkd/sxhkdrc +++ b/src/.config/sxhkd/sxhkdrc @@ -46,6 +46,23 @@ shift + 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 "stop" +# loop specific sound +ctrl + shift + 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 "set loop inf" + +# reduce volume of current dir +ctrl + KP_Subtract + snd_id="{0-9}";\ + ls $SB_DIR/cur/sb-socket* | sb-msg "add volume -5";\ + sb-vol + +# increase volume of current dir +ctrl + KP_Add + snd_id="{0-9}";\ + ls $SB_DIR/cur/sb-socket* | sb-msg "add volume +5";\ + sb-vol + # stop all sounds shift + KP_Delete find $SB_DIR/ -name "sb-socket*" | sb-msg "stop";\ diff --git a/src/.local/bin/deskutils/soundboard/sb-msg b/src/.local/bin/deskutils/soundboard/sb-msg index cd6f51e..961206e 100755 --- a/src/.local/bin/deskutils/soundboard/sb-msg +++ b/src/.local/bin/deskutils/soundboard/sb-msg @@ -3,5 +3,4 @@ while read -r socket; do printf "$1\n" | socat - $socket - rm "$socket" done diff --git a/src/.local/bin/deskutils/soundboard/sb-vol b/src/.local/bin/deskutils/soundboard/sb-vol new file mode 100755 index 0000000..e7d41c9 --- /dev/null +++ b/src/.local/bin/deskutils/soundboard/sb-vol @@ -0,0 +1,10 @@ +#!/bin/sh +# Get the highest volume in the current directory, and present it as a notification. + +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) }') + +CUR_DIR="$(basename $(readlink $SB_DIR/cur))" + +notify-send -a "soundboard" -r 13371337 "$(printf "%s\nVolume set to %s\n" "$CUR_DIR" "$RES")"