From a17b721bbbf6760251ed5dda3f27d76fe667e877 Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Fri, 7 Oct 2022 20:46:01 -0400 Subject: [PATCH] soundboard: use hierarchy for directories --- src/.config/sxhkd/sxhkdrc | 32 +++++++++++++++++++++++--------- src/.local/bin/bk.sh | 1 + 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/.config/sxhkd/sxhkdrc b/src/.config/sxhkd/sxhkdrc index c58cce1..6c99eed 100644 --- a/src/.config/sxhkd/sxhkdrc +++ b/src/.config/sxhkd/sxhkdrc @@ -1,14 +1,31 @@ -# Soundboard setup -# "Boxes" labelled 0-9 in $SB_DIR/ -# Each one has files/symlinks 0-9 +# Soundboard + +# Directory tree under $SB_DIR +# Play sounds in current dir using numpad 0-9 keys +# Navigate to a dir under current one with super + 0-9 +# Navigate back to root with super + minus + # change dir super + {0-9} + if [ ! -h $SB_DIR/cur ]; then \ + ln -sr $SB_DIR $SB_DIR/cur;\ + fi;\ + ln -sr $SB_DIR/$(readlink $SB_DIR/cur)/{0-9}* $SB_DIR/cur_n;\ unlink $SB_DIR/cur;\ - ln -sr $SB_DIR/{0-9} $SB_DIR/cur + mv $SB_DIR/cur_n $SB_DIR/cur + +# set current directory to $SB_DIR +super + minus + unlink $SB_DIR/cur;\ + ln -sr $SB_DIR $SB_DIR/cur # start sound KP_{Insert,End,Down,Next,Left,Begin,Right,Home,Up,Prior} + if [ -z "$SB_DIR" ]; then \ + notify-send -u critical -a "soundboard" '$SB_DIR is unset!';\ + exit;\ + fi;\ snd_id="{0-9}";\ id=$(cat /dev/random | base32 | head -c 5);\ socket="$SB_DIR/cur/sb-socket$snd_id-$id";\ @@ -20,10 +37,7 @@ 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" -# stop all sounds in current dir -KP_Delete - ls $SB_DIR/cur/sb-socket* | stop.sh - # stop all sounds shift + KP_Delete - find $SB_DIR/ -name "sb-socket*" | sb-msg "stop" + find $SB_DIR/ -name "sb-socket*" | sb-msg "stop";\ + find $SB_DIR/ -name "sb-socket*" | xargs rm diff --git a/src/.local/bin/bk.sh b/src/.local/bin/bk.sh index fb249a5..f43921c 100755 --- a/src/.local/bin/bk.sh +++ b/src/.local/bin/bk.sh @@ -20,6 +20,7 @@ then --exclude=med/mus \ --exclude=med/gv \ --exclude=sb-socket \ + --exclude=med/sb/cur \ --exclude=dox/dow \ --exclude=dox/rss \ --exclude=dox/rem \