aboutsummaryrefslogtreecommitdiff
path: root/xmonad
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2021-01-22 23:44:12 -0300
committerEuAndreh <eu@euandre.org>2021-01-22 23:44:12 -0300
commit79d834b35164734f8bc66379d4659104ff4fe4a3 (patch)
treeca505bba2d5d4e65a1d6eba3e530e305faf5a8e9 /xmonad
parentAdd vid* scripts (diff)
downloaddotfiles-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-xxmonad/scripts/dmenu-vid.sh21
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