summaryrefslogtreecommitdiff
path: root/bin/guiscripts/sturl
blob: bf1fb02fadcad3c4f51bc37af4848b0ebb6147b2 (plain)
1
2
3
4
5
6
7
8
9
10
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="$(cat | tr -d '\n' | grep -Eo "$regex" | dmenu -x -c -g 1 -l 10)"
[ -z "$url" ] && exit 1

case $1 in
	'c') echo -n "$url" | xclip -sel c -r ;;
	'o') linkhandler "$url" ;;
	*) echo "no option" ;;
esac