diff options
| author | EuAndreh <eu@euandre.org> | 2021-01-22 23:44:12 -0300 |
|---|---|---|
| committer | EuAndreh <eu@euandre.org> | 2021-01-22 23:44:12 -0300 |
| commit | 79d834b35164734f8bc66379d4659104ff4fe4a3 (patch) | |
| tree | ca505bba2d5d4e65a1d6eba3e530e305faf5a8e9 /xmonad | |
| parent | Add vid* scripts (diff) | |
| download | dotfiles-79d834b35164734f8bc66379d4659104ff4fe4a3.tar.gz dotfiles-79d834b35164734f8bc66379d4659104ff4fe4a3.tar.xz | |
dmenu-vid.sh: Rewrite it to be a one-of launcher of media in the queue
Diffstat (limited to 'xmonad')
| -rwxr-xr-x | xmonad/scripts/dmenu-vid.sh | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/xmonad/scripts/dmenu-vid.sh b/xmonad/scripts/dmenu-vid.sh index e60b56fd..dbadb49b 100755 --- a/xmonad/scripts/dmenu-vid.sh +++ b/xmonad/scripts/dmenu-vid.sh @@ -1,10 +1,23 @@ #!/bin/sh set -eu -URL="$(xsel -bo)" +QUEUE="$HOME/archive/vid/queue.txt" +DB="$HOME/archive/vid/metadata-database.txt" -res="$(printf 'yes\nno\n' | dmenu -l 2 -p "$(printf 'Add to VLC: %s' "$URL")")" +LIST="$(mktemp)" +touch "$DB" +for url in $(cat "$QUEUE"); do + MATCH="$(grep -F "$url" "$DB" ||:)" + if [ -n "$MATCH" ]; then + echo "$MATCH" >> "$LIST" + else + printf '%s - %s\n' "$(youtube-dl "$url" -o '%(title)s - %(uploader)s' --get-filename)" "$url" >> "$DB" & + echo "$url" >> "$LIST" + fi +done -if [ "$res" = 'yes' ]; then - vlc "$URL" +file="$(dmenu -l 20 -p 'Media: ' < "$LIST")" + +if [ -n "$file" ]; then + vid "$file" fi |
