following links now separate script

this avoids the effects of swallow in dwm

it also will not produce dmenu without found urls
This commit is contained in:
Luke Smith
2020-04-15 16:43:14 -04:00
parent d9f3fd8a16
commit baa9fa076a
3 changed files with 19 additions and 3 deletions

15
st-urlhandler Executable file
View File

@ -0,0 +1,15 @@
#!/bin/sh
urlregex="(((http|https)://|www\\.)[a-zA-Z0-9.]*[:]?[a-zA-Z0-9./@&%?$#=_-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)"
# First remove linebreaks and mutt sidebars:
urls="$(sed 's/.*│//g' | tr -d '\n' |
grep -aEo "$urlregex" | # grep only urls as defined above.
uniq | # Ignore neighboring duplicates.
sed 's/^www./http:\/\/www\./g')"
[ -z "$urls" ] && exit
chosen="$(echo "$urls" | dmenu -w "$(xdotool getactivewindow)" -i -p 'Follow which url?' -l 10)"
setsid xdg-open "$chosen" >/dev/null 2>&1 &