lots: shellcheck, streaming stuff, fixes
[distro-setup] / clip-up
diff --git a/clip-up b/clip-up
new file mode 100755 (executable)
index 0000000..dea5f1d
--- /dev/null
+++ b/clip-up
@@ -0,0 +1,25 @@
+#!/bin/bash
+set -e; . /usr/local/lib/bash-bear; set +e
+cd /a/bin/data/clips/up
+
+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