summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2023-12-12 00:12:10 +0100
committerRaymaekers Luca <raymaekers.luca@gmail.com>2023-12-12 00:12:10 +0100
commite04eb710bbd01c0f6f486c037815687081c21d4b (patch)
tree9b86cd1aa3921c7a706944bf04922c817e2180dc
parent94c9b362faa414e7068f60184e3d01a47b96b823 (diff)
added ytlink
-rwxr-xr-xbin/common/ytclipo19
-rwxr-xr-xbin/common/ytlink14
-rw-r--r--config/essentials/zsh/aliases.sh1
3 files changed, 16 insertions, 18 deletions
diff --git a/bin/common/ytclipo b/bin/common/ytclipo
index 959ee21..1a82df2 100755
--- a/bin/common/ytclipo
+++ b/bin/common/ytclipo
@@ -1,23 +1,6 @@
#!/bin/sh
-# argument ($1) -> clipboard -> stdin
-if [ "$WAYLAND_DISPLAY" ]
-then paste() { wl-paste; }
-elif [ "$TERMUX_VERSION" ]
-then paste() { termux-clipboard-get; }
-else paste() { xclip -o -sel c; }
-fi
-
-inp="$1"
-[ "${inp:=$(paste)}" ] || inp="$(cat /dev/stdin)"
-
-# remove util scheme
-inp="${inp#*//}"
-# convert to youtube.com/path url
-# works for:
-# - 'youtu.be/watch?v=xxxxxx'
-# - 'https://piped.video/watch?v=xxxxx'
-inp="https://youtube.com/${inp#*/}"
+inp="$(ytlink)"
>&2 printf "inp: %s\n" "$inp"
notify-send "ytclipo" "downloading <i>$inp</i>" || :
diff --git a/bin/common/ytlink b/bin/common/ytlink
new file mode 100755
index 0000000..a5e9bf0
--- /dev/null
+++ b/bin/common/ytlink
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# convert to youtube.com/path url
+# works for:
+# - 'youtu.be/watch?v=xxxxxx'
+# - 'https://piped.video/watch?v=xxxxx'
+
+inp="$1"
+[ "${inp:=$(clipo)}" ] || inp="$(cat /dev/stdin)"
+
+# remove util scheme
+inp="${inp#*//}"
+inp="https://youtube.com/${inp#*/}"
+printf "%s" "$inp"
diff --git a/config/essentials/zsh/aliases.sh b/config/essentials/zsh/aliases.sh
index 9c8f7f6..ee7dfd8 100644
--- a/config/essentials/zsh/aliases.sh
+++ b/config/essentials/zsh/aliases.sh
@@ -284,6 +284,7 @@ alias ffwin='hyprctl clients -j | jq '\''.[].pid'\'' | fzf --preview "hyprctl cl
alias pff='find ${PASSWORD_STORE_DIR:=~/src/password-store/} -name "*.gpg" | sed -e "s@$PASSWORD_STORE_DIR/@@" -e '\''s/\.gpg$//'\'' | fzf | xargs pass show -c'
alias fzps='fzf --print0 | xargs -0I{}'
alias ytdl='yt-dlp --restrict-filenames --embed-chapters -f "b" -S "res:1080" -P "$HOME/vids/youtube/" -o "%(channel)s/%(title)s.%(ext)s"'
+alias ytplay='mpv "$(ytlink)"'
# emacs aliases
alias emacsd='emacs --daemon'