blob: b16418f8c1d34be94ad7457f7393a8fdd37ef90f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
#!/bin/bash
[ "$1" ] || exit 1
uri="$1"
queryfiltereduri="$(uriqueryfilter "$uri")"
if [ "$uri" != "$queryfiltereduri" ];then
trackeruri="$uri"
uri="$queryfiltereduri"
fi
### this clipping should be part of choose probably
if [ "${uri}" != "${uri:0:64}" ];then
prompt="${uri:0:64}..."
else
prompt="${uri}"
fi
scheme="$(uricut -s <<< "$uri")"
with="$(urigetline "$uri" < <(uristart.conf))"
if [ "$with" != "$(urigetline -a "$uri" < <(uristart.conf))" ];then
with="[multiple matches]"
fi
selection="$(printf "start with: %s\nremote_csn\ncopy\nshorten\nunshorten\ntitle\nverbose\nforget\nsplit\nQR-image\nQR\n%s\n" "${with}" "$(printf "%s\n" "$uri" | uricut | grep -v '^whole')" \
| choose "${prompt}")"
# | choose "$(printf "uri: '%s'\nwill be ran with: %s\n" "$uri" "$(urigetline "$uri")" )" -default start )"
echo "$selection"
case "$selection" in
remote_csn)
remote_host="$(choose "remote host to run URI on> " < ~/.config/urirhosts.conf)"
### TODO: include in the list our own display either to use -X or use our IP and display number?
display="$(ssh "${remote_host}" myXdisplays | choose "which display?")"
uristart "ssh://${remote_host}/copy_start_nevermind.sh%20${uri}?DISPLAY=$display"
exit 0
;;
verbose)
x-terminal-emulator -e less -f <(printf "%s" "$uri")
exit 0
;;
copy)
printf "%s" "$uri" | xclip -i
exit 0
;;
title)
copy_start_nevermind.sh "$(urititle "$uri")"
exit 0
;;
forget)
cp ~/.cache/uristart.log ~/.cache/uristart.log.tmp
cat ~/.cache/uristart.log.tmp | grep -vFw "${uri}" > ~/.cache/uristart.log
exit 0
;;
start*)
scheme="$(printf "%s\n" "$uri" | uricut -s)"
### might make sense to use xwindowURI for this value
if [ "$(xdotool getwindowfocus)" != 0 ];then
refering_window_title="$(xdotool getwindowfocus getwindowname)"
else
refering_window_title="[root window]"
fi
exec uristart "$uri" "$refering_window_title"
exit 0
;;
shorten)
escaped="$(uriescape "$uri")"
gemini-handler "gemini://epo.k.vu/submit?$escaped"
exit 0
;;
unshorten)
copy_start_nevermind.sh "$(unshorten.sh "$uri")"
exit 0
;;
split)
ret="$(printf "%s\n" "$uri" | tr ' ' '\n' | tr -s ' ' | choose "split> ")"
if [ "$ret" ];then
## do NOT want newlines in the clipboard.
printf "%s" "$ret" | xclip -i
fi
exit 0
;;
QR-image)
escaped="$(uriescape "$uri")"
file=~/Pictures/qr-codes/"${escaped}".png
qr "$uri" > "$file"
copy_start_nevermind.sh "file://$file"
;;
QR)
x-terminal-emulator -hold -e bash -c "qr '$uri';echo 'uri: $uri'"
;;
*)
if [ "$selection" ];then
exec printf "%s" "$selection" | cut '-d ' -f2- | xclip -i
fi
;;
esac
|