summaryrefslogtreecommitdiff
path: root/dmpv
blob: f5742f5082652e96ccf620237ee620deb10540e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/sbin/sh

cd ~/Videos
case "$@" in
  "-l")
    LOOP="true"
    ;;
  "-h")
    HELP="true"
    ;;
esac

playvid () {
  while true; do
    VIDEO=$(printf ".\n%s\n" "$(ls)" | uniq | barmenu "$@")
    [ -z $VIDEO ] && exit
    if [ "$VIDEO" = "." ]; then
      break;
    fi
    [ -d $VIDEO ] && cd $VIDEO && continue
    [ -f "$VIDEO" ] && break
    pwd
  done
  mpv "$VIDEO"
}

printhelp () {
  printf \
    "Usage: dmpv [-l] [-h]\n" \
    "dmpv is a simple barmenu interface for playing content with mpv\n" \
    "dmpv assumes videos are stored in ~/Videos\n" \
    "  -h\t\tprint this help message\n" \
    "  -l\t\trun the prompt again after mpv exits\n"
}

if [ -n "$HELP" ]; then
  printhelp && exit 0
elif [ -n "$LOOP" ]; then
  while true; do
    playvid || exit 0
  done
fi

playvid
  done
fi