-
Notifications
You must be signed in to change notification settings - Fork 618
/
tweaks.sh
executable file
·372 lines (329 loc) · 17.8 KB
/
tweaks.sh
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
#! /usr/bin/env bash
# WARNING: Please make this shell not working-directory dependant, for example
# instead of using 'ls blabla', use 'ls "${REPO_DIR}/blabla"'
#
# WARNING: Don't use "cd" in this shell, use it in a subshell instead,
# for example ( cd blabla && do_blabla ) or $( cd .. && do_blabla )
#
# SUGGESTION: Please don't put any dependency installation here
###############################################################################
# VARIABLES & HELP #
###############################################################################
readonly REPO_DIR="$(dirname "$(readlink -m "${0}")")"
source "${REPO_DIR}/libs/lib-install.sh"
# Customization, default values
colors=("${COLOR_VARIANTS[@]}")
opacities=("${OPACITY_VARIANTS[@]}")
# Firefox values
adaptive=''
theme_name="$THEME_NAME"
firefoxtheme="$THEME_NAME"
left_button="3"
right_button="3"
usage() {
# Please specify their default value manually, some of them are come from _variables.scss
# You also have to check and update them regurally
helpify_title
helpify "-o, --opacity" "[$(IFS='|'; echo "${OPACITY_VARIANTS[*]}")]" " Set '${THEME_NAME}' GDM/Flatpak theme opacity variants" "Default is 'normal'"
helpify "-c, --color" "[$(IFS='|'; echo "${COMMAND_COLOR_VARIANTS[*]}")]" " Set '${THEME_NAME}' GDM/Flatpak theme color variants" "Default is 'light'"
helpify "-t, --theme" "[$(IFS='|'; echo "${THEME_VARIANTS[*]}")]" " Set '${THEME_NAME}' GDM/Flatpak theme accent color" "Default is BigSur-like theme"
helpify "-s, --scheme" "[$(IFS='|'; echo "${SCHEME_VARIANTS[*]}")]" " Set '${THEME_NAME}' GDM/Flatpak theme colorscheme style" "Default is 'standard'"
helpify "" "" "Tweaks for GDM theme" "options"
sec_title "-g, --gdm" "" " Without options default GDM theme will install..." ""
sec_helpify "1. -i, -icon" "[$(IFS='|'; echo "${ICON_VARIANTS[*]}")]" " Set GDM panel 'Activities' icon" "Default is 'standard'"
sec_helpify "2. -b, -background" "[default|blank|IMAGE_PATH]" " Set GDM background image" "Default is BigSur-like wallpaper"
sec_helpify "3. -p, -panelopacity" "[$(IFS='|'; echo "${PANEL_OPACITY_VARIANTS[*]}")]" " Set GDM panel transparency" "Default is 15%"
sec_helpify "4. -h, -panelheight" "[$(IFS='|'; echo "${PANEL_SIZE_VARIANTS[*]}")]" " Set GDM panel height size" "Default is 32px"
sec_helpify "5. -sf, -smallerfont" "" " Set GDM font size to smaller (10pt)" "Default is 11pt"
sec_helpify "6. -nd, -nodarken" "" " Don't darken '${THEME_NAME}' GDM theme background image" ""
sec_helpify "7. -nb, -noblur" "" " Don't blur '${THEME_NAME}' GDM theme background image" ""
helpify "" "" "Tweaks for firefox" "options"
sec_title "-f, --firefox" " [(monterey|flat)|alt|(darker|adaptive)]" " Without options default WhiteSur theme will install..." " Options:"
sec_helpify "1. monterey" " [3+3|3+4|3+5|4+3|4+4|4+5|5+3|5+4|5+5]" " Topbar buttons number: 'a+b'" " a: left side buttons number, b: right side buttons number"
sec_helpify "2. flat" " Monterey alt version" "" " Flat round tabs..."
sec_helpify "3. alt" " Alt windows button version" "" " Alt windows button style like gtk theme"
sec_helpify "4. darker" " Darker Firefox theme version" "" " Darker Firefox theme version"
sec_helpify "5. nord" " Nord Firefox colorscheme version" "" " Nord Firefox colorscheme version"
sec_helpify "6. adaptive" " Adaptive color version" " You need install adaptive-tab-bar-colour plugin first" " https://addons.mozilla.org/firefox/addon/adaptive-tab-bar-colour/"
helpify "-e, --edit-firefox" "[(monterey|flat)|alt|(darker|adaptive)]" " Edit '${THEME_NAME}' theme for Firefox settings and also connect the theme to the current Firefox profiles" ""
helpify "" "" "Others" "options"
sec_title "-F, --flatpak" "Support options: [-o, -c, -t...]" " Connect '${THEME_NAME}' theme to Flatpak" "Without options will only install default themes"
sec_helpify "1. -o, --opacity" "[$(IFS='|'; echo "${OPACITY_VARIANTS[*]}")]" " Set '${THEME_NAME}' flatpak theme opacity variants" "Default is 'normal'"
sec_helpify "2. -c, --color" "[$(IFS='|'; echo "${COLOR_VARIANTS[*]}")]" " Set '${THEME_NAME}' flatpak theme color variants" "Default is 'light'"
sec_helpify "3. -t, --theme" "[$(IFS='|'; echo "${THEME_VARIANTS[*]}")]" " Set '${THEME_NAME}' flatpak theme accent color" "Default is BigSur-like theme"
sec_helpify "4. -s, --scheme" "[$(IFS='|'; echo "${SCHEME_VARIANTS[*]}")]" " Set '${THEME_NAME}' flatpak theme colorscheme style" "Default is 'standard'"
#helpify "-s, --snap" "" " Connect '${THEME_NAME}' theme the currently installed snap apps" ""
helpify "-d, --dash-to-dock" "" " Fixed Dash to Dock theme issue" ""
helpify "-r, --remove, --revert" "" " Revert to the original themes, do the opposite things of install and connect" ""
helpify "--silent-mode" "" " Meant for developers: ignore any confirm prompt and params become more strict" ""
helpify "-h, --help" "" " Show this help" ""
}
gdm_info() {
if [[ "${gdm}" == "false" ]]; then
prompt -e "Oops... there's nothing to tweak. this option '${1}' only works for GDM theme! ..."
prompt -i "HINT: Run ./tweaks.sh -h for help!... \n"
fi
}
###############################################################################
# MAIN #
###############################################################################
#-----------------------------PARSE ARGUMENTS---------------------------------#
echo
while [[ $# -gt 0 ]]; do
# Don't show any dialog here. Let this loop checks for errors or shows help
# We can only show dialogs when there's no error and no -r parameter
#
# * shift for parameters that have no value
# * shift 2 for parameter that have a value
#
# Please don't exit any error here if possible. Let it show all error warnings
# at once
case "${1}" in
# Parameters that don't require value
-r|--remove|--revert)
uninstall='true'; shift ;;
--silent-mode)
full_sudo "${1}"; silent_mode='true'; shift ;;
-h|--help)
need_help="true"; shift ;;
-f|--firefox|-e|--edit-firefox)
case "${1}" in
-f|--firefox)
firefox="true" ;;
-e|--edit-firefox)
edit_firefox="true" ;;
esac
for variant in "${@}"; do
case "${variant}" in
default)
firefoxtheme="WhiteSur"
shift ;;
monterey)
firefoxtheme="Monterey"
theme_name="Monterey"
shift
for button in "${@}"; do
case "${button}" in
3+3)
left_button="3"
right_button="3"
shift ;;
3+4)
left_button="3"
right_button="4"
shift ;;
3+5)
left_button="3"
right_button="5"
shift ;;
4+3)
left_button="4"
right_button="3"
shift ;;
4+4)
left_button="4"
right_button="4"
shift ;;
4+5)
left_button="4"
right_button="5"
shift ;;
5+3)
left_button="5"
right_button="3"
shift ;;
5+4)
left_button="5"
right_button="4"
shift ;;
5+5)
left_button="5"
right_button="5"
shift ;;
esac
done
prompt -s "Left side topbar button number: $left_button, right side topbar button number: $right_button.\n" ;;
flat)
firefoxtheme="Flat"
theme_name="Monterey"
shift ;;
alt)
window="alt"
prompt -i "Alt windows button version...\n"
shift ;;
darker)
darker="-darker"
prompt -i "Darker Firefox theme version...\n"
shift ;;
nord)
colorscheme="-nord"
prompt -i "Nord Firefox colorscheme version...\n"
shift ;;
adaptive)
adaptive="-adaptive"
prompt -i "Firefox adaptive color version...\n"
prompt -w "You need install adaptive-tab-bar-colour plugin first: https://addons.mozilla.org/firefox/addon/adaptive-tab-bar-colour/\n"
shift ;;
esac
done
if ! has_command firefox && ! has_command firefox-bin && ! has_flatpak_app org.mozilla.firefox && ! has_snap_app firefox && ! has_command firefox-developer-edition; then
prompt -e "'${1}' ERROR: There's no Firefox installed in your system"
has_any_error="true"
elif [[ ! -d "${FIREFOX_DIR_HOME}" && ! -d "${FIREFOX_FLATPAK_DIR_HOME}" && ! -d "${FIREFOX_SNAP_DIR_HOME}" ]]; then
prompt -e "'${1}' ERROR: Firefox is installed but not yet initialized."
prompt -w "'${1}': Don't forget to close it after you run/initialize it"
has_any_error="true"
elif pidof "firefox" &> /dev/null || pidof "firefox-bin" &> /dev/null; then
prompt -e "'${1}' ERROR: Firefox is running, please close it"
has_any_error="true"
fi; shift ;;
-g|--gdm)
gdm="true"; full_sudo "${1}"
showapps_normal="true" # use normal showapps icon
background="default"
shift
for variant in "${@}"; do
case "${variant}" in
-i|-icon)
activities_icon="true";
check_param "${1}" "${1}" "${2}" "must" "must" "must" && shift 2 || shift ;;
-b|-background)
check_param "${1}" "${1}" "${2}" "must" "must" "must" "false" && shift 2 || shift ;;
-p|-panelopacity)
check_param "${1}" "${1}" "${2}" "optional" "optional" "optional" && shift 2 || shift ;;
-h|-panelheight)
check_param "${1}" "${1}" "${2}" "optional" "optional" "optional" && shift 2 || shift ;;
-nd|-nodarken)
gdm_info ${1}
no_darken="true"; shift ;;
-nb|-noblur)
gdm_info ${1}
no_blur="true"; shift ;;
-sf|-smallerfont)
smaller_font="true"; shift ;;
esac
done
if ! has_command gdm && ! has_command gdm3 && [[ ! -e /usr/sbin/gdm3 ]]; then
prompt -e "'${1}' ERROR: There's no GDM installed in your system"
has_any_error="true"
fi ;;
-F|--flatpak)
flatpak="true"; signal_exit
if ! has_command flatpak; then
prompt -e "'${1}' ERROR: There's no Flatpak installed in your system"
has_any_error="true"
fi; shift ;;
# -s|--snap)
# snap="true";
# if ! has_command snap; then
# prompt -e "'${1}' ERROR: There's no Snap installed in your system"
# has_any_error="true"
# fi; shift ;;
-d|--dash-to-dock)
if [[ ! -d "${DASH_TO_DOCK_DIR_HOME}" && ! -d "${DASH_TO_DOCK_DIR_ROOT}" ]]; then
prompt -e "'${1}' ERROR: There's no Dash to Dock installed in your system"
has_any_error="true"
else
dash_to_dock="true"
fi; shift ;;
-o|--opacity)
check_param "${1}" "${1}" "${2}" "not-at-all" "must" "must" && shift 2 || shift ;;
-c|--color)
check_param "${1}" "${1}" "${2}" "not-at-all" "must" "must" && shift 2 || shift ;;
-t|--theme)
check_param "${1}" "${1}" "${2}" "not-at-all" "must" "must" && shift 2 || shift ;;
-s|--scheme)
check_param "${1}" "${1}" "${2}" "not-at-all" "must" "must" && shift 2 || shift ;;
*)
prompt -e "ERROR: Unrecognized tweak option '${1}'."
has_any_error="true"; shift ;;
esac
done
finalize_argument_parsing
#---------------------------START INSTALL THEMES-------------------------------#
if [[ "${uninstall}" == 'true' ]]; then
prompt -w "REMOVAL: Non file-related parameters will be ignored. \n"
if [[ "${gdm}" == 'true' ]]; then
if [[ "${firefox}" == 'true' || "${edit_firefox}" == 'true' || "${flatpak}" == 'true' || "${snap}" == 'true' || "${dash_to_dock}" == 'true' ]]; then
prompt -e "Do not run this option with '--gdm' \n"
else
prompt -i "Removing '${name}' GDM theme... \n"
revert_gdm_theme
prompt -s "Done! '${name}' GDM theme has been removed. \n"
fi
fi
# if [[ "${snap}" == 'true' && "${gdm}" != 'true' ]]; then
# prompt -i "Disconnecting '${name}' theme from your installed snap apps... \n"
# disconnect_snap
# prompt -s "Done! '${name}' theme has been disconnected from your snap apps.\n"
# fi
if [[ "${flatpak}" == 'true' && "${gdm}" != 'true' ]]; then
prompt -i "Disconnecting '${name}' theme from your Flatpak... \n"
disconnect_flatpak
prompt -s "Done! '${name}' theme has been disconnected from your Flatpak. \n"
fi
if [[ "${dash_to_dock}" == 'true' && "${gdm}" != 'true' ]]; then
prompt -i "Revert Dash to Dock theme... \n"
revert_dash_to_dock_theme
prompt -s "Done! Dash to Dock theme has reverted to default. \n"
fi
if [[ "${firefox}" == 'true' && "${gdm}" != 'true' ]]; then
prompt -i "Removing '${firefoxtheme}' Firefox theme... \n"
remove_firefox_theme
prompt -s "Done! '${firefoxtheme}' Firefox theme has been removed. \n"
fi
else
show_needed_dialogs; customize_theme
if [[ "${gdm}" == 'true' ]]; then
if [[ "${firefox}" == 'true' || "${edit_firefox}" == 'true' || "${flatpak}" == 'true' || "${snap}" == 'true' || "${dash_to_dock}" == 'true' ]]; then
prompt -e "Do not run this option with '--gdm' \n"
else
prompt -i "Installing '${name}' GDM theme... \n"
install_gdm_theme
prompt -s "Done! '${name}' GDM theme has been installed. \n"
fi
fi
# if [[ "${snap}" == 'true' && "${gdm}" != 'true' ]]; then
# prompt -i "Connecting '${name}' theme to your installed snap apps... \n"
# connect_snap
# prompt -s "Done! '${name}' theme has been connected to your snap apps. \n"
# fi
if [[ "${flatpak}" == 'true' && "${gdm}" != 'true' ]]; then
prompt -i "Connecting '${name}' themes to your Flatpak... \n"
prompt -w "Without options it will only install default themes\n"
customize_theme; avoid_variant_duplicates; connect_flatpak
prompt -s "Done! '${name}' theme has been connected to your Flatpak. \n"
fi
if [[ "${dash_to_dock}" == 'true' && "${gdm}" != 'true' ]]; then
prompt -i "Fix Dash to Dock theme issue... \n"
fix_dash_to_dock
prompt -s "Done! '${name}' Dash to Dock theme has been fixed. \n"
prompt -w "DASH TO DOCK: You may need to logout to take effect. \n"
fi
if [[ "${firefox}" == 'true' || "${edit_firefox}" == 'true' ]]; then
if [[ "${darker}" == '-darker' && "${adaptive}" == '-adaptive' ]]; then
prompt -w "FIREFOX: You can't use 'adaptive' and 'darker' at the same time. \n"
prompt -i "FIREFOX: Setting to adaptive only... \n"
darker=''
fi
if [[ "${firefox}" == 'true' && "${gdm}" != 'true' ]]; then
prompt -i "Installing '${firefoxtheme}' Firefox theme... \n"
install_firefox_theme
prompt -s "Done! '${firefoxtheme}' Firefox theme has been installed. \n"
fi
if [[ "${edit_firefox}" == 'true' && "${gdm}" != 'true' ]]; then
prompt -i "Editing '${firefoxtheme}' Firefox theme preferences... \n"
edit_firefox_theme_prefs
prompt -s "Done! '${firefoxtheme}' Firefox theme preferences has been edited. \n"
fi
if [[ "${gdm}" == "false" ]]; then
prompt -w "FIREFOX: Please go to [Firefox menu] > [Customize...], and customize your Firefox to make it work. Move your 'new tab' button to the titlebar instead of tab-switcher. \n"
prompt -i "FIREFOX: Anyway, you can also edit 'userChrome.css' and 'customChrome.css' later in your Firefox profile directory. \n"
fi
fi
fi
if [[ "${firefox}" == "false" && "${edit_firefox}" == "false" && "${flatpak}" == "false" && "${gdm}" == "false" && "${dash_to_dock}" == "false" && "${libadwaita}" == "false" ]]; then
prompt -e "Oops... there's nothing to tweak..."
prompt -i "HINT: Don't forget to define which component to tweak, e.g. '--gdm'"
prompt -i "HINT: Run ./tweaks.sh -h for help!... \n"
fi