1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 gst="/usr/share/gnome-shell/gnome-shell-theme.gresource"
19 workdir="/tmp/shell-theme"
20 xml="$workdir/theme/gnome-shell-theme.gresource.xml"
21 newimagedir="$HOME/Pictures"
22 newimage="binary-arch-dual.png"
23
24
25
26 if [ "$(id -u)" -eq 0 ]; then
27 echo "Do not run this script as root; it will ask when needed"
28 elif [ ! -f "$newimagedir/$newimage" ]; then
29 echo "Image file not found: $newimagedir/$newimage"
30 elif [ ! -f "$gst" ]; then
31 echo "File not found: $gst"
32 elif [ ! -d "/tmp" ]; then
33 echo "Directory not found: /tmp"
34 else
35
36
37 echo "Using the following image for the login background:"
38 echo "$newimagedir/$newimage"
39
40
41
42 echo "Extracting the current theme..."
43 for r in `gresource list $gst`; do
44 r="${r#\/org\/gnome\/shell/}"
45 if [ ! -d "$workdir/${r%/*}" ]; then
46 mkdir -p "$workdir/${r%/*}"
47 fi
48 done
49
50 for r in `gresource list $gst`; do
51 gresource extract "$gst" "$r" > "$workdir/${r#\/org\/gnome\/shell/}"
52 done
53
54
55
56 echo "Copying replacement image..."
57 cp "$newimagedir/$newimage" "$workdir/theme/"
58
59
60
61 echo "Creating xml file..."
62 echo '<?xml version="1.0" encoding="UTF-8"?>
63 <gresources>
64 <gresource prefix="/org/gnome/shell/theme">' > "$xml"
65
66 find "$workdir/theme" -type f | sed "s|^$workdir/theme/||" | sort | sed 's|^| <file>|' | sed 's|$|</file>|' >> "$xml"
67
68 echo " </gresource>
69 </gresources>" >> "$xml"
70
71
72
73 echo "Modifying css file..."
74 perl -i -p0e "s|#lockDialogGroup {.*?}|#lockDialogGroup {\n background: #41494c url(resource:///org/gnome/shell/theme/$newimage);\n background-size: 3840px 1080px;\n background-repeat: no-repeat; }|s" "$workdir/theme/gnome-shell.css"
75
76
77
78 echo "Recompiling theme..."
79 cd "$workdir/theme"
80 glib-compile-resources gnome-shell-theme.gresource.xml
81 echo "Copying theme file into place..."
82 sudo cp "$workdir/theme/gnome-shell-theme.gresource" /usr/share/gnome-shell/
83
84
85 echo "Cleaning up..."
86 rm -r "$workdir"
87 echo "Done. Log out and restart GDM to complete."
88 fi