st/st-plumber

14 lines
385 B
Plaintext
Raw Normal View History

2021-08-12 15:44:21 +02:00
#!/bin/sh
# requires https://metacpan.org/pod/Regexp::Common::URI
2021-08-12 15:53:51 +02:00
open() {
2021-08-12 16:41:21 +02:00
echo "$1" | xsel -ib
exec setsid -f xdg-open "$1"
2021-08-12 15:53:51 +02:00
}
2022-07-14 00:35:32 +02:00
{ [ -f "$1" ] || [ -d "$1" ] ;} && open "$1"
2021-08-12 15:53:51 +02:00
2021-08-12 15:44:21 +02:00
url="$(echo "$1" | perl -M'Regexp::Common=URI' -ne 'if (/($RE{URI})/) {print $1; exit}')"
2021-08-12 16:41:21 +02:00
[ -n "$url" ] && open "$url"
2021-08-12 15:53:51 +02:00
2021-08-12 15:44:21 +02:00
notify-send -t 2000 -u critical st-plumber "Selection is not a valid file or url!"