44

How can I change the Ubuntu 20.04 login screen theme or background?

In the previous version 19.10, I can change it from the CSS file under Yaru theme but now there is no CSS file.

2
  • 1
    The answer is to install vanilla-gnome-default-settings. This will set the GDM theme to Gnome stock, and also give you the option of continuing to use Yaru as your theme or the stock stock Gnome theme. Apr 22, 2020 at 16:45
  • I haven't tested this on 20.04, but I believe my answer here for how to do this on 21.10 should work on 20.04, and it doesn't require installing any third-party scripts or extracting gresource files: askubuntu.com/a/1396066/84581
    – gsgx
    Mar 5, 2022 at 10:30

4 Answers 4

35

In previous versions of Ubuntu since its introduction of gdm3 for login greeter, the style sheet file is directly available to edit.

for example:

/usr/share/gnome-shell/theme/ubuntu.css #for Ubuntu 18.04
/usr/share/gnome-shell/theme/Yaru/gnome-shell.css` #for Ubuntu 19.10

are the files being used as alternatives.

The name of alternatives is gdm3.css.

for Ubuntu 20.04 the equivalent to above is gdm3-theme.gresource

$ update-alternatives --config gdm3-theme.gresource   
There are 3 choices for the alternative gdm3-theme.gresource (providing /usr/share/gnome-shell/gdm3-theme.gresource).

  Selection    Path                                                           Priority   Status
------------------------------------------------------------
* 0            /usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource   15        auto mode
  1            /usr/local/share/gnome-shell/theme/focalgdm3.gresource          0         manual mode
  2            /usr/share/gnome-shell/gnome-shell-theme.gresource              10        manual mode
  3            /usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource   15        manual mode

Press <enter> to keep the current choice[*], or type selection number:

from the core files of Ubuntu, the config for gdm is

stylesheetName: 'gdm3.css',
themeResourceName: 'gdm3-theme.gresource',

the above means that one needs to edit the file gdm3.css inside the .gresource file from the above update-alternatives result. Or install some other .gresource files which have the compatibility for Ubuntu 20.04. for example in above output you have the choice of

.../gnome-shell/gnome-shell-theme.gresource

as an alternative. If you trust some other (external sources) .gresource files that have the compatibility for Ubuntu 20.04, You can install them as an alternative and use it.

If you want to edit,

for example, you can extract the gdm3.css and see the color that is configured for login screen background.

run the below commands one by one

gresource extract /usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource /org/gnome/shell/theme/gdm3.css > $HOME/gdm3.css
gedit $HOME/gdm3.css

some of the content:

#lockDialogGroup {
  background-color: #4f194c; }

Editing this content with your required content and recompiling it to create new .gresource file is required. After which you can install this new .gresource file as an alternative and select it.

How to extract and compile?

Disclimer: this link is only for Idea. Proper making and configuration is required for getting things to work for Ubuntu 20.04 Otherwise system will be bricked. Please note that this post is quite older and contents vary from Ubuntu 20.04.

Also note that the package libglib2.0-dev is required to compile the .gresource file.


Well, seems the process is very heavy just for changing the login screen background, rite? what if you want to change the background Image or color of the Login screen frequently?

Workaround
for changing login background with Image/ Color/ Gradient Horizontal/Vertical with a script.

you can download the ubuntu-gdm-set-background file via command line

wget -qO - https://github.com/PRATAP-KUMAR/ubuntu-gdm-set-background/archive/main.tar.gz | tar zx --strip-components=1 ubuntu-gdm-set-background-main/ubuntu-gdm-set-background

Once you downloaded the script ubuntu-gdm-set-background.

Make sure you have installed the required package, libglib2.0-dev-bin.
If not installed, Install it with the command

sudo apt install libglib2.0-dev-bin

there are four options

background with image
background with color
background with gradient horizontal ( requires two valid hex color inputs)
background with gradient vertical ( requires two valid hex color inputs)

tip: be ready with valid hex color code in place of below example like #aAbBcC or #dDeEfF. Change them to your preferred hex color codes. you may choose colors from https://www.color-hex.com/

Example Commands:

sudo ./ubuntu-gdm-set-background --image /home/user/backgrounds/image.jpg
sudo ./ubuntu-gdm-set-background --color \#aAbBcC
sudo ./ubuntu-gdm-set-background --gradient horizontal \#aAbBcC \#dDeEfF
sudo ./ubuntu-gdm-set-background --gradient vertical \#aAbBcC \#dDeEfF
sudo ./ubuntu-gdm-set-background --reset
./ubuntu-gdm-set-background --help

try Ctrl+Alt+F1 to go the gdm screen to see the change.

If change does not appear, then restart gdm with below command

sudo systemctl restart gdm

5
  • 1
    Thanks. Will you be able to help with this thread: askubuntu.com/questions/1233580/… ? The 20.04 default log out/ power off screen had a cool blur effect with some nice icon and effects. I lost that and instead getting a dialog box. Any idea, how to restore that and choose the right setting to bring it back?
    – SubinR
    May 12, 2020 at 14:32
  • I tried Workaround 2 and specified background image path as /home/username/Pictures/mybackground.jpg but it did not appear on the login screen. On the other hand, when I saved the same image as /usr/share/backgrounds/mybackground.jpg then it was displayed as the background.
    – rpr
    Jul 28, 2020 at 16:22
  • Yes, /home/username is the path of my home directory. The problem is actually caused by the permissions of that directory: rwxrwx--- (770). The process that displays the login screen background probably runs as gdm user and so it cannot access the picture inside my home directory.
    – rpr
    Jul 28, 2020 at 18:21
  • Nice catch.....
    – PRATAP
    Jul 28, 2020 at 18:22
  • 2
    Thanks a lot. Workaround 2 worked.
    – Puspam
    Aug 11, 2020 at 8:24
12

Easy! Just download the script from https://github.com/thiggy01/ubuntu-20.04-change-gdm-background, chmod +x the script, run like this:

First, install this package:

sudo apt install libglib2.0-dev-bin

Now, run the script:

sudo ./Scriptname picturename

To restore default background:

sudo ./Scriptname --restore

This only works on 20.04.

3
  • when I tried to download the script from the link with the below command: curl -L -O github.com/thiggy01/ubuntu-20.04-change-gdm-background/raw/master/ubuntu-20.04-change-gdm-background I'm getting permission denied error!
    – SubinR
    May 12, 2020 at 13:58
  • Thanks for the post. The script already asks if you want to install libglib2.0-dev-bin. @SubinR try with wget github.com/thiggy01/ubuntu-20.04-change-gdm-background/raw/master/ubuntu-20.04-change-gdm-background.
    – thiggy01
    May 17, 2020 at 15:28
  • 1
    this is easiest foolproof solution for Ubuntu 20.04 Jun 19, 2020 at 12:07
1

You can use https://github.com/juhaku/loginized which is an elegant software to update GDM3 theme for Ubuntu 20.04. With this you can change gtk-theme, login screen background and screen shield wallpaper.

If you also want to change cursor-theme and icon-theme you can use gdm3setup.

Hope that helps!

1

On Ubuntu 22.04, this didn't work for me. The script kept giving me an error message. The solution that ended up being successful for me was simply using a few commands to login as GDM user and set the path to the image, as follows :

sudo machinectl shell gdm@ /bin/bash

Then

gsettings set com.ubuntu.login-screen background-picture-uri 'file:///usr/share/backgrounds/warty-final-ubuntu.png'

And finally logging out using

exit

This procedure is from a bug description which can be found at this link.

I'm using Ubuntu 22.04.3 on a brand new Framework 13 laptop. Processor is an AMD Ryzen 7784u. I post this here because I came across this page while looking for a way to change the login background to an image. So I guess it might help other people too :) .

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .