blob: 021c487284f19e5f0027788071aecefa8438eadc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#!/bin/sh
urlregex="(((http|https|gopher|gemini|ftp|ftps|git)://|www\\.)[a-zA-Z0-9.]*[:;a-zA-Z0-9./+@$&%?$\#=_~-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)"
urls="$(sed 's/.*│//g' | tr -d '\n' | # First remove linebreaks and mutt sidebars:
grep -aEo "$urlregex" | # grep only urls as defined above.
uniq | # Ignore neighboring duplicates.
sed "s/\(\.\|,\|;\|\!\\|\?\)$//;
s/^www./http:\/\/www\./")" # xdg-open will not detect url without http
[ -z "$urls" ] && exit 1
if [ $(echo "$urls" | wc -l) = "1" ]; then
chosen_url="$urls"
else
chosen_url="$(echo "$urls" | rofi -dmenu -i -p "" -l 10)"
fi
case "$chosen_url" in
http://*suckless.org*|https://*suckless.org*) command="surf" ;;
https://*.reliant.io*|https://acumera.*) command="/usr/bin/librewolf -P work" ;;
*) command="xdg-open" ;;
esac
setsid $command "$chosen_url" >/dev/null 2>&1
|