-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfirefox
executable file
·135 lines (116 loc) · 4.05 KB
/
firefox
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
#!/bin/bash
#*****************************************************************
# ffox_profile_tools - equk.co.uk
#*****************************************************************
#
# This script was created to simplify and standardize firefox configuration
# across profiles.
#
# 19-05-2015 - initial script with tweaks
# ref: https://equk.co.uk/2015/05/19/firefox-scripts/
# 06-06-2015 - disable pocket (bundled with firefox)
# ----------------------------------------------------------------
# enable OffMainThreadCompositing
# added new tweaks ref: fingerprinting
# 2018 enabled tracking protection globally
# enabled always send DoNotTrack
# 08-09-2018 added userChrome.css
# added style - bookmark item spacing
# added style - move find bar to top
# 09-09-2018 added style - adwaita folder icon
# 11-09-2018 added style - find dropdown on right
# 25-09-2018 added style - gtk folder icon
#
# License: MIT (LICENSE file should be included with script)
#*****************************************************************
## variables
profile_name=${0##*/}
profile_folder="$HOME/.ffox_profiles/$profile_name"
##
SCRIPT_P=${0%/*}
ffox_bin="/usr/bin/firefox"
ffox_prefs="$SCRIPT_P/ffox_data/def_prefs.js"
ffox_userChrome="$SCRIPT_P/ffox_data/userChrome.css"
#*****************************************************************
# color / colour
blue="\033[1;34m"
green="\033[1;32m"
red="\033[1;31m"
bold="\033[1;37m"
reset="\033[0m"
# CLI feedback
cl_error="[$red ERROR $reset]"
gplus="[$green+$reset]"
bplus="[$blue+$reset]"
# Check if running within X Window Session
if [ "x$DISPLAY" = "x" ]; then
echo "must be run within the X Window System." >&2
echo "Exiting." >&2
exit 1
fi
# Check for root ( quit if root :x )
if [ $(whoami) = "root" ]; then
echo -e "$cl_error do not run this script as root"
exit 1
fi
# Check if user namespaces is enabled (for sandbox)
# Note: this is to enforce user namespaces for sandbox
if [[ ! (-r /proc/sys/kernel/unprivileged_userns_clone && $(</proc/sys/kernel/unprivileged_userns_clone) == 1 && -n $(zcat /proc/config.gz | grep CONFIG_USER_NS=y)) ]]; then
echo "User namespaces are not detected as enabled on your system, this is required for sandbox"
exit 1
fi
# Quit if ffox_prefs doesn't exist
if [[ ! -e $ffox_prefs ]]; then
echo -e "$cl_error $ffox_prefs not found"
notify-send -i dialog-error "$profile_name" "ERROR: $ffox_prefs not found"
exit 1
fi
# Quit if ffox_userChrome doesn't exist
if [[ ! -e $ffox_userChrome ]]; then
echo -e "$cl_error $ffox_userChrome not found"
notify-send -i dialog-error "$profile_name" "ERROR: $ffox_userChrome not found"
exit 1
fi
# Create profile directory if it doesn't exist
if [[ ! -e $profile_folder ]]; then
mkdir -p $profile_folder
fi
function copy() {
if [ -f $1 ]; then
ORIGIN=$1
DESTINATION=$2
if [ -a "$DESTINATION" ]; then
if diff "$ORIGIN" "$DESTINATION" >/dev/null; then
echo -e " $bplus $DESTINATION already up to date"
return 2
fi
while true; do
echo -e " $gplus updating file $DESTINATION"
cp "$ORIGIN" "$DESTINATION"
return 2
done
else
echo -e " $gplus Copying $ORIGIN"
cp "$ORIGIN" "$DESTINATION"
fi
else
echo -e " $cl_error '$1' does not exist"
fi
}
# Copy custom preferences if none exist
if [[ ! -e $profile_folder/prefs.js ]]; then
cp $ffox_prefs $profile_folder/prefs.js
fi
## Append prefs.js to update settings
if [ -f $profile_folder/prefs.js ]; then
echo -e " $gplus updating $profile_folder/prefs.js"
cat $ffox_prefs >>$profile_folder/prefs.js
fi
# Copy custom userChrome style overrides if required
# (works for updates to userChrome.css)
if [[ ! -e $profile_folder/chrome ]]; then
mkdir -p $profile_folder/chrome
fi
copy $ffox_userChrome $profile_folder/chrome/userChrome.css
# Execute firefox
exec $ffox_bin --profile "$profile_folder" "$@"