-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset-gdm-wallpaper
executable file
·87 lines (65 loc) · 2.47 KB
/
set-gdm-wallpaper
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
#!/usr/bin/sh
set -e
if ! hash gresource 2>/dev/null; then
echo "gresource binary not found. "
echo " "
echo "Please install glib2 or glib2-devel"
echo " "
echo "Fedora:"
echo "# dnf install glib2-devel"
exit 1
fi
if [ ! -n "$1" ]
then
echo 'Usage:';
echo ' set-gdm-wallpaper /path/to/image';
echo ' set-gdm-wallpaper --uninstall';
exit 1
fi
if [ "$1" == "--uninstall" ]
then
if grep -q "macOS_mojave_wallpaper_mid-day.png" /usr/share/gnome-shell/gnome-shell-theme.gresource; then
cp -f /usr/share/gnome-shell/gnome-shell-theme.gresource.backup /usr/share/gnome-shell/gnome-shell-theme.gresource
echo 'gnome-shell-theme.gresource recovered';
fi
exit
fi
workdir="/usr/share/gnome-shell/wallpaper"
if [ "$1" == "--rpm" ]
then
image="$workdir/macOS_mojave_wallpaper_mid-day.png"
else
image="$1"
fi
if [ ! -f $image ]
then
echo "File not found: \"$image\" "
exit 1
fi
echo "Updating wallpaper..."
mkdir -p $workdir/theme
echo '<?xml version="1.0" encoding="UTF-8"?>' > $workdir/gnome-shell-theme.gresource.xml
echo '<gresources><gresource prefix="/org/gnome/shell/theme">' >> $workdir/gnome-shell-theme.gresource.xml
for r in `gresource list /usr/share/gnome-shell/gnome-shell-theme.gresource`; do
gfile="${r#\/org\/gnome\/shell\/theme/}";
mkdir -p "$(dirname $workdir/theme/$gfile)"
if [ "$gfile" != "wallpaper-gdm.png" ]; then
gresource extract /usr/share/gnome-shell/gnome-shell-theme.gresource $r >$workdir/theme/$gfile
echo "<file>$gfile</file>" >> $workdir/gnome-shell-theme.gresource.xml
fi
done
echo "<file>wallpaper-gdm.png</file>" >> $workdir/gnome-shell-theme.gresource.xml
cp -f $image $workdir/theme/wallpaper-gdm.png
echo '</gresource></gresources>' >> $workdir/gnome-shell-theme.gresource.xml
sed -i -e 's/background: #2e3436 url(resource:\/\/\/org\/gnome\/shell\/theme\/noise-texture.png);/background: #2e3436 url(resource:\/\/\/org\/gnome\/shell\/theme\/wallpaper-gdm.png);background-size: cover;/g' $workdir/theme/gnome-shell.css
cd $workdir/theme
glib-compile-resources $workdir/gnome-shell-theme.gresource.xml
if ! grep -q "wallpaper-gdm.png" /usr/share/gnome-shell/gnome-shell-theme.gresource; then
cp -f /usr/share/gnome-shell/gnome-shell-theme.gresource /usr/share/gnome-shell/gnome-shell-theme.gresource.backup
echo "Backup"
fi
cp -f $workdir/gnome-shell-theme.gresource /usr/share/gnome-shell/
rm -rf $workdir/theme
rm -f $workdir/gnome-shell-theme.gresource.xml
rm -f $workdir/gnome-shell-theme.gresource
echo "Done!"