Updated testspeed
[clearscm.git] / bin / impishgdm
1 #!/bin/bash
2
3 codename=$(cat /etc/os-release | grep UBUNTU_CODENAME | cut -d = -f 2)
4
5 if [ "$codename" == "impish" ]
6 then
7 source="/usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource"
8 else
9 echo "
10 ----------------------------------------
11 Sorry, Script is only for Ubuntu 21.10
12 Exiting...
13 ----------------------------------------"
14 exit 1
15 fi
16
17 pkg=$(dpkg -l | grep libglib2.0-dev >/dev/null && echo "yes" || echo "no")
18 if [ "$pkg" == "no" ]
19 then
20 echo "
21 -----------------------------------------------------------------------------------------------------
22 Sorry, the package 'libglib2.0-dev' is not installed. Install the package and then run this Script.
23 For now, Exiting...
24 -----------------------------------------------------------------------------------------------------"
25 exit 1
26 fi
27
28 ############################################################################################
29 case "$1" in ###############################################################################
30 ############################################################################################
31 --set)
32 ############################################################################################
33
34 if [ "$UID" != "0" ]
35 then
36 echo "This Script must be run with sudo"
37 exit 1
38 fi
39
40 echo "
41 -------------------------------------------------------------------------------------------------------
42 Please note that after setting login screen background,
43 >>>>>>>>> Reboot is highly recomonded to see the changes <<<<<<<<<<<<
44
45 Do you want to proceed now? [Yes/no] Type n to exit, or press enter to proceed.
46 -------------------------------------------------------------------------------------------------------"
47 read answer
48
49 if [ "$answer" == "n" ] || [ "$answer" == "N" ]
50 then
51 echo "Exiting..."
52 exit 1
53 fi
54
55 echo "
56 Please Choose any one number from below.
57 -------------
58 1. for Image
59 2. for Color
60 -------------"
61 read a
62
63 if [ -z $a ]
64 then
65 echo "Option is not selected.
66 Exiting..."
67 exit 1
68 fi
69
70 if [ "$a" == "1" ]
71 then
72 echo "Enter Image Path for Login Screen
73 ----------------------------------------------------
74 Example1: /usr/share/backgrounds/2.jpg
75 Example2: /usr/local/share/backgrounds/spaceship.png
76 Example3: /home/impish/Downloads/myBG.jpeg
77 ----------------------------------------------------"
78 read b
79
80 elif [ "$a" == "2" ]
81 then
82 echo "
83 Enter Hex Color Code for Login Screen (you may note down colors of your choice from this link https://www.color-hex.com/)
84 -------------------------------------------------------------------------------------------------------------------------
85 Example1: #00ff00
86 Example2: #fca
87 Example3: #456789
88 Example4: #123
89 Example5: #FF00FF
90 -------------------------------------------------------------------------------------------------------------------------"
91 read c
92 fi
93
94 if [ -z $b ] && [ -z $c ]
95 then
96 echo "Input is not Provided.
97 Exiting..."
98 exit 1
99 fi
100
101 if [ -z $c ]
102 then
103 color="#042320"
104 else
105 color="$c"
106 fi
107
108 if ! [ -z $c ]
109 then
110         if ! [[ $c =~ ^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$ ]]; then
111         echo "
112 ------------------------------------------------------------------------------------------------------------
113         Sorry it is not a valid Hex color, Please choose the valid HEX color first and then run this script.
114 ------------------------------------------------------------------------------------------------------------"
115         exit 1
116         fi
117 fi
118
119 if ! [ -z $b ]
120 then
121         if ! [ -e $b ]; then
122         echo "
123 ---------------------------------------------------------------------------------------------------
124 Image path you entered does not exist, script defined background color is going to be used for now.
125 Please notedown the correct file path of the Image and then run this script.
126 ---------------------------------------------------------------------------------------------------"
127         fi
128 fi
129
130 prefix="/org/gnome/shell/theme"
131 dest="/usr/local/share/gnome-shell/theme/impishgdm"
132
133 install -D /dev/null $dest/gdm.css
134 install -D /dev/null $dest/impishgdm.gresource.xml
135 install -d $dest/icons/scalable/actions
136
137 gresource extract $source $prefix/gdm.css > $dest/original.css
138 gresource extract $source $prefix/checkbox.svg > $dest/checkbox.svg
139 gresource extract $source $prefix/checkbox-off.svg > $dest/checkbox-off.svg
140 gresource extract $source $prefix/checkbox-focused.svg > $dest/checkbox-focused.svg
141 gresource extract $source $prefix/checkbox-off-focused.svg > $dest/checkbox-off-focused.svg
142 gresource extract $source $prefix/toggle-on.svg > $dest/toggle-on.svg
143 gresource extract $source $prefix/toggle-off.svg > $dest/toggle-off.svg
144 gresource extract $source $prefix/icons/scalable/actions/pointer-drag-symbolic.svg > $dest/icons/scalable/actions/pointer-drag-symbolic.svg
145 gresource extract $source $prefix/icons/scalable/actions/keyboard-enter-symbolic.svg > $dest/icons/scalable/actions/keyboard-enter-symbolic.svg
146 gresource extract $source $prefix/icons/scalable/actions/keyboard-hide-symbolic.svg > $dest/icons/scalable/actions/keyboard-hide-symbolic.svg
147 gresource extract $source $prefix/icons/scalable/actions/pointer-secondary-click-symbolic.svg > $dest/icons/scalable/actions/pointer-secondary-click-symbolic.svg
148 gresource extract $source $prefix/icons/scalable/actions/keyboard-shift-filled-symbolic.svg > $dest/icons/scalable/actions/keyboard-shift-filled-symbolic.svg
149 gresource extract $source $prefix/icons/scalable/actions/keyboard-caps-lock-filled-symbolic.svg > $dest/icons/scalable/actions/keyboard-caps-lock-filled-symbolic.svg
150 gresource extract $source $prefix/icons/scalable/actions/pointer-primary-click-symbolic.svg > $dest/icons/scalable/actions/pointer-primary-click-symbolic.svg
151 gresource extract $source $prefix/icons/scalable/actions/keyboard-layout-filled-symbolic.svg > $dest/icons/scalable/actions/keyboard-layout-filled-symbolic.svg
152 gresource extract $source $prefix/icons/scalable/actions/eye-not-looking-symbolic.svg > $dest/icons/scalable/actions/eye-not-looking-symbolic.svg
153 gresource extract $source $prefix/icons/scalable/actions/pointer-double-click-symbolic.svg > $dest/icons/scalable/actions/pointer-double-click-symbolic.svg
154 gresource extract $source $prefix/icons/scalable/actions/eye-open-negative-filled-symbolic.svg > $dest/icons/scalable/actions/eye-open-negative-filled-symbolic.svg
155
156 echo '@import url("resource:///org/gnome/shell/theme/original.css");
157   #lockDialogGroup {
158   background: '$color' url(file://'$b');
159   background-repeat: no-repeat;
160   background-size: cover;
161   background-position: center; }' > $dest/gdm.css
162
163 echo '<?xml version="1.0" encoding="UTF-8"?>
164 <gresources>
165   <gresource prefix="/org/gnome/shell/theme">
166     <file>original.css</file>
167     <file>gdm.css</file>
168     <file>toggle-off.svg</file>
169     <file>checkbox-off.svg</file>
170     <file>toggle-on.svg</file>
171     <file>checkbox-off-focused.svg</file>
172     <file>checkbox-focused.svg</file>
173     <file>checkbox.svg</file>
174     <file>icons/scalable/actions/pointer-drag-symbolic.svg</file>
175     <file>icons/scalable/actions/keyboard-enter-symbolic.svg</file>
176     <file>icons/scalable/actions/keyboard-hide-symbolic.svg</file>
177     <file>icons/scalable/actions/pointer-secondary-click-symbolic.svg</file>
178     <file>icons/scalable/actions/keyboard-shift-filled-symbolic.svg</file>
179     <file>icons/scalable/actions/keyboard-caps-lock-filled-symbolic.svg</file>
180     <file>icons/scalable/actions/pointer-primary-click-symbolic.svg</file>
181     <file>icons/scalable/actions/keyboard-layout-filled-symbolic.svg</file>
182     <file>icons/scalable/actions/eye-not-looking-symbolic.svg</file>
183     <file>icons/scalable/actions/pointer-double-click-symbolic.svg</file>
184     <file>icons/scalable/actions/eye-open-negative-filled-symbolic.svg</file>
185   </gresource>
186 </gresources>' > $dest/impishgdm.gresource.xml
187
188 cd $dest
189 glib-compile-resources impishgdm.gresource.xml
190 mv impishgdm.gresource ..
191 rm -r $dest
192 update-alternatives --quiet --install /usr/share/gnome-shell/gdm-theme.gresource gdm-theme.gresource /usr/local/share/gnome-shell/theme/impishgdm.gresource 0
193 update-alternatives --quiet --set gdm-theme.gresource /usr/local/share/gnome-shell/theme/impishgdm.gresource
194
195 check=$(update-alternatives --query gdm-theme.gresource | grep Value | grep /usr/local/share/gnome-shell/theme/impishgdm.gresource >/dev/null && echo "pass" || echo "fail")
196 if [ "$check" == "pass" ]
197 then
198 echo "
199                                                 ---------
200                                                 |Success|
201                                                 ---------"
202 else
203 echo Failure
204 exit 1
205 fi
206 ;;
207 ############################################################################################
208 --reset) ###################################################################################
209 ############################################################################################
210
211 if [ -e /usr/local/share/gnome-shell/theme/impishgdm.gresource ]
212 then
213 rm /usr/local/share/gnome-shell/theme/impishgdm.gresource
214 update-alternatives --quiet --set gdm-theme.gresource "$source"
215 cd /usr/local/share
216 rmdir --ignore-fail-on-non-empty -p gnome-shell/theme
217 echo "
218                                                 ---------------
219                                                 |Reset Success|
220                                                 ---------------"
221 else
222 echo "
223 -----------------------------------------------------------------------------
224 No need, Already Reset. (or unlikely background is not set using this Script.)
225 -----------------------------------------------------------------------------"
226 exit 1
227 fi
228 ;;
229 ############################################################################################
230 *) #########################################################################################
231 ############################################################################################
232 echo "Use the parameter '--set' or '--reset'; example: './impishgdm --set' or './impishgdm --reset'"
233 exit 1
234 esac