aboutsummaryrefslogtreecommitdiff
path: root/scripts/viddq
blob: 6abb66a2b28e704a5c9e68027ce9c97156e7c2c2 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh
set -eu

QUEUE="$HOME/archive/vid/queue.txt"
NEXT="$(head -n1 "$QUEUE")"
if [ -z "$NEXT" ]; then
  echo 'Queue is empty!'
else
  if mpv "$NEXT" 2>/dev/null | tail -n1 | grep '^Exiting\.\.\. (End of file)$'; then
    echo "Finished playing '$NEXT', getting next on the queue." >&2
    NEW_QUEUE="$(mktemp)"
    tail -n+2 "$QUEUE" > "$NEW_QUEUE"
    mv "$NEW_QUEUE" "$QUEUE"
    viddq
  else
    echo "Quit playing '$NEXT' without finishing, not removing it from the queue."
  fi
fi