2
2
# nbrowser v0.2
3
3
# author : odnar-dev <https://github.com/odnar-dev>
4
4
# source : https://github.com/MyOS-ArchLinux/nbrowser
5
- # license: GPLv3+ <https://gnu.org/licenses/gpl.html>
5
+ # license: GPLv3 <https://gnu.org/licenses/gpl-3.0 .html>
6
6
# shellcheck disable=SC2190,SC2086,SC1091
7
7
8
8
NBROWSER_CONFIG_DIR=" ${XDG_CONFIG_HOME:- $HOME / .config} /nbrowser"
9
9
NBROWSER_DEFAULT_SEARCH=${NBROWSER_DEFAULT_SEARCH:- duckduckgo}
10
10
11
11
declare -A ENGINES
12
12
13
- ENGINES+=([" duckduckgo" ]=" https://duckduckgo.com/?q=" )
14
- ENGINES+=([" ddg" ]=" https://duckduckgo.com/?q=" )
15
- ENGINES+=([" google" ]=" https://www.google.com/search?q=" )
16
- ENGINES+=([" startpage" ]=" https://www.startpage.com/do/search?query=" )
17
-
18
- ENGINES+=([" archwiki" ]=" https://wiki.archlinux.org/index.php?title=Special:Search&search=" )
19
- ENGINES+=([" aur" ]=" https://aur.archlinux.org/packages/?O=0&SeB=nd&outdated=&SB=n&SO=a&PP=50&do_Search=Go&K=" )
20
-
21
- ENGINES+=([" git" ]=" https://github.com/search?q=" )
22
- ENGINES+=([" github" ]=" https://github.com/search?q=" )
23
-
24
- ENGINES+=([" mal" ]=" https://myanimelist.net/search/all?q=" )
25
- ENGINES+=([" imdb" ]=" https://www.imdb.com/find?q=" )
26
- ENGINES+=([" tmdb" ]=" https://www.themoviedb.org/search?query=" )
27
- ENGINES+=([" tvdb" ]=" https://www.thetvdb.com/search?query=" )
13
+ ENGINES=(
14
+ [" google" ]=" https://www.google.com/search?q="
15
+ [" duckduckgo" ]=" https://duckduckgo.com/?q="
16
+ [" ddg" ]=" https://duckduckgo.com/?q="
17
+ [" startpage" ]=" https://www.startpage.com/do/search?query="
18
+ [" archwiki" ]=" https://wiki.archlinux.org/index.php?title=Special:Search&search="
19
+ [" aur" ]=" https://aur.archlinux.org/packages/?O=0&SeB=nd&outdated=&SB=n&SO=a&PP=50&do_Search=Go&K="
20
+ [" github" ]=" https://github.com/search?q="
21
+ [" git" ]=" https://github.com/search?q="
22
+ [" imdb" ]=" https://www.imdb.com/find?q="
23
+ [" tmdb" ]=" https://www.themoviedb.org/search?query="
24
+ [" tvdb" ]=" https://www.thetvdb.com/search?query="
25
+ [" mal" ]=" https://myanimelist.net/search/all?q="
26
+ )
28
27
29
28
has () {
30
29
case " $( command -v " $1 " 2> /dev/null) " in
@@ -135,58 +134,65 @@ open_a_browser(){
135
134
{ setsid -f ${selected_browser} > /dev/null 2>&1 ; }
136
135
;;
137
136
esac
138
-
139
137
}
140
138
141
139
open_video_with (){
142
140
selected_action=$( printf ' %s\n' " Play" " Download" " Open in Browser" | rofi -dmenu -p ' Open Video with' -mesg " ${@// &/ &} " -i -l 3)
143
141
144
142
case " $selected_action " in
145
143
" Play" )
146
- if has ' play ' ; then
147
- { setsid -f play " play:// $* " > /dev/null 2>&1 ; }
148
- else
144
+ if [ -n " ${NBROWSER_PLAYER} " ] ; then
145
+ { setsid -f ${NBROWSER_PLAYER} " $* " > /dev/null 2>&1 ; }
146
+ elif has ' mpv ' ; then
149
147
{ setsid -f mpv " $* " > /dev/null 2>&1 ; }
148
+ elif has ' vlc' ; then
149
+ { setsid -f vlc " $* " > /dev/null 2>&1 ; }
150
+ else
151
+ _pemx " mpv is not installed in your system!"
150
152
fi
151
153
;;
152
154
" Download" )
153
- if has ' dwld' ; then
154
- { setsid -f dwld " dwld://$* " > /dev/null 2>&1 ; }
155
+ if [ -n " ${NBROWSER_DOWNLOADER} " ] ; then
156
+ { setsid -f ${NBROWSER_DOWNLOADER} " $* " > /dev/null 2>&1 ; }
157
+ elif has ' youtube-dl' ; then
158
+ { setsid -f " ${TERMINAL:- st} " -e sh -c " youtube-dl $* || read" > /dev/null 2>&1 ; }
159
+ elif has ' yt-dlp' ; then
160
+ { setsid -f " ${TERMINAL:- st} " -e sh -c " yt-dlp $* || read" > /dev/null 2>&1 ; }
155
161
else
156
- { setsid -f " ${TERMINAL :- st} " -e sh -c " youtube-dl $* " > /dev/null 2>&1 ; }
162
+ _pemx " youtube-dl is not installed in your system! "
157
163
fi
158
164
;;
159
165
" Open in Browser" )
160
166
open_in_browser " $1 "
161
167
;;
162
168
esac
163
-
164
169
}
165
170
166
171
open_picture_with (){
167
172
selected_action=$( printf ' %s\n' " View" " Edit with Gimp" " Open in Browser" | rofi -dmenu -p ' Open Picture with' -mesg " ${@// &/ &} " -i -l 3)
168
173
169
174
case " $selected_action " in
170
175
" View" )
171
- if has ' sxiv' ; then
176
+ if has ' sxiv' ; then
172
177
curl -sL " $1 " > " /tmp/$( echo " $@ " | sed " s/.*\///;s/%20/ /g" ) " && \
173
178
{ setsid -f sxiv -a " /tmp/$( echo " $@ " | sed " s/.*\///;s/%20/ /g" ) " > /dev/null 2>&1 ; }
179
+ elif has ' feh' ; then
180
+ { setsid -f feh " $* " > /dev/null 2>&1 ; }
174
181
else
175
- _pemx " sxiv is no installed in your system!"
182
+ _pemx " sxiv is not installed in your system!"
176
183
fi
177
184
;;
178
185
" Edit with Gimp" )
179
- if has ' gimp' ; then
186
+ if has ' gimp' ; then
180
187
{ setsid -f gimp " $* " > /dev/null 2>&1 ; }
181
188
else
182
- _pemx " gimp is no installed in your system!"
189
+ _pemx " gimp is not installed in your system!"
183
190
fi
184
191
;;
185
192
" Open in Browser" )
186
193
open_in_browser " $1 "
187
194
;;
188
195
esac
189
-
190
196
}
191
197
192
198
open_in_browser (){
@@ -211,7 +217,6 @@ open_in_browser(){
211
217
{ setsid -f $selected_browser " $* " > /dev/null 2>&1 ; }
212
218
;;
213
219
esac
214
-
215
220
}
216
221
217
222
url_handler (){
@@ -296,7 +301,7 @@ main(){
296
301
# handle local pdf
297
302
[ -z " $NBROWSER_PDF_VIEWER " ] || installed_browsers[0]=" PDF Reader : ${NBROWSER_PDF_VIEWER} "
298
303
;;
299
- * .html)
304
+ * .html)
300
305
# handle local html
301
306
[ -z " $NBROWSER_HTML_EDITOR " ] || installed_browsers[0]=" Text Editor : ${NBROWSER_HTML_EDITOR} "
302
307
esac
0 commit comments