Hello world,
In part I, we have seen how to customize gdm login screen on your Ubuntu 17.10 machine. We were expecting a really complex process but, at the end, it consisted in changing some css code in a configuration file. In the previous post, we have explained how to perform the changes step by step. Since we understand how the gdm login screen is controlled, it’s possible to create a small script that would automate the process and make the process even more easier.
Let’s see how to change the GDM Background image using a simple script…..
The Little script
The script below has been developed really in a rush and we have not performed any deep debugging. It’s probably possible to improve it or even better to create a small tool that could streamline the process of changing the background image in the GDM login pages…
The provided script will basically prompt you to select the image to use and automatically perform the changes in the /usr/share/gnome-shell/theme/ubuntu.css file. No more than this.
Important Note :
If you copy/paste the script, you might encounter some issues because font formatting might be not maintained during the copy/paste operation. Please ensure that format is accurate before launching the script. A downloadable version of the script is available at the bottom of the post
Disclaimer : As usual, use this at your own risk !!
################################################################ # Script_Name : Change-Gdm-Background-1.0.sh # Description : Change background image of the GDM Login screen # on ubuntu 17.10 # Date : December 2017 # written by : Griffon # Web Site :http://www.c-nergy.be - http://www.c-nergy.be/blog # Version : 1.0 # Disclaimer : Script provided AS IS. Use it at your own risk.... ################################################################## #---------------------------------------------------# # Step 0 - Credits .... #---------------------------------------------------# /bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m" /bin/echo -e "\e[1;32mChange-Gdm-Background-1.0.sh\e[0m" /bin/echo -e "\e[1;32mwritten by Griffon - December 2017 - Version 1.0 - Change-Gdm-Background-1.0.sh\e[0m" /bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m" echo #---------------------------------------------------# # Step 1 - Prompt for image to be used.... #---------------------------------------------------# echo /bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m" /bin/echo -e "\e[1;32mSelecting an image...Proceeding\e[0m" /bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m" echo pix=$(zenity --file-selection --title="select the new login image") # get just name of the file fname=$(basename $pix) echo $fname #---------------------------------------------------# # Step 2 - Copy file to correct location #---------------------------------------------------# echo /bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m" /bin/echo -e "\e[1;32mCopy image to correct location....proceeding\e[0m" /bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m" echo sudo cp $pix /usr/share/backgrounds/ #---------------------------------------------------# # Step 3 - Update the ubuntu.css file #---------------------------------------------------# echo /bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m" /bin/echo -e "\e[1;32mUpdating the ubuntu.css file....proceeding\e[0m" /bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m" echo sudo cp /usr/share/gnome-shell/theme/ubuntu.css /usr/share/gnome-shell/theme/ubuntu.css.bak sudo sed -i "/#lockDialogGroup/a background: #2c001e url(file:///usr/share/backgrounds/${fname});\nbackground-repeat: no-repeat;\nbackground-size: cover;\nbackground-position: center;\n}\nGriffonToDel" /usr/share/gnome-shell/theme/ubuntu.css sudo sed -i '/GriffonToDel/,+2d' /usr/share/gnome-shell/theme/ubuntu.css #---------------------------------------------------# # Step 4 - Ask User to reboot system #---------------------------------------------------# echo echo "Need to reboot your machine to see the changes....:-)" echo
How to Use the Script
Set Execute Right on the script
After downloading the script, extracting from the zip, navigate to the Change_Gdm_Background-1.0.sh file and right-click on it. Go to permissions tab and check the box, allow executing file as a program
Click on picture for better Resolution
Execute the script
In the Terminal console, Browse to the location where the script has been stored and then issue the following command
./Change-Gdm-Background-1.0.sh
Click on picture for better Resolution
You will see a dialog box opening asking you for the image to be set as background image. The image can be located anywhere. The script will copy the image to the correct location automatically…
Click on picture for better Resolution
Then, you will be asked to provide your password. Proceed and wait for the script to complete
Click on picture for better Resolution
When the script complete, you will see a message asking you to reboot the machine. By default, the script will not reboot the machine automatically, you will need to perform this action in order to see the changes applied.
Click on picture for better Resolution
Check your settings
After the reboot,the login page should show your new background. After login into the system, lock and unlock the system and you should see again your customize background theme applied accordingly
Click on picture for better Resolution
Click on picture for better Resolution
Download the Script
Please download the script : Change-Gdm-Background-1.0.sh.zip
Final Notes
Voila ! This is done. We have streamlined the process of changing the GDM Login background image. Using scripting technologies, it’s really easy to automate an number of tasks and actions in Ubuntu. In the future, somebody might be creating a small QT utility or a gnome extensions that could be used to change the gdm login background page…This would be really cool actually… All in all, we are quite happy as we have achieved our goal : offering a consistent Login/lock/unlock user experience….
Till next time
See ya
On second run script makes Ubuntu loop not reaching login screen because the script creates duplicate lines
background-size: cover;
background-position: center;
}
@Amis,
Indeed, the script is quite basic and should be run only once…. We will try to update it and take this into account
Thanks for the feedback
Till next time
See ya