-
Notifications
You must be signed in to change notification settings - Fork 39
/
layoutmanager.sh
executable file
·316 lines (292 loc) · 17.7 KB
/
layoutmanager.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
#!/bin/bash
#################################################################
# #
# GNOME Layout Manager #
# Copyright (C) 2017 Bill Mavromatis #
# Licensed under the GNU General Public License 3.0 #
# #
# https://github.com/bill-mavromatis/gnome-layout-manager #
# #
#################################################################
# Check tools availability (zenity, wget, unzip)
ZENITY=true
command -v zenity >/dev/null 2>&1 || { ZENITY=false; }
command -v unzip >/dev/null 2>&1 || {
if [[ $ZENITY == true ]]; then
zenity --error --text="Please install unzip!"
else
echo -e "\e[31m\e[1mPlease install unzip!\e[0m"
fi;
exit 1;
}
command -v wget >/dev/null 2>&1 || {
if [[ $ZENITY == true ]]; then
zenity --error --text="Please install wget!"
else
echo -e "\e[31m\e[1mPlease install wget!\e[0m"
fi;
exit 1;
}
command -v curl >/dev/null 2>&1 || {
if [[ $ZENITY == true ]]; then
zenity --error --text="Please install curl!"
else
echo -e "\e[31m\e[1mPlease install curl!\e[0m"
fi;
exit 1;
}
# Set gnome shell extension site URL
GNOME_SITE="https://extensions.gnome.org"
# Get current GNOME version (major and minor only)
GNOME_VERSION="$(DISPLAY=":0" gnome-shell --version | tr -cd "0-9." | cut -d'.' -f1,2)"
# Default installation path for default mode (user mode, no need of sudo)
EXTENSION_PATH="$HOME/.local/share/gnome-shell/extensions"
PICTURES_FOLDER=$(xdg-user-dir PICTURES)
dirs=( $(find /usr/share/gnome-shell/extensions $HOME/.local/share/gnome-shell/extensions -maxdepth 1 -type d -printf '%P\n') )
declare -a EXT_UNITY=('[email protected]' '[email protected]' '[email protected]' '[email protected]' '[email protected]' 'gnomeGlobalAppMenu@lestcape' '[email protected]' '[email protected]' '[email protected]')
declare -a EXT_WINDOWS=('[email protected]' '[email protected]' '[email protected]' '[email protected]' '[email protected]' '[email protected]')
declare -a EXT_MACOS=('[email protected]' '[email protected]' '[email protected]' '[email protected]' '[email protected]')
LAYOUT=""
# If no arguments given, show help
if [[ ${#} -eq 0 && $ZENITY == false ]]; then
echo "Downloads and installs GNOME extensions from Gnome Shell Extensions site https://extensions.gnome.org/"
echo "Parameters are :"
echo " --save Save current settings (all gsettings in /org/gnome/) to ~/.config/gnome-layout-manager/"
echo " --load Load settings (Please save your work as this may crash your gnome-shell)"
echo " --windows Windows 10 layout (panel and no topbar)"
echo " --macos macOS layout (bottom dock /w autohide + topbar)"
echo " --unity Unity layout (left dock + topbar)"
echo " --vanilla GNOME Vanilla (Adwaita theme + disable all extensions)"
exit 1
else
if [[ $# -eq 0 ]]; then #if no argument given and zenity installed, start zenity
ANSWER=$(zenity --list --width=800 --height=400 --text "Please select the layout you want" --column "Option" --column "Details" \
"Save" "Save current settings (all gsettings in /org/gnome/) to ~/.config/gnome-layout-manager/"\
"Load" "Load settings (Please save your work as this may crash your gnome-shell)"\
" " " "\
"Unity layout" "(left dock + topbar)" \
"GNOME Vanilla" "(Adwaita theme + disable all extensions)" \
"macOS layout" "(bottom dock + topbar)" \
"Windows 10 layout" "(bottom panel and no topbar)")
case $ANSWER in
"Save") declare -a arr=(); shift; LAYOUT="save"; shift; ;;
"Load") declare -a arr=(); shift; LAYOUT="load"; shift; ;;
"Unity layout") declare -a arr=( "${EXT_UNITY[@]}" ); shift; LAYOUT="unity"; shift; ;;
"GNOME Vanilla") declare -a arr=(); LAYOUT="vanilla"; shift; ;;
"macOS layout") declare -a arr=( "${EXT_MACOS[@]}" ); LAYOUT="macos"; shift; ;;
"Windows 10 layout") declare -a arr=( "${EXT_WINDOWS[@]}" ); LAYOUT="windows"; shift; ;;
*) exit 1
esac
fi
fi
# Read arguments (if any)
while test ${#} -gt 0
do
case $1 in
--save) declare -a arr=(); LAYOUT="save"; shift; ;;
--load) declare -a arr=(); LAYOUT="load"; shift; ;;
--windows) declare -a arr=( "${EXT_WINDOWS[@]}" ); LAYOUT="windows"; shift; ;;
--macos) declare -a arr=( "${EXT_MACOS[@]}" ); LAYOUT="macos"; shift; ;;
--unity) declare -a arr=( "${EXT_UNITY[@]}" ); shift; LAYOUT="unity"; shift; ;;
--vanilla) declare -a arr=(); shift; LAYOUT="vanilla"; shift; ;;
*) echo "Unknown parameter $1"; shift; ;;
esac
done
#Disable all current extensions
if [[ $LAYOUT == "windows" || $LAYOUT == "macos" || $LAYOUT == "unity" || $LAYOUT == "vanilla" ]]; then
echo "Layout selected: $LAYOUT"
echo "Disabling all current extensions"
gsettings set org.gnome.shell enabled-extensions []
[[ -e ~/.local/share/themes ]] || mkdir -p ~/.local/share/themes #Create theme and icon directory
[[ -e ~/.local/share/icons ]] || mkdir -p ~/.local/share/icons
fi
#install all extensions from array
if [[ $LAYOUT == "windows" || $LAYOUT == "macos" || $LAYOUT == "unity" ]]; then
for EXT_UUID in "${arr[@]}"
do
# if installed, skip
if [[ " ${dirs[*]} " == *" $EXT_UUID "* ]]; then
echo "Extension ${EXT_UUID} is already installed. Skipping."
else
if [[ ${EXT_UUID} == "remove-dropdown-arrows" ]]; then #For Dropdown Arrows fake 3.22
GNOME_VERSION="3.22"
fi
TMP_ZIP=$(mktemp -t ext-XXXXXXXX.zip)
JSON="${GNOME_SITE}/extension-info/?uuid=${EXT_UUID}&shell_version=${GNOME_VERSION}"
EXTENSION_URL=${GNOME_SITE}$(curl -s "${JSON}" | sed -e 's/^.*download_url[\": ]*\([^\"]*\).*$/\1/')
# download extension archive
if [[ ${EXT_UUID} == "gnomeGlobalAppMenu@lestcape" ]]; then #For Global Menu use GitHub instead
EXTENSION_URL="https://github.com/bill-mavromatis/Gnome-Global-AppMenu/archive/master.zip"
wget --header='Accept-Encoding:none' -O "${TMP_ZIP}" "${EXTENSION_URL}"
# unzip extension to installation folder
mkdir -p "${EXTENSION_PATH}"/"${EXT_UUID}"
unzip -o "${TMP_ZIP}" -d /tmp/
cp -R "/tmp/Gnome-Global-AppMenu-master/gnomeGlobalAppMenu@lestcape/" -d "${EXTENSION_PATH}"
chmod +r "${EXTENSION_PATH}"/"${EXT_UUID}"/*
elif [[ ${EXT_UUID} == "[email protected]" ]]; then #For Pixel Saver use GitHub instead
EXTENSION_URL="https://github.com/bill-mavromatis/pixel-saver/archive/master.zip"
wget --header='Accept-Encoding:none' -O "${TMP_ZIP}" "${EXTENSION_URL}"
# unzip extension to installation folder
mkdir -p "${EXTENSION_PATH}"/"${EXT_UUID}"
unzip -o "${TMP_ZIP}" -d /tmp/
cp -R "/tmp/pixel-saver-master/[email protected]/" -d "${EXTENSION_PATH}"
chmod +r "${EXTENSION_PATH}"/"${EXT_UUID}"/*
else #for everything else use GNOME site
wget --header='Accept-Encoding:none' -O "${TMP_ZIP}" "${EXTENSION_URL}"
# unzip extension to installation folder
mkdir -p "${EXTENSION_PATH}"/"${EXT_UUID}"
unzip -oq "${TMP_ZIP}" -d "${EXTENSION_PATH}"/"${EXT_UUID}"
chmod +r "${EXTENSION_PATH}"/"${EXT_UUID}"/*
fi
fi
rm -f "${TMP_ZIP}" #remove temp files
done
fi
#Move schema files to local dir and compile
[[ -e ~/.local/share/glib-2.0/schemas/ ]] || mkdir -p ~/.local/share/glib-2.0/schemas/
export XDG_DATA_DIRS=~/.local/share:/usr/share
find ~/.local/share/gnome-shell/extensions/ -name *gschema.xml -exec ln {} -sfn ~/.local/share/glib-2.0/schemas/ \;
glib-compile-schemas ~/.local/share/glib-2.0/schemas/
#apply layout
case $LAYOUT in
windows)
gsettings set org.gnome.shell enabled-extensions "['[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]']"
if [[ -e ~/.themes/Windows-10-master ]]; then
mv -v ~/.themes/Windows-10-master/ ~/.local/share/themes/Windows-10-master/ #move old files
elif [[ ! -d ~/.local/share/themes/Windows-10-master ]]; then
cd /tmp && wget -N https://github.com/B00merang-Project/Windows-10/archive/master.zip && unzip -o master.zip -d ~/.local/share/themes/
fi
if [[ ! -f "$PICTURES_FOLDER"/wallpaper-windows.png ]]; then
cd /tmp && wget https://static.pexels.com/photos/337685/pexels-photo-337685.png && mv pexels-photo-337685.png "$PICTURES_FOLDER"/wallpaper-windows.png
fi
gsettings set org.gnome.desktop.background picture-uri file:///"$PICTURES_FOLDER"/wallpaper-windows.png
if [[ ! -d ~/.local/share/icons/Windows-10-Icons-master ]]; then
cd /tmp && wget -N https://github.com/B00merang-Project/Windows-10-Icons/archive/master.zip && unzip -o master.zip -d ~/.local/share/icons/
fi
gsettings set org.gnome.shell.extensions.topicons tray-pos 'Center'
gsettings set org.gnome.shell.extensions.topicons tray-order '2'
gsettings set org.gnome.shell.extensions.dash-to-panel panel-position 'BOTTOM'
gsettings set org.gnome.shell.extensions.dash-to-panel location-clock 'STATUSRIGHT'
gsettings set org.gnome.shell.extensions.gnomenu disable-activities-hotcorner 'true'
gsettings set org.gnome.shell.extensions.gnomenu hide-panel-view 'true'
gsettings set org.gnome.shell.extensions.gnomenu hide-panel-apps 'true'
gsettings set org.gnome.shell.extensions.gnomenu panel-menu-label-text ["''"]
gsettings set org.gnome.shell.extensions.gnomenu disable-panel-menu-keyboard 'true'
gsettings set org.gnome.shell.extensions.gnomenu hide-shortcuts 'true'
gsettings set org.gnome.shell.extensions.gnomenu hide-useroptions 'true'
gsettings set org.gnome.desktop.wm.preferences button-layout ':minimize,maximize,close'
gsettings set org.gnome.desktop.interface icon-theme "Windows-10-Icons-master"
gsettings set org.gnome.desktop.interface gtk-theme "Windows-10-master"
gsettings set org.gnome.shell.extensions.user-theme name "Windows-10-master"
gnome-shell --replace &>/dev/null & disown
zenity --info --width=500 --height=200 --text "Layout applied successfully.\nIf you are experiencing any issues, please restart gnome-shell."
;;
macos)
gsettings set org.gnome.shell enabled-extensions "['[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]']"
if [[ -e ~/.themes/Gnome-OSX-II-2-6-NT ]]; then
mv -v ~/.themes/Gnome-OSX-II-NT-2-6/ ~/.local/share/themes/Gnome-OSX-II-2-6-NT/ #move old files
elif [[ ! -d ~/.local/share/themes/nome-OSX-II-2-6-NT ]]; then
cd /tmp && wget https://dl.opendesktop.org/api/files/download/id/1494791955/Gnome-OSX-II-2-6-NT.tar.gz && tar -xvzf Gnome-OSX-II-2-6-NT.tar.gz -C ~/.local/share/themes/
fi
if [[ ! -f "$PICTURES_FOLDER"/wallpaper-macos.jpg ]]; then
cd /tmp && wget https://upload.wikimedia.org/wikipedia/commons/9/9b/Aurora_-_panoramio.jpg && mv Aurora_-_panoramio.jpg "$PICTURES_FOLDER"/wallpaper-macos.jpg
fi
gsettings set org.gnome.desktop.background picture-uri file:///"$PICTURES_FOLDER"/wallpaper-macos.jpg
if [[ ! -d ~/.local/share/icons/La-Capitaine ]]; then
cd /tmp && wget -N https://github.com/keeferrourke/la-capitaine-icon-theme/archive/master.zip && unzip -o master.zip -d ~/.local/share/icons && mv ~/.local/share/icons/la-capitaine-icon-theme-master ~/.local/share/icons/La-Capitaine
fi
if [[ -e ~/.themes/Human ]]; then
mv -v ~/.themes/Human/ ~/.local/share/themes/Human/ #move old files
elif [[ ! -d ~/.local/share/themes/Human ]]; then
cd /tmp && wget https://dl.opendesktop.org/api/files/download/id/1497836019/Human.zip && unzip -o Human.zip -d ~/.local/share/themes/
fi
gsettings set org.gnome.shell.extensions.dash-to-dock dock-position 'BOTTOM'
gsettings set org.gnome.shell.extensions.dash-to-dock intellihide 'false'
gsettings set org.gnome.shell.extensions.dash-to-dock extend-height 'false'
gsettings set org.gnome.shell.extensions.dash-to-dock background-opacity '0.4'
gsettings set org.gnome.shell.extensions.dash-to-dock background-color '#FFFFFF'
gsettings set org.gnome.shell.extensions.dash-to-dock dock-fixed 'true'
gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize'
gsettings set org.gnome.shell.extensions.dash-to-dock show-apps-at-top 'true'
gsettings set org.gnome.shell.extensions.dash-to-dock show-running 'true'
gsettings set org.gnome.shell.extensions.dash-to-dock apply-custom-theme 'false'
gsettings set org.gnome.desktop.wm.preferences button-layout 'close,minimize,maximize:'
gsettings set org.gnome.desktop.interface icon-theme "La-Capitaine"
gsettings set org.gnome.desktop.interface gtk-theme "Gnome-OSX-II-2-6-NT"
gsettings set org.gnome.shell.extensions.user-theme name "Human"
gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/ShellShowsAppMenu': <1>}"
gnome-shell --replace &>/dev/null & disown
zenity --info --width=500 --height=200 --text "Layout applied successfully.\nIf you are experiencing any issues, please restart gnome-shell."
;;
unity)
gsettings set org.gnome.shell enabled-extensions "['[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', 'gnomeGlobalAppMenu@lestcape']"
gsettings set org.gnome.shell.extensions.dash-to-dock dock-position 'LEFT'
gsettings set org.gnome.shell.extensions.dash-to-dock intellihide 'false'
gsettings set org.gnome.shell.extensions.dash-to-dock background-opacity '0.7'
gsettings set org.gnome.shell.extensions.dash-to-dock background-color '#2C001E'
gsettings set org.gnome.shell.extensions.dash-to-dock dock-fixed 'true'
gsettings set org.gnome.shell.extensions.dash-to-dock extend-height 'true'
gsettings set org.gnome.shell.extensions.dash-to-dock show-running 'true'
gsettings set org.gnome.shell.extensions.dash-to-dock show-apps-at-top 'true'
if [[ -e ~/.themes/United ]]; then
mv -v ~/.themes/United* ~/.local/share/themes/ #move old files
elif [[ ! -d ~/.local/share/themes/United ]]; then
cd /tmp && wget https://github.com/godlyranchdressing/United-GNOME/raw/master/United-Latest.tar.gz && tar -xvzf United-Latest.tar.gz -C ~/.local/share/themes/
fi
if [[ ! -f "$PICTURES_FOLDER"/wallpaper-united.png ]]; then
cd /tmp && wget https://raw.githubusercontent.com/godlyranchdressing/United-GNOME/master/Wallpaper.png && mv Wallpaper.png "$PICTURES_FOLDER"/wallpaper-united.png
fi
gsettings set org.gnome.desktop.background picture-uri file:///"$PICTURES_FOLDER"/wallpaper-united.png
if [[ ! -d ~/.local/share/icons/Humanity ]]; then
wget https://launchpad.net/ubuntu/+archive/primary/+files/humanity-icon-theme_0.6.13.tar.xz && tar --xz -xvf humanity-icon-theme_0.6.13.tar.xz -C /tmp/ && mv /tmp/humanity-icon-theme-0.6.13/* ~/.local/share/icons
fi
gsettings set org.gnome.desktop.interface icon-theme "Humanity"
gsettings set org.gnome.desktop.interface gtk-theme "United-Ubuntu"
gsettings set org.gnome.shell.extensions.user-theme name "United-Ubuntu"
gsettings set org.gnome.desktop.wm.preferences button-layout 'close,minimize,maximize:'
gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/ShellShowsAppMenu': <1>}"
gnome-shell --replace &>/dev/null & disown
zenity --info --width=500 --height=200 --text "Layout applied successfully.\nIf you are experiencing any issues, please restart gnome-shell."
;;
vanilla)
gsettings set org.gnome.desktop.interface gtk-theme "Adwaita"
gsettings set org.gnome.desktop.interface icon-theme "Adwaita"
gsettings set org.gnome.desktop.interface cursor-theme "Adwaita"
gsettings set org.gnome.desktop.wm.preferences button-layout ':minimize,maximize,close'
gsettings set org.gnome.desktop.background picture-uri file:///usr/share/backgrounds/gnome/adwaita-morning.jpg
gnome-shell --replace &>/dev/null & disown
zenity --info --width=500 --height=200 --text "Layout applied successfully.\nIf you are experiencing any issues, please restart gnome-shell."
;;
save)
[[ -e ~/.config/gnome-layout-manager ]] || mkdir ~/.config/gnome-layout-manager
#dconf dump /org/gnome/desktop/ > ~/.config/gnome-layout-manager/dconf.txt
#gsettings get org.gnome.shell enabled-extensions > ~/.config/gnome-layout-manager/extensions.txt
rm ~/.config/gnome-layout-manager/backup.txt #remove old file
set -x
for schema in $(gsettings list-schemas | grep 'org.gnome.shell\|org.gnome.desktop')
do
for key in $(gsettings list-keys $schema)
do
value="$(gsettings get $schema $key)"
echo gsettings set $schema $key $(printf '"')$value$(printf '"') >> ~/.config/gnome-layout-manager/backup.txt
done
done
set +x
if [[ $ZENITY == true && ${#} -ne 0 ]]; then
zenity --info --text "Layout saved in ~/.config/gnome-layout-manager/"
else
echo -e "Layout saved in ~/.config/gnome-layout-manager/"
fi;
;;
load)
#dconf load /org/gnome/desktop/ < ~/.config/gnome-layout-manager/dconf.txt
#gsettings set org.gnome.shell enabled-extensions "$(cat ~/.config/gnome-layout-manager/extensions.txt)"
bash -x ~/.config/gnome-layout-manager/backup.txt
gnome-shell --replace &>/dev/null & disown
if [[ $ZENITY == true && ${#} -ne 0 ]]; then
zenity --info --text "Layout loaded from ~/.config/gnome-layout-manager/"
else
echo -e "Layout loaded from ~/.config/gnome-layout-manager/"
fi;
;;
esac