X-Git-Url: https://iankelling.org/git/?p=distro-setup;a=blobdiff_plain;f=obs-clip;fp=clip-up;h=7d075a07530e7a9ec1094397d4035726ae5eb0e9;hp=2a26e547bba050560f9f360c1a9f385ad3db043b;hb=12e4748d67a2891d120f0ce7c29c2cf44a6119df;hpb=a44c96f8de0dfbb302923b48961abc912b41803e diff --git a/clip-up b/obs-clip similarity index 53% rename from clip-up rename to obs-clip index 2a26e54..7d075a0 100755 --- a/clip-up +++ b/obs-clip @@ -21,26 +21,41 @@ # 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'