-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbromium
executable file
·101 lines (93 loc) · 3.4 KB
/
bromium
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
#!/bin/bash
help() {
echo 'usage: bromium [--enable-cookies] [--userdir /path/to/userdir] [URL]'
echo ' bromium --help'
echo
echo ' Run chromium with an empty temporary profile'
echo ' or with a given directory.'
echo
echo ' By default bromium will run in "incognito"'
echo ' mode. If you want to allow cookies then'
echo ' use --enable-cookies'
echo
echo ' If you are using bromium as a privacy tool'
echo ' then you may want to consider changing your'
echo ' default search provider. See'
echo ' https://stackoverflow.com/a/50888866'
echo
echo ' --enable-cookies - do not run in incognito mode'
echo
echo ' --userdir $DIR - run from a given user directory. This'
echo ' can be used to prepare a specific'
echo ' configuration for a specific application'
echo ' and then use that directory only for that'
echo ' application.'
echo ' When run with --userdir, cookies will'
echo ' be *enabled*.'
echo
echo ' How to prepara a special userdir:'
echo
echo ' 1. terminate all chromium browser'
echo ' 2. move your original chromium configuration to the side'
echo ' `mv ~/.config/chromium ~/.config/chromium.your-original-config`'
echo ' 3. start chromium'
echo ' 4. configure whatever you need'
echo ' 5. terminate chromium'
echo ' 6. move the config to the side'
echo ' `mv ~/.config/chromium ~/.config/chromium.my-special-config`'
echo ' 7. restore your original config'
echo ' `mv ~/.config/chromium.your-original-config ~/.config/chromium`'
echo ' 8. now you can use your special config with bromium'
echo ' `bromium --userdir ~/.config/chromium.my-special-config $SOME_APPLICATION_URL`'
echo
exit 1
}
# TODO: change theme: https://unix.stackexchange.com/questions/14129/gtk-enable-set-dark-theme-on-a-per-application-basis
# defaults
incognito_option="--incognito"
temp_profile_option="--temp-profile"
while true; do
case "$1" in
--help) help ;;
--enable-cookies) incognito_option="" ;;
--userdir) shift; userdir="$1" ;;
*) break ;;
esac
shift
done
if [ "$userdir" ]; then
user_or_tmp_dir="$userdir"
temp_profile_option=""
else
tmp_user_dir=$( mktemp -d /tmp/bromium.XXXX )
user_or_tmp_dir="$tmp_user_dir"
temp_profile_option="--temp-profile"
fi
# see http://peter.sh/experiments/chromium-command-line-switches/ for options
# $1 = URL and/or furher options
if [ "$1" ]; then
chromium --user-data-dir="$user_or_tmp_dir" \
$temp_profile_option \
--password-store=basic \
--disable-notifications \
$incognito_option \
"$@"
else
chromium --user-data-dir="$user_or_tmp_dir" \
$temp_profile_option \
--password-store=basic \
--disable-notifications \
$incognito_option \
"about:blank"
fi
# be really sure that "$tmp_user_dir" contains a correct tmpdir
# before rm -rf /* or such
#
if [[ "$tmp_user_dir" =~ /tmp/bromium ]]; then
rm -r "$tmp_user_dir"
elif [ "$userdir" ]; then
# if userdir was set then do nothing
true
else
echo "hae? $tmp_user_dir"
fi