summaryrefslogtreecommitdiff
path: root/st-0.8.2/st-urlhandler
diff options
context:
space:
mode:
authorstkhan <personal@slickd.xyz>2021-04-21 19:36:08 +0000
committerstkhan <personal@slickd.xyz>2021-04-21 19:36:08 +0000
commit661cc0a02fb3d38440ad8c1e295fdbde9c1299d8 (patch)
treef66f68dc51e04a1cacb3d609be5fa0c83ba876c1 /st-0.8.2/st-urlhandler
parentfe2168b902a1775ae50041710b79d7751237f1ce (diff)
Added paleofetch
Diffstat (limited to 'st-0.8.2/st-urlhandler')
-rwxr-xr-xst-0.8.2/st-urlhandler18
1 files changed, 18 insertions, 0 deletions
diff --git a/st-0.8.2/st-urlhandler b/st-0.8.2/st-urlhandler
new file mode 100755
index 0000000..b8f9787
--- /dev/null
+++ b/st-0.8.2/st-urlhandler
@@ -0,0 +1,18 @@
+#!/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/^www./http:\/\/www\./g')" # xdg-open will not detect url without http://
+
+[ -z "$urls" ] && exit 1
+
+while getopts "hoc" o; do case "${o}" in
+ h) printf "Optional arguments for custom use:\\n -c: copy\\n -o: xdg-open\\n -h: Show this message\\n" && exit 1 ;;
+ o) chosen="$(echo "$urls" | dmenu -i -p 'Follow which url?' -l 10)"
+ setsid xdg-open "$chosen" >/dev/null 2>&1 & ;;
+ c) echo "$urls" | dmenu -i -p 'Copy which url?' -l 10 | tr -d '\n' | xclip -selection clipboard ;;
+ *) printf "Invalid option: -%s\\n" "$OPTARG" && exit 1 ;;
+esac done