summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2023-03-05 12:21:24 +0100
committerRaymaekers Luca <raymaekers.luca@gmail.com>2023-03-05 12:21:24 +0100
commitb75ec24e80504b24b1d35f6d6c6d55b14f564517 (patch)
treee6f952060c6ab4e0f028f4958103ddc05a6754cf /bin
parentd63ed4966b8fe4a813caaf1977ec21becc142add (diff)
rewritten sturl to better handle links
Diffstat (limited to 'bin')
-rwxr-xr-xbin/guiscripts/sturl13
1 files changed, 10 insertions, 3 deletions
diff --git a/bin/guiscripts/sturl b/bin/guiscripts/sturl
index f7a3956..bf1fb02 100755
--- a/bin/guiscripts/sturl
+++ b/bin/guiscripts/sturl
@@ -1,4 +1,11 @@
#!/bin/sh
-regex='\(ipfs:\|ipns:\|magnet:\|mailto:\|gemini:\|gopher:\|https:\|http:\|news:\|file:\|git:\|ssh:\|ftp:\)[^\<>"{-}\^`]\+'
-url="$(grep "$regex" | sort | uniq | dmenu -g 1 -l 10 -x -c)"
-linkhandler $url
+
+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