lots: shellcheck, streaming stuff, fixes
[distro-setup] / clip-sad
diff --git a/clip-sad b/clip-sad
new file mode 100755 (executable)
index 0000000..e1ce318
--- /dev/null
+++ b/clip-sad
@@ -0,0 +1,18 @@
+#!/bin/bash
+set -e; . /usr/local/lib/bash-bear; set +e
+cd /a/bin/data/clips/sad
+
+if pgrep mpv; then
+  pkill mpv
+  exit 0
+fi
+
+clip=$(find . -type f -printf '%f\n' | \
+         { if [[ -e /tmp/last-sad ]]; then
+             sed "/^$(cat /tmp/last-sad)\$/d"
+           else
+             cat
+           fi ; } | \
+             shuf | head -n1)
+echo $clip >/tmp/last-sad
+mpv --profile=a $clip