diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/common/ytclipo | 19 | ||||
-rwxr-xr-x | bin/common/ytlink | 14 | ||||
-rwxr-xr-x | bin/extra/sgimg | 2 | ||||
-rwxr-xr-x | bin/guiscripts/linkhandler | 8 | ||||
-rwxr-xr-x | bin/guiscripts/sturl | 6 |
5 files changed, 26 insertions, 23 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/bin/extra/sgimg b/bin/extra/sgimg index 7c1823c..acb8126 100755 --- a/bin/extra/sgimg +++ b/bin/extra/sgimg @@ -1,6 +1,6 @@ #!/bin/sh -imv "$(find ~/.local/share/gurk/ -type f -printf "%A@\t%p\n" | +imv "$(find ~/.local/share/gurk/ -type f \( -iname '*.png' -o -iname '*.jpg' \) -printf "%A@\t%p\n" | sort -n | tail -n 1 | cut -f 2-)" diff --git a/bin/guiscripts/linkhandler b/bin/guiscripts/linkhandler index aeec202..329e267 100755 --- a/bin/guiscripts/linkhandler +++ b/bin/guiscripts/linkhandler @@ -11,6 +11,12 @@ test -z "${url:=$1}" && dunstify "linkhandler" "<b>handling</b> $url" case "$url" in + file://*) file="${url##file:/}" + case "$(file -bi "$file" | cut -f1 -d'/')" in + audio|video) mpv "$file" ;; + image) imv "$file" ;; + *) xdg-open "$file" ;; + esac ;; *mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtube.com/shorts*|*youtu.be*|*hooktube.com*|*bitchute.com*|*videos.lukesmith.xyz*|*odysee.com*) setsid -f mpv --quiet --ytdl --ytdl-raw-options="format-sort=res:720" "$url" > /dev/null 2>&1 ;; *png|*jpg|*jpe|*jpeg|*gif) @@ -18,7 +24,7 @@ case "$url" in *pdf|*cbz|*cbr) curl -sL "$url" > "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" && $VIEWER "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;; *mp3|*flac|*opus|*mp3?source*) - qndl "$url" 'curl -LO' >/dev/null 2>&1 ;; + mpv "$url" 'curl -LO' >/dev/null 2>&1 ;; *) if [ -f "$url" ] then setsid -f "$TERMINAL" -e "$EDITOR" "$url" >/dev/null 2>&1 diff --git a/bin/guiscripts/sturl b/bin/guiscripts/sturl index c738c8e..5b8b1e7 100755 --- a/bin/guiscripts/sturl +++ b/bin/guiscripts/sturl @@ -1,11 +1,11 @@ #!/bin/sh -regex='(((https?|gopher|gemini|ftps?|git)://|www\.)[a-zA-Z0-9.]*[:;a-zA-Z0-9./+@$&%?$\#=_~-]*)|(magnet:\?xt=urn:btih:[a-zA-Z0-9]*)' -url="$(tr -d '\n' | grep -Eo "$regex" | dmenu -x -c -g 1 -l 10)" +regex='(((file|https?|gopher|gemini|ftps?|git)://|www\.)[a-zA-Z0-9.]*[:;a-zA-Z0-9./+@$&%?$\#=_~-]*)|(magnet:\?xt=urn:btih:[a-zA-Z0-9]*)' +url="$(tr -d '\n' | grep -Eo "$regex" | tac | commander -cl)" [ -z "$url" ] && exit 1 case $1 in - 'c') echo -n "$url" | xclip -sel c -r ;; + 'c') printf '%s' "$url" | xclip -sel c -r ;; 'o') linkhandler "$url" ;; *) echo "no option" ;; esac |