summaryrefslogtreecommitdiff
path: root/bin/guiscripts/sturl
blob: 17f2beb6a4b0aa0d77d2340c7f60b4f98e4c9ba5 (plain)
1
2
3
4
5
6
7
8
9
10
11
#!/bin/sh

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]*)'
[ -z "$url" ] && exit 1

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