-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowser
executable file
·60 lines (53 loc) · 2.5 KB
/
browser
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
#!/usr/bin/env bash
## By Davoud Arsalani
## https://github.com/davoudarsalani/scripts
## https://github.com/davoudarsalani/scripts/blob/master/browser
## https://raw.githubusercontent.com/davoudarsalani/scripts/master/browser
## https://davoudarsalani.ir
source "$HOME"/main/scripts/gb
readarray -t json_files < <(find "$HOME"/main/linux/cfg-firefox/ -mindepth 1 -maxdepth 1 -type f -iname 'bookmarks*.json' | sort)
readarray -t bookmarks < <(jq -rM .'children[1].children' "${json_files[-1]}" | \grep '"uri"' | sed 's/^\s*"\(uri\|iconUri\)": "//;s/"$//' | \grep '^http' | sort) ## NOTE keep \grep '^http' the last one
## previously: readarray -t bookmarks < <(\grep 'HREF=' "$HOME"/main/linux/cfg-firefox/bookmarks.html | \grep -vE 'place:parent|place:type' | sed 's/" .*//;s/^.*"//g;s/\/$//g' | sort)
case "$1" in
firefox )
ff_items=( 'new page' 'new tab' 'private' 'safe mode' 'preferences' 'tor' "${bookmarks[@]}" )
ff_item="$(pipe_to_rofi "${ff_items[@]}" 'header=firefox')" || exit 37
case "$ff_item" in
'new page' )
firefox &>/dev/null & ;;
'new tab' )
firefox --new-tab 'https://gitlab.com' &>/dev/null & ;;
private )
firefox --private-window &>/dev/null & ;;
'safe mode' )
firefox --safe-mode &>/dev/null & ;;
preferences )
firefox --preferences &>/dev/null & ;;
tor )
cd "$HOME"/main/tor-browser_en-US || exit ## absolute path won't work
./start-tor-browser.desktop &>/dev/null & ;;
* )
firefox "$ff_item" &>/dev/null & ;;
esac ;;
chromium )
chr_items=( 'new page' 'new tab' 'private' "${bookmarks[@]}" )
chr_item="$(pipe_to_rofi "${chr_items[@]}" 'header=chromium')" || exit 37
case "$chr_item" in
'new page' )
chromium &>/dev/null & ;;
'new tab' )
chromium 'https://gitlab.com' &>/dev/null & ;;
private )
chromium --incognito &>/dev/null & ;;
* )
chromium "$chr_item" &>/dev/null & ;;
esac ;;
qb ) qb_items=( 'new page' "${bookmarks[@]}" )
qb_item="$(pipe_to_rofi "${qb_items[@]}" 'header=qutebrowser')" || exit 37
case "$qb_item" in
'new page' )
qutebrowser --target tab &>/dev/null & ;;
* )
qutebrowser "$qb_item" &>/dev/null & ;;
esac ;;
esac