summaryrefslogtreecommitdiff
path: root/bin/common
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2023-10-16 12:09:14 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2023-10-16 12:09:14 +0200
commit4ca15dd82c255dfad7e4cf5a347b971f97a0bfed (patch)
treea848847a680f25f04ab6d3a31bb9e10377d78f6d /bin/common
parentdb8f32037483ade8fc3d8fc2cb2c0e18331e442e (diff)
parent6c78112e19f44ef79eebf1076041feff83c303e6 (diff)
Merge branch 'main' of db:dotfiles
Diffstat (limited to 'bin/common')
-rwxr-xr-xbin/common/ytclipo20
1 files changed, 10 insertions, 10 deletions
diff --git a/bin/common/ytclipo b/bin/common/ytclipo
index fc98b6e..712b068 100755
--- a/bin/common/ytclipo
+++ b/bin/common/ytclipo
@@ -2,19 +2,20 @@
# argument ($1) -> clipboard -> stdin
if [ "$WAYLAND_DISPLAY" ]
-then
- paste="$(wl-paste)"
-else
- paste="$(xclip -o -sel c)"
+then paste() { wl-paste; }
+elif [ "$TERMUX_VERSION" ]
+then paste() { termux-clipboard-get; }
+else paste() { xclip -o -sel c; }
fi
-test -z "${inp:=${1:-$paste}}" &&
- inp="$(cat /dev/stdin)"
+
+inp="$1"
+[ "${inp:=$(paste)}" ] || inp="$(cat /dev/stdin)"
# take last link from clipboard
# works when link is from yt-local
inp="https://youtu.be/$(echo "$inp" | sed 's/.*\(.\{11\}\)$/\1/')"
-echo "inp: ${inp}" 1>&2
-notify-send "ytclipo" "<b>downloading</b> $inp"
+>&2 printf "inp: %s\n" "$inp"
+notify-send "ytclipo" "<b>downloading</b> $inp" || :
yt-dlp "$inp" \
--restrict-filenames \
@@ -23,5 +24,4 @@ yt-dlp "$inp" \
-S "res:1080" \
-P "$HOME/vids/youtube/" \
-o "%(channel)s - %(title)s.%(ext)s"
-notify-send "ytclipo" "<b>ytclipo</b><br>finished downloading."
-echo "$inp" >> /tmp/ytclipo_history
+notify-send "ytclipo" "<b>ytclipo</b><br>finished downloading." || :