aboutsummaryrefslogtreecommitdiff
path: root/env/.local/bin/system/url-handler.sh
blob: d7be722515b28e3ea38340b5ec3b78cb9a6b93a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh
url=$@
prompt_message="Open with:"

echo $url

choices="
clipboard
browser/xdg-open
"

choice=$(echo "$choices" | sed /^$/d | rofi -dmenu "$prompt_message")
choice=$(echo "$choice" | sed -e 's/browser\/xdg-open/xdg-open/')

if [ "$choice" == "clipboard" ]; then
    if [ -z $WAYLAND_DISPLAY ]; then
        printf "$url" | xclip -selection clipboard
    else
        printf "$url" | wl-copy
    fi
else
	$choice "$url" & disown
fi