aboutsummaryrefslogtreecommitdiff
path: root/env/.local/bin/system/url-handler.sh
blob: 5d0e893cbdbf8daf25046f3b63fabe35aaeb058c (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 -- "%s" "$url" | xclip -selection clipboard
    else
        printf -- "%s" "$url" | wl-copy
    fi
else
	$choice "$url" & disown
fi