forked from thiggy01/ubuntu-change-gdm-background
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgdm-change-ubuntu18.04
executable file
·74 lines (61 loc) · 2.89 KB
/
gdm-change-ubuntu18.04
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
#!/usr/bin/env bash
# Autor: Thiago Silva
# Contact: [email protected]
# URL : https://github.com/thiggy01/ubuntu-change-gdm-background
# ============================================================= #
# Add the restore option in order to restore gdm original theme.
if [ "$1" = "--restore" ]; then
cat /usr/share/gnome-shell/theme/gdm3.css~ > /usr/share/gnome-shell/theme/gdm3.css
echo "L'arrière-plan de la connexion a été restauré avec succès sur son thème d'origine."
echo "Redémarrez GNOME afin d'appliquer les changements"
exit 0
fi
# Get the image selected by user from yad based GUI.
usrInput=$(yad --file --center --width=900 --height=450 --title "Séléctionnez une image" --add-preview --file-filter "Image Files | *.jpg *.png" 2> /dev/null)
# Verify if yad is installed
if [ "$?" -eq 127 ]; then
echo "Le paquet yad n'est pas installé"
echo "Il est utile pour des interfaces graphiques qui vous simplifirons la vie"
echo "Utiliser la commande : sudo apt install yad"
exit 1
fi
# Check if there is a user input.
[ -z "$usrInput" ] && exit 1
# Test if argument is an image file.
if [[ $(file --mime-type -b "$usrInput") == image/*g ]]; then
# Get the full path of submited image.
imgPath=$(realpath "$usrInput")
# Save pictures to /usr/share/gdm-backgrounds.
[ ! -d /usr/share/gdm/saved-pictures ] && mkdir /usr/share/gdm/saved-pictures
cp "$imgPath" /usr/share/gdm/saved-pictures
bgImgPath=/usr/share/gdm/saved-pictures/"${usrInput##*/}"
# Ubuntu GDM login background configuration file path.
cssPath=/usr/share/gnome-shell/theme/gdm3.css
# Test if there is a backup of the original gdm css file and create a backup,
# if there isn't one.
[ ! -f "$cssPath"~ ] && cp "$cssPath" "$cssPath"~
# Change the login background image to the one you submited.
ex $cssPath << EOF
/#lockDialogGroup
:normal jf:ld}a url(file://$bgImgPath);obackground-size: cover; }
:wq
EOF
# Test if login screen background was changed.
if grep -wq "$bgImgPath" "$cssPath"; then
yad --title "Message d'information" --center \
--width=300 --height=100 --borders=20 \
--text="L'image de l'écran de choix de session à été changée avec succès" \
--button=gtk-ok
yad --title "Redémarrer le gestionnaire de session" --center \
--width=300 --height=100 --borders=20 \
--text="Souhaitez-vous redémarrer gdm afin que les modifications soit prise en compte ?" \
--button=gtk-yes:1 --button=gtk-no:2
if [ $? == 1 ]; then
service gdm restart
elif [ $? == 2 ]; then
# On ne souhaite pas embêter l'utilisateur pour son choix donc on n'utilise plus yad.
echo "\[033;1m Les changements ne seront pas appliqués jusqu'au redémarrage de gdm"
echo "Via la commande : service gdm restart"
fi
fi
fi