#!/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