# limitations under the License.
set -e; . /usr/local/lib/bash-bear; set +e
-cd /a/bin/data/clips/up
+
+type=$1
+
+cd /a/bin/data/clips/$type
if pgrep mpv; then
pkill mpv
exit 0
fi
-if [[ ! -s /tmp/last-up ]]; then
- find . -type f -printf '%f\n' | shuf > /tmp/last-up
-fi
-clip=$(head -n1 /tmp/last-up)
-tail -n+2 /tmp/last-up | sponge /tmp/last-up
-
-# clip=$(ls -1 . | \
- # { if [[ -e /tmp/last-up ]]; then
-# sed "/^$(cat /tmp/last-up)\$/d"
-# else
-# cat
-# fi ; } | \
- # shuf | head -n1)
-# echo $clip >/tmp/last-up
-
-mpv --profile=a $clip
+
+case $type in
+ up)
+ if [[ ! -s /tmp/last-up ]]; then
+ find . -type f -printf '%f\n' | shuf > /tmp/last-up
+ fi
+ clip=$(head -n1 /tmp/last-up)
+ tail -n+2 /tmp/last-up | sponge /tmp/last-up
+ ;;
+ *)
+ clip=$(find . -type f -printf '%f\n' | \
+ { if [[ -e /tmp/last-$type ]]; then
+ sed "/^$(cat /tmp/last-$type)\$/d"
+ else
+ cat
+ fi ; } | \
+ shuf | head -n1)
+ echo $clip >/tmp/last-$type
+ ;;
+esac
+
+p=$(cat /p/obs-ws-pass)
+# note, if the desktop audio is already on, this will do the wrong thing.
+# obs-cmd needs more commands. But, I don't use desktop audio for anything
+# else atm.
+obs-cmd -w obsws://localhost:4455/$p toggle-mute 'Desktop Audio'
+mpv --profile=a $clip ||:
+obs-cmd -w obsws://localhost:4455/$p toggle-mute 'Desktop Audio'