Hello World,
Since Ubuntu 24.10 has been released recently, we are also updating our change-gdm-background script. The latest version was set to 3.7 and could be run on Ubuntu 20.04 up to Ubuntu 24.04. We are releasing a new version of this little script which will get version 3.8. There are no major changes in this release since there are other solutions or approach that can be used to perform the same thing.
However, we still have small number of users asking to update the script and to include support for Ubuntu 24.10. So, we have decided to work a little bit on the script and we have added Ubuntu 24.10 support. We have also decided to remove support for Obsolete, End of Life Operating systems (or reaching soon end of life).
This is a maintenance release and no major changes have been introduced. The version 3.8 works exactly the same way as the version 3.7. Please always use the latest version of the script and check that the version of your Ubuntu machine is supported
Let’s go !
Change-Gdm-Background Script – Version 3.8
Overview
As with the previous version, the Change-gdm-background script can be used to customize the background image you see at the login screen of Ubuntu. So, yes, it’s possible to change the purple or the gray background from the login screen with either another solid color or an background image of your choice.
There are probably other ways or tools that can be used to change the login screen background image. However, we wanted to provide a relatively easy way to perform this operation. The Change-Gdm-Background-3.8.sh script
- support Ubuntu 20.04, Ubuntu 22.04, Ubuntu 24.04 and Ubuntu 24.10
- Removed support for Ubuntu 23.xx
- can run multiple times
- provides a basic GUI interface to have a more friendly experience
- allows you to set either a solid color or a picture as background image
- the script create a custom theme folder instead of replacing the original compiled file.
- The GUI offers you the possibility to easily revert back changes if needed for Ubuntu 20.04 and later (see more below)
- support light and dark theme in Ubuntu…
- cleanup code and simplification
- add lighter background on user account object in login page
If you change the background with any other techniques (see Ubuntu-How to manually customize the Gnome login screen in Ubuntu ), you might end up with something like the screenshot below
Click on Picture for better Resolution
To overcome this situation, you have to either select a more appropriate picture (dark background) or you can use our script which will modify the code to have a lighter background color on the user account object in the login page.
Click on Picture for Better Resolution
The code in the script version 3.7 will try to set a more neutral color when performing the background picture change.
How to Use the Script
Disclaimer
The script is provided AS IS ! Use it at your own risk !!!
Download the script
To download the script, you have multiple options. You can from a Terminal issue the following command
wget https://www.c-nergy.be/downloads/ChangeGDM/Change-Gdm-Background-3.8.zip
You can also simply use your browser and click on the link to download the script :
Unzip the File
After downloading the zip package containing the file, you will need to unzip it first. To unzip the package, you can use the Terminal console and issue the following command
unzip Change-Gdm-Background-3.8.zip
You can also use the GUI and the Nautilus file manager to select the downloaded package, right-click on it and select the option Extract Here
Set Execute Right on the script
After downloading the script and extracting from the zip, open a Terminal console. From the Terminal console, we will mark the script as executable. To mark the script as executable, you simply navigate to the location where the script is located and you issue the following command
chmod +x Change-Gdm-Background-3.8.sh
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-3.8.sh
You will see some output in your Terminal console and you should be prompted for a password.
Click on Picture for better Resolution
After entering the password, the GUI part of the script will start and you should be presented with the following dialog box
Click on Picture for better Resolution
As you can see, you can decide to use a solid color for the login background settings or you can decide to use your favorite picture to be used at login screen.
Solid Color Selection
So, let’s assume you want to use solid color at your login screen, you have then selected the option “Solid Color as background”. Press OK. The script will then display the color palette dialog box where you can easily choose your preferred color. When you are done, click on Select button.
Click on Picture for better Resolution
Wait for the script to execute. Then, a new Dialog Box will be displayed asking you what to do next. You can decide to restart the GDM Service or simply reboot the server completely and see if the changes have been applied successfully. Select your preferred option and Press OK
Click on Picture for better Resolution
If everything worked as expected, you should see your customized login screen displayed properly with your selected solid color displayed on the screen…
Click on Picture for better Resolution
As you can see, on Ubuntu 24.xx, we have soften the background color of the user list which makes it a little bit more appealing than the default color scheme.
Picture as background
If you prefer to use a picture as background login screen, when the script is presenting your the dialog box to choose from, be sure to select the picture as background option. Press OK.
The File Browser dialog box will open and you will be able to easily browser and locate the image to be used. When selected, Press OK
Click on Picture for better Resolution
In the screenshot below, we can see the script running when dark style is selected in your Ubuntu machine.
Click on Picture for better Resolution
Again, a new Dialog Box will be displayed asking you to either reboot the server completely or to simply restart the GDM service. Select your preferred option and Press OK. This step is mandatory in order to visualize the changes made at the login screen…..
Click on Picture for better Resolution
After rebooting or restarting the GDM service, you should see your new customized login screen and you can proceed with the login process
Click on Picture for Better Resolution
Here again, you can see that we have decided to soften the background color in the user list which make the login screen more consistent. If we update the script, we could possibly add an option to specify the color to be used in the user list….
How to revert back changes via the GUI
If you ever want to revert back the changes made to you login screen and go back to default Ubuntu Theme, you can now use the gui interface to do so. The feature is working great against Ubuntu 20.04 and later.
Click on Picture for Better Resolution
After rebooting or restarting the GDM service, you should see the familiar login screen of your Ubuntu 24.XX distribution
Click on Picture for better Resolution
How to revert back changes if something goes wrong
If something goes really wrong (for example, your login screen is gray and all the elements are overlapping each others) and you cannot use the gnome login screen, you can try to switch to command line login prompt (Press Ctrl+Alt-F2). Provide your credentials and simply execute the command above, reboot the server and you should be back to your standard Ubuntu purple login screen and you should be able to proceed with the login process
Note : This command works for Ubuntu 20.04 and later
sudo update-alternatives --quiet --set gdm3-theme.gresource /usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource
Final Notes
Voila ! This is it for this post !
The Change-Gdm-Background 3.8 script has been released in order to include support for Ubuntu 24.10. The script is working as previous version but the code has been slightly updated in order to perform some long awaited cleanup.
If you detect some issues or bugs with the script, please let us know and we will try to fix it but with no guarantee. As we have no time at the moment, no new feature will be added in future releases and only “maintenance” releases will be made available. As mentioned in previous post as well, this script might become deprecated in the future since it seems that some native gnome apps might provide the same functionality….
Till next time
See ya
Annex – The Script in plain text….
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. The content of the script is presented hereafter so people can review it and see what it’s doing….. A downloadable version of the script is available here
Disclaimer : As usual, use this at your own risk !!
#!/bin/bash ########################################################################## # Script_Name : Change-Gdm-Background-3.8.sh # # Description : Change background image of the GDM Login screen # # on ubuntu 18.04,20.04,22.xx,23.xx,24.xx # # Date : Oct 2024 # # written by : Griffon # # Web Site :https://www.c-nergy.be - https://www.c-nergy.be/blog # # Version : 3.8 # # History : 3.8 - Adding support to Ubuntu 24.10 # # : - Fixing Zenity Sizing DialogBox # # : - Minor code update # # : 3.7 - Adding support to Ubuntu 24.04 # # - Remove Support Ubuntu 23.04 and 23.10 # # : 3.6 - Adding support to Ubuntu 23.XX # # : - Remove Support Ubuntu 18.04 (End of Standard Support) # # : - Remove Support Ubuntu 22.10 (End of Life) # # : 3.5 - Adding Support to Ubuntu 22.10 # # : 3.5 - Remove Support End of Life Ubuntu # # : 3.4 - Adding Support to Ubuntu 22.04 # # : 3.3 - Adding Support to Ubuntu 21.10 # # - Removing Support to Ubuntu 20.10 # # : 3.2 - Adding Support to Ubuntu 21.04 # # - Updating Code Picture background # # 3.1 - Adding Support to Ubuntu 20.10 # # 3.0 - Adding Support to Ubuntu 20.04 # # - New Code structure # # - Added Solid Color Palette GUI # # 2.0 - Updated Version to support 17.10,18.04,18.10 # # 1.0 - Initial Release Ubuntu 17.10 # # # # Disclaimer : Script provided AS IS. Use it at your own risk.... # # You can use this script and distribute it as long as # # credits are kept in place and unchanged # # # ########################################################################## #---------------------------------------------------# # Variables and Constants # #---------------------------------------------------# #--Automating Script versioning ScriptVer="3.8" gdmpath="gdm3" #---------------------------------------------------# # Script Version information Displayed # #---------------------------------------------------# echo /bin/echo -e "\e[1;36m !----------------------------------------------------------------! ! Change-Gdm-Background script - Ver. $ScriptVer ! ! Written by Griffon - Oct 2024 ! ! www.c-nergy.be ! !----------------------------------------------------------------! \e[0m" /bin/echo -e "\e[1;38m !----------------------------------------------------------------! ! Disclaimer ! ! !! Script provided AS IS. Use it at your own risk.!! ! !----------------------------------------------------------------! \e[0m" echo #--------------------------------------------------------------------------# # -----------------------Function Section - DO NOT MODIFY -----------------# #--------------------------------------------------------------------------# #---------------------------------------------------# # Function 0 - check for supported OS version ....# #---------------------------------------------------# check_os() { echo /bin/echo -e "\e[1;33m |-| Detecting Ubuntu version \e[0m" case $version in *"Ubuntu 20.04"*) /bin/echo -e "\e[1;32m |-| Ubuntu Version : $version\e[0m" call_gui_choice gdm_update gdm_compile ;; *"Ubuntu 22.04"*) /bin/echo -e "\e[1;32m |-| Ubuntu Version : $version\e[0m" gdmpath="gdm" call_gui_choice gdm_update gdm_compile ;; *"Ubuntu 24.04"*) /bin/echo -e "\e[1;32m |-| Ubuntu Version : $version\e[0m" gdmpath="gdm" call_gui_choice gdm_update user_login_change gdm_compile ;; *"Ubuntu 24.10"*) /bin/echo -e "\e[1;32m |-| Ubuntu Version : $version\e[0m" gdmpath="gdm" call_gui_choice gdm_update user_login_change gdm_compile ;; *) /bin/echo -e "\e[1;31m !--------------------------------------------------------------! ! Your system is not running a supported version ! ! The script has been tested only on the following versions ! ! 20.04.x/22.04/24.04/24.10 ! ! The script is exiting... ! !--------------------------------------------------------------! \e[0m" echo exit ;; esac echo } #--------------------------------------------------------------------# # Function 1 - Display GUI for Change Login script # #--------------------------------------------------------------------# call_gui_choice(){ #------ Selection Dialog Box Displayed ----------------------------# echo /bin/echo -e "\e[1;33m |-| Starting Wizard Interface \e[0m" cbxChoice=$(zenity --list \ --height=400 \ --title="Login Screen Background Changer" \ --text "What do you want to do ?" \ --radiolist \ --column "Choice" \ --column "Description" \ FALSE "Solid color as background" \ FALSE "Picture as background" \ FALSE "Revert back to default" 2>/dev/null) #---------Check which option has been selected - Color/picture/Nothing------# if [[ $cbxChoice = "Solid color as background" ]]; then /bin/echo -e "\e[1;32m |-| Solid color selected..Proceeding\e[0m" selectcolor=$(zenity --color-selection --show-palette 2>/dev/null) if [ -z "$selectcolor" ] then /bin/echo -e "\e[1;31m |-| No color has been chosen..Exiting\e[0m" exit else /bin/echo -e "\e[1;32m |-| Solid color ........ : $selectcolor \e[0m" fi elif [[ $cbxChoice = "Revert back to default" ]]; then /bin/echo -e "\e[1;31m |-| Resetting Ubuntu default settings\e[0m" sudo update-alternatives --quiet --set $gdmpath-theme.gresource /usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource call_gui_rboot echo elif [[ $cbxChoice = "Picture as background" ]]; then /bin/echo -e "\e[1;32m |-| Picture Selected...Proceeding\e[0m" pix=$(zenity --file-selection --title="select the new login image" 2>/dev/null) if [ $? -eq 1 ] then /bin/echo -e "\e[1;31m |-| No Image Selected...Exiting\e[0m" echo exit else #--Get the File Name only not the full path -----## fname=$(basename "$pix") fi else /bin/echo -e "\e[1;31m |-| No option Selected...Exiting\e[0m" echo exit fi } #--------------------------------------------------------------------# # Function 2 - Reboot function # #--------------------------------------------------------------------# call_gui_rboot(){ cbxReboot=$(zenity --list \ --height=400 \ --title="Restart GDM Service or Reboot ?" \ --text "Select which option is best for you?" \ --radiolist \ --column "Choice" \ --column "Description" \ FALSE "Reboot Now (Recommended)" \ FALSE "Restart GDM service" 2>/dev/null) #---------Check which option has been selected - Color/picture/Nothing------# if [[ $cbxReboot = "Reboot Now (Recommended)" ]]; then /bin/echo -e "\e[1;32m |-| want to reboot....;:-) \e[0m" sudo reboot elif [[ $cbxReboot = "Restart GDM service" ]]; then /bin/echo -e "\e[1;32m |-| Restart GDM service....;:-) \e[0m" sudo service gdm restart else /bin/echo -e "\e[1;31m |-| Nothing here..... \e[0m" echo exit fi } #--------------------------------------------------------------------# # Function 3 - Update css file on Ubuntu 20.04 or later # #--------------------------------------------------------------------# gdm_common() { # Step 1 - Install prereqs for compilation later on sudo apt-get -y install libglib2.0-dev-bin sudo apt-get -y install libxml2-utils #--Define some Variable workdir="${HOME}/shell-theme" xmlfile=${workdir}/custom.gresource.xml echo /bin/echo -e "\e[1;33m |-| Creating Directory Structure \e[0m" if [ ! -d ${workdir} ]; then mkdir -p ${workdir} fi if [[ ! -d ${workdir}/Yaru ]]; then mkdir -p ${workdir}/Yaru fi if [[ ! -d ${workdir}/Yaru-dark ]]; then mkdir -p ${workdir}/Yaru-dark fi #Addition to support Ubuntu 21.04 if [[ ! -d ${workdir}/Yaru-light ]]; then mkdir -p ${workdir}/Yaru-light fi if [[ ! -d ${workdir}/icons ]]; then mkdir -p ${workdir}/icons fi if [[ ! -d ${workdir}/icons/scalable ]]; then mkdir -p ${workdir}/icons/scalable fi if [[ ! -d ${workdir}/icons/scalable/actions ]]; then mkdir -p ${workdir}/icons/scalable/actions fi if [[ ! -d ${workdir}/icons/scalable/status ]]; then mkdir -p ${workdir}/icons/scalable/status fi echo /bin/echo -e "\e[1;33m |-| Creating xml file for compilation step \e[0m" bash -c "cat >"$xmlfile <<EOF <?xml version="1.0" encoding="UTF-8"?> <gresources> <gresource prefix="/org/gnome/shell/theme"> EOF echo /bin/echo -e "\e[1;32m |-| Populate xml file... \e[0m" #--Extract Resources -- Important location gst=/usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource for r in `gresource list $gst`; do gresource extract $gst $r >$workdir/${r#\/org\/gnome\/shell\/theme/} if [ $? -eq 0 ] then echo " <file>"${r#\/org\/gnome\/shell\/theme/}"</file>" >>$xmlfile fi done #Close the file echo "</gresource>" >>$xmlfile echo "</gresources>" >>$xmlfile } #--------------------------------------------------------------------# # Function 4 - GDM Compilation Function # #--------------------------------------------------------------------# gdm_compile() { /bin/echo -e "\e[1;32m |-| Compile Resource File...\e[0m" cd ${workdir} glib-compile-resources custom.gresource.xml echo /bin/echo -e "\e[1;33m |-| Create new Theme Folder... \e[0m" if [ ! -d "/usr/share/gnome-shell/theme/custom" ]; then sudo mkdir /usr/share/gnome-shell/theme/custom else /bin/echo -e "\e[1;32m |-| Folder exists...Proceeding \e[0m" fi /bin/echo -e "\e[1;32m |-| Copy new gresource file...\e[0m" sudo cp ${workdir}/custom.gresource /usr/share/gnome-shell/theme/custom /bin/echo -e "\e[1;32m |-| Copy picture to new theme folder...\e[0m" echo /bin/echo -e "\e[1;33m |-| Applying Changes... \e[0m" /bin/echo -e "\e[1;32m |-| redirect to new theme folder...\e[0m" echo sudo update-alternatives --quiet --install /usr/share/gnome-shell/$gdmpath-theme.gresource $gdmpath-theme.gresource /usr/share/gnome-shell/theme/custom/custom.gresource 0 sudo update-alternatives --quiet --set $gdmpath-theme.gresource /usr/share/gnome-shell/theme/custom/custom.gresource echo /bin/echo -e "\e[1;33m |-| Rebooting or Restarting GDM Service... \e[0m" #Reboot Server or Restart GDM Service ... call_gui_rboot } gdm_update() { #common code to run gdm_common echo /bin/echo -e "\e[1;32m |-| Modifying $gdmpath.css file...\e[0m" if [ -z "$selectcolor" ] then echo /bin/echo -e "\e[1;32m |-| Copying Picture to working Directory... \e[0m" cp "$pix" ${workdir} #Updated Code echo " #lockDialogGroup { background: #2c001e url('resource:///org/gnome/shell/theme/${fname}'); background-repeat: no-repeat; background-size: cover; background-position: center; }" >> ${workdir}/$gdmpath.css sed -i "/<file>$gdmpath.css<\/file>/a<file>${fname}<\/file>" $xmlfile else echo " #lockDialogGroup { background-color: ${selectcolor}; }" >> ${workdir}/$gdmpath.css fi } #--------------------------------------------------------------------# # Function 4 - Update css file on Ubuntu 24.04 # #--------------------------------------------------------------------# user_login_change() { #Only valid for Ubuntu 24.04 so far echo " .login-dialog-not-listed-button { color: #f2f2f2; background-color: transparent; padding: 0 6px; margin: 6px; } .login-dialog-not-listed-button:focus { color: #f2f2f2; box-shadow: inset 0 0 0 0px #ef8661 !important; background-color: rgba(0, 0, 0, 0.1875); } .login-dialog-not-listed-button:focus:hover { background-color: #3c3532; } .login-dialog-not-listed-button:hover { color: #f2f2f2; background-color: rgba(0, 0, 0, 0.1875);} .login-dialog-not-listed-button:active { color: #f2f2f2; background-color: rgba(0, 0, 0, 0.1875); } .login-dialog-not-listed-button:active:hover { background-color: rgba(0, 0, 0, 0.1875); } .login-dialog-not-listed-button:active:focus { background-color: rgba(0, 0, 0, 0.1875); } .login-dialog-user-list-view { width: 25em; -st-vfade-offset: 3em; } .login-dialog-user-list-view .login-dialog-user-list { margin: 0 8px; spacing: 12px; } .login-dialog-user-list-view .login-dialog-user-list .login-dialog-user-list-item { color: #f2f2f2; background-color: transparent; border-radius: 6px; padding: 9px; } .login-dialog-user-list-view .login-dialog-user-list .login-dialog-user-list-item:selected, .login-dialog-user-list-view .login-dialog-user-list .login-dialog-user-list-item:focus { color: #f2f2f2; box-shadow: inset 0 0 0 0px #ef8661 !important; background-color: rgba(0, 0, 0, 0.1875); } .login-dialog-user-list-view .login-dialog-user-list .login-dialog-user-list-item:selected:hover, .login-dialog-user-list-view .login-dialog-user-list .login-dialog-user-list-item:focus:hover { background-color:rgba(0, 0, 0, 0.1875); } .login-dialog-user-list-view .login-dialog-user-list .login-dialog-user-list-item:hover { color: #f2f2f2; background-color: rgba(0, 0, 0, 0.1875); } .login-dialog-user-list-view .login-dialog-user-list .login-dialog-user-list-item:active { color: #f2f2f2; background-color: rgba(0, 0, 0, 0.1875); } .login-dialog-user-list-view .login-dialog-user-list .login-dialog-user-list-item:active:hover { background-color: rgba(0, 0, 0, 0.1875); } .login-dialog-user-list-view .login-dialog-user-list .login-dialog-user-list-item:active:focus { background-color: rgba(0, 0, 0, 0.1875); } .login-dialog-user-list-view .login-dialog-user-list .login-dialog-user-list-item .user-icon { border: 2px solid rgba(0, 0, 0, 0.1875); } .login-dialog-user-list-view .login-dialog-user-list .login-dialog-user-list-item .login-dialog-timed-login-indicator { height: 2px; margin-top: 6px; background-color: rgba(242, 242, 242, 0.7); } .login-dialog-user-list-view .login-dialog-user-list .login-dialog-user-list-item:logged-in .user-icon { border-color: transparent; } .login-dialog-user-list-view .login-dialog-user-list .login-dialog-user-list-item:logged-in .user-icon StIcon { background-color: rgba(211, 70, 21, 0.3); }" >> ${workdir}/$gdmpath.css } #--------------------------------------------------------------------# # Function 5 - Intermediate Function # #--------------------------------------------------------------------# #--------------------------------------------------------------------# # Function 6 - Show Credits # #--------------------------------------------------------------------# sh_credits() { /bin/echo -e "\e[1;36m !-----------------------------------------------------! ! Change-Gdm-Background - Version : $ScriptVer ! ! Written By - Griffon - Oct. 2024 ! ! ! ! Web :www.c-nergy.be - www.c-nergy.be/blog ! !-----------------------------------------------------! \e[0m" echo } #--------------------------------------------------------------------------# # -----------------------END Function Section -----------------# #--------------------------------------------------------------------------# #--------------------------------------------------------------------------# #------------ MAIN SCRIPT SECTION -------------------# #--------------------------------------------------------------------------# #---------------------------------------------------# #-- Step 0 - Try to Detect Ubuntu Version.... #---------------------------------------------------# version=$(lsb_release -sd) codename=$(lsb_release -sc) #Trick to get prompted for sudo password - Nothing will be logged sudo touch gdmlogin.log #Call Check OS Function to validate OS Version check_os #End of script - Show Credits sh_credits