-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdmenu-browse
103 lines (94 loc) · 4.38 KB
/
dmenu-browse
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
#!/bin/bash
INFO() {
cat <<EOF>&2
### DEPENDS ON ###
"surfraw"-for keyword based search, you will need /usr/lib/surfraw in your path, so add below line to your .bashrc (uncommented)
PATH=/usr/lib/surfraw:${PATH}
"trans" and "w3m" for language translations, https://github.com/soimort/translate-shell
"sdcv" for dictionary use
### CONFIGURATION ###
place your browser in BROWSER=? line
place your bookmarks text file with 1 url/line, put it in "BOOKMARKS=?" field
default script uses rofi, to use dmenu uncomment the line starting with dmenu and comment out previous line starting with rofi
### USE ###
enter text in rofi/dmenu field, it will be matched against bookmarks, <enter> to open selected bookmark
to search specific sites use keyword as first argument ( like go for google, wi for wikipedia, aw for archwiki etc.) > read the script to find out all keywords
to find out route from delhi to mumbai with google map, "nav delhi mumbai" or to search a location only use "map <location>"
if no keyword or url is used, entire argument will be searched with duckduckgo
to search with input text only (not matching bookmark) use <C-enter> (rofi only)
to edit selected bookmark use <C-space> (rofi only)
EOF
}
while getopts h: help; do
case $help in
h|\?) INFO && exit ;;
esac
done
shopt -s lastpipe
## Add name of your browser here ( not text-browsers )
BROWSER=qutebrowser
## add your plain text bookmarks here, you can add tag after the bookmark bookmart url e.g., "www.google.co.in search googlesearch", use "link-handler" for adding bookmarks
BOOKMARKS=~/.config/vimb/bookmark
# use rofi to display bookmarks and select one
rofi -dmenu -location 1 -l 10 -width 100 -font "Inconsolata 14" -p $BROWSER < "$BOOKMARKS" | read -a "url"
## use dmenu inplace of rofi
#/usr/bin/dmenu -l 10 -fn "Inconsolata 14" -p $BROWSER: < "$BOOKMARKS" | read -a url
[[ ! $url ]] && exit
duckimage() {
x=$@
$BROWSER "https://duckduckgo.com/?q=${x// /+}&ia=images&iax=1"
}
duckvideo() {
x=$@; $BROWSER "https://duckduckgo.com/?q=${x// /+}&ia=videos&iax=1"
}
DDG() {
x=$@; $BROWSER "https://duckduckgo.com/?q=${x// /+}"
}
MED() {
x=$@; $BROWSER "http://medical-dictionary.thefreedictionary.com/${x// /+}"
}
FLIPKART() {
x=$@; $BROWSER "https://www.flipkart.com/search?q=${x// /+}"
}
NAV() {
$BROWSER "https://maps.google.com/maps?saddr=$1&daddr=$2"
}
case "${url[0]}" in
*.*|*:*|*/*) $BROWSER "${url[0]}" ;;
aw|awiki) archwiki -browser=$BROWSER "${url[@]:1}" ;;
wi|wiki) wikipedia -browser=$BROWSER "${url[@]:1}" ;;
imdb) imdb -browser=$BROWSER "${url[@]:1}" ;;
aur) aur -browser=$BROWSER "${url[@]:1}" ;;
pkg) archpkg -browser=$BROWSER "${url[@]:1}" ;;
ddg|S|DDG) DDG "${url[@]:1}" ;;
go|google) google -browser=$BROWSER "${url[@]:1}" ;;
map) google -m -browser=$BROWSER "${url[@]:1}" ;;
nav) NAV "${url[1]}" "${url[2]}" ;;
# image) google -i -browser=$BROWSER "${url[@]:1}" ;;
image) duckimage "${url[@]:1}" ;;
# video) google -v -browser=$BROWSER "${url[@]:1}" ;;
video) duckvideo "${url[@]:1}" ;;
news) google -n -browser=$BROWSER "${url[@]:1}" ;;
yt|youtube) youtube -browser=$BROWSER "${url[@]:1}" ;;
ebay) ebay -browser=$BROWSER "${url[@]:1}" ;;
fk|flipkart) FLIPKART "${url[@]:1}" ;;
pubmed) pubmed -browser=$BROWSER "${url[@]:1}" ;;
git|github) github -browser=$BROWSER "${url[@]:1}" ;;
## LOCAL DICTIONARIES
## to use def/guj/hin for dictionaries sdcv needs to setup with working dictionaries.
def) notify-send "$( sdcv --data-dir ~/dic/english/ "${url[@]:1}" )" && exit ;;
guj) notify-send "$( sdcv --data-dir ~/dic/gujarati/ "${url[@]:1}" )" && exit ;;
hin) notify-send "$( sdcv --data-dir ~/dic/hindi/ "${url[@]:1}" )" && exit ;;
## ONLINE TRANSLATION
## to use translation "trans" should be in path with w3m installed, translates to english
trans) notify-send "$( trans -brief "${url[@]:1}" )" && exit ;;
## translates to gujarati
trans_gu) notify-send "$( trans -brief :gu "${url[@]:1}" )" && exit ;;
## online medical dictionary
med) MED "${url[@]:1}" ;;
*) if [[ $BROWSER != dillo ]]; then
duckduckgo -j -browser=$BROWSER "${url[@]}"
else
google -browser=$BROWSER "${url[@]}"
fi ;;
esac