-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb-xdg-open.1
174 lines (151 loc) · 3.28 KB
/
web-xdg-open.1
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
.TH wxo 1 web-xdg-open
.SH NAME
web-xdg-open - open links in the program configured for xdg-open instead of a
normal browser
.SH SYNOPSIS
.B web-xdg-open
.I LINK
.SH DESCRIPTION
.B web-xdg-open
tries to open links with the
.B default filetype
handler. For example images are opened in the default image viewer as
configured by
.B xdg-utils.
.SH CONFIGURATION
You can configure
.B web-xdg-open
by overriding it's default behaviour for a file group. This can be done in one
of:
.in 10
.B $XDG_CONFIG_HOME/wxorc
.in 10
.B ~/.config/wxorc
.in 7
The file groups are:
.in 10
- image
.in 10
- video
.in 10
- text
.in 10
- git
.in 10
- gif
.in 10
- pdf
.in 10
- clipboard
.in 7
Additionally you can also override a
.I other
function to provide handling of other patterns that
.B web-xdg-open
does not already recognise. This function receives a second parameter containing the same link
stripped of the any query string it might have.
.in 7
For example, to open text files in neovim one can define this function in the
config file:
.in 10
text() {
dl "$1" >"$TEMPFILE" && $TERMINAL -e bash -c "nvim '$TEMPFILE'"
.br
}
.in 7
.B IMPORTANT NOTE:
.br
For
.B web-xdg-open
to work properly it is very important that exit statuses are
propagated outside these functions. To do this either chain all commands with
.I &&
or append
.I ||return
to the command.
If you don't do this then the fallback might not be used and
.B web-xdg-open
will be very frustrating to use.
.B Example:
.in 10
video() {
command1 && command2
.br
}
.br
.I OR
.br
video() {
command1 || return
.br
command2 || return
.br
}
.in 7
When defining these functions there are a few utilities that
.B web-xdg-open
defines you can make use of when making your config file. You can also
override them but this is highly discouraged.
.TP
.B notify()
A simple wrapper around
.B notify-send(1)
that never returns an error exit status.
.TP
.B dl()
Downloads the passed link and outputs the downloaded data to
.B stdout
returning an error exit status if the download fails for any reason and uses
.B notify()
to warn about it.
.TP
.B fallback()
Is used in case
.B web-xdg-open
fails for any reason. By default it opens the link in
.I $BROWSER
.br
Change this variable in the config file (or globally) to set your default web
browser.
.TP
.B $TEMPFILE
A variable that is guaranteed to hold the name of a valid temporary file in the
format
.I tmp.XXXXXXXXXX.EXT
where
.I XXXXXXXXXX
are random characters and
.I EXT
is the file extension. This file is also guaranteed to be
.I deleted
after
.B web-xdg-open
exits.
.SH FAQ
.TP
.B What is 'clipboard' used for?
The 'clipboard' function will copy the file's contents to the clipboard.
Currently only files ending in
.I *.pub
are copied to the clipboard, as these are usually public rsa keys.
.TP
.B How do I set web-xdg-open as my default browser?
xdg-mime default web-xdg-open.desktop x-scheme-handler/http
.br
xdg-mime default web-xdg-open.desktop x-scheme-handler/https
.TP
.B How can I have a really cool confy config?
That's easy! Just download
.I https://github.com/mendess/spell-book/blob/master/runes/wxorc
😎.
.SH AUTHORS
Written by Pedro Mendes <[email protected]> originally in 2020.
.SH LICENSE
GPLv3
.SH SEE ALSO
.BR notify-send(1)
.BR mpv(1)
.BR xclip(1)
.BR xdg-open(1)
.BR xdg-mime(1)
.BR youtube-dl(1)