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