bin: merge linkhandler

This commit is contained in:
Dmitry Zakharchenko 2022-10-07 19:30:39 +03:00
parent 70a935fd7b
commit 87a6659dff
5 changed files with 17 additions and 40 deletions

View file

@ -5,7 +5,7 @@ initial-window-size-chars=80x24
pad=2x2
[url]
launch=linkhandler ${url}
launch=xdg-open ${url}
[colors]
foreground=f2f0ec

View file

@ -1,5 +1,5 @@
external-url-viewer "urlscan -dc -r 'linkhandler {}'"
browser linkhandler
external-url-viewer "urlscan -dc -r 'xdg-open {}'"
browser xdg-open
auto-reload no
goto-next-feed no
show-read-feeds no
@ -48,10 +48,10 @@ bookmark-interactive no
bookmark-autopilot yes
# Macroses
macro y set browser "echo %u | wl-copy"; open-in-browser; set browser linkhandler
macro d set browser "handler %u"; open-in-browser-and-mark-read; set browser linkhandler
macro c set browser "pipe-viewer --no-interactive --comments=%u | less"; open-in-browser; set browser linkhandler
macro i set browser "pipe-viewer --no-interactive --info=%u | less"; open-in-browser; set browser linkhandler
macro y set browser "echo %u | wl-copy"; open-in-browser; set browser xdg-open
macro d set browser "linkhandler %u"; open-in-browser-and-mark-read; set browser xdg-open
macro c set browser "pipe-viewer --no-interactive --comments=%u | less"; open-in-browser; set browser xdg-open
macro i set browser "pipe-viewer --no-interactive --info=%u | less"; open-in-browser; set browser xdg-open
# Colors
color info black white reverse

View file

@ -1,17 +1,20 @@
# Binds
config.bind('po', 'spawn linkhandler {url}')
config.bind('pd', 'spawn wm-handler {url}')
config.bind('yo', 'hint links spawn linkhandler {hint-url}')
config.bind('yd', 'hint links spawn wm-handler {hint-url}')
config.bind('pd', 'spawn linkhandler {url}')
config.bind('yd', 'hint links spawn linkhandler {hint-url}')
# Cloudflare workaround
old_chrome_ua = 'Mozilla/5.0 ({os_info}) AppleWebKit/{webkit_version} (KHTML, like Gecko) {qt_key}/{qt_version} {upstream_browser_key}/67.0.1 Safari/{webkit_version}'
config.set('content.headers.user_agent', old_chrome_ua, 'market.dota2.net')
config.set('content.headers.user_agent', old_chrome_ua, '4chan.org')
# Search engines
c.url.searchengines = {'DEFAULT': 'https://librex.extravi.dev/search.php?q={}',
c.url.searchengines = {'DEFAULT': 'https://librex.beparanoid.de/search.php?q={}',
'y': 'https://yewtu.be/search?q={}',
'gh': 'https://github.com/search?q={}',
'md': 'https://reelgood.com/search?q={}',
'rtk': 'https://rutracker.org/forum/tracker.php?nm={}',
'rep': 'https://repology.org/projects/?search={}',
'trans': 'https://lingva.pussthecat.org/en/uk/{}'
'trans': 'https://lingva.ml/en/uk/{}'
}
c.confirm_quit = ['downloads']

View file

@ -1,26 +0,0 @@
#!/bin/sh
# Feed script a url or file location.
# If an image, it will view in sxiv,
# if a video or gif, it will view in mpv
# if a music file or pdf, it will download,
# otherwise it opens link in browser.
if [ -z "$1" ]; then
url="$(wl-copy -o)"
else
url="$1"
fi
case "$url" in
*mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*yewtu.be*|*hooktube.com*|*twitch.tv*|*bitchute.com/embed*|*videos.lukesmith.xyz*)
setsid -f mpv -quiet "$url" >/dev/null 2>&1 ;;
*png|*jpg|*jpe|*jpeg|*gif)
curl -sL "$url" > "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" && sxiv -a "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;;
*pdf|*cbz|*cbr)
curl -sL "$url" > "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" && zathura "/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 ;;
*)
[ -f "$url" ] && setsid -f "$TERMINAL" -e "$EDITOR" "$url" >/dev/null 2>&1 || setsid -f "$BROWSER" "$url" >/dev/null 2>&1
esac

View file

@ -2,7 +2,7 @@
# Feed this script a link and it will give dmenu
# some choice programs to use to open it.
feed="${1:-$(printf "%s" | wmenu -p 'Paste URL or file path')}"
feed="${1:-$(printf "%s" | tofi --prompt-text 'Paste URL or file path')}"
case "$(printf "yt-dlp\\nyt-dlp (audio)\\nyt-dlp (music)\\nmpv\\nmpv (audio)\\ncurl\\nzathura\\nimv\\nvim\\nbrowser" | tofi --prompt-text "Handle it with?")" in
"yt-dlp") qndl "$feed" >/dev/null 2>&1 ;;