#!/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