Gnome Themes – How to Use Default Yaru Gnome-Shell Theme on Ubuntu 21.04

gnomegnome-shellthemes

I did a fresh Ubuntu 21.04 installation, installed the Gnome session (sudo apt install gnome-session), restarted, selected Gnome (tried Wayland and X11) in the login window (where you have to enter the user password to log into the system), installed Gnome-Tweaks (sudo apt install gnome-tweaks) and Gnome-Extensions (sudo apt install gnome-shell-extensions) in order to be able to change the Gnome-Shell theme.

But to my surprise, the dropdown for the Gnome-Shell theme in Gnome-Tweaks shows only Default (this is the Adwaita theme, because I'm using the Gnome session) and Yaru Light.

If I change to the Ubuntu session at startup, I see the same two entries, but the Default theme is now Yaru (the dark version), because I'm in the Ubuntu session.

My question is: Is it possible to use the Yaru Gnome-Shell theme (the dark one) under the Gnome session in Ubuntu 21.04? If yes, then how, preferably without using additional resources, because the Yaru Gnome-Shell theme is already installed, but can't be accessed?

Best Answer

Disclaimer: if any mistakes in below procedure, will lock down to login-loops in gdm3 login screen. In such case you need to choose Ubuntu or Ubuntu Xorg sessions and edit the changes.

create three local directories with below command

sudo mkdir -p /usr/local/share/xsessions /usr/local/share/wayland-sessions /usr/local/share/gnome-shell/modes

copy the GNOME and GNOME on Xorg desktop files to above first two directories.

sudo cp /usr/share/xsessions/gnome-xorg.desktop /usr/local/share/xsessions/
sudo cp /usr/share/wayland-sessions/gnome.desktop /usr/local/share/wayland-sessions/

Open the above files, I am showing the example for one file below

sudo nano /usr/local/share/xsessions/gnome-xorg.desktop

need to edit the Exec= line from below content

[Desktop Entry]
Name=GNOME on Xorg
Comment=This session logs you into GNOME
Exec=/usr/bin/gnome-session --session=gnome
TryExec=/usr/bin/gnome-session
Type=Application
DesktopNames=GNOME
X-GDM-SessionRegisters=true
X-Ubuntu-Gettext-Domain=gnome-session-3.0

Exec= line should be edited as below.

Exec=env GNOME_SHELL_SESSION_MODE=myyaru /usr/bin/gnome-session --session=gnome

copy the ubuntu.json file from /usr/share/gnome-shell/modes/ to /usr/local/share/gnome-shell/modes/ directory and rename to myyaru.json with below command

sudo cp /usr/share/gnome-shell/modes/ubuntu.json /usr/local/share/gnome-shell/modes/myyaru.json

Edit the above file to have the below content.

sudo nano /usr/local/share/gnome-shell/modes/myyaru.json

Content:

{
    "parentMode": "user",
    "stylesheetName": "Yaru/gnome-shell.css",
    "themeResourceName": "/theme/Yaru/gnome-shell-theme.gresource"
}

All set, now we need to create a symbolic link to /usr/share/gnome-shell/theme in /usr/local/share/gnome-shell directory.

sudo ln -s /usr/share/gnome-shell/theme /usr/local/share/gnome-shell/theme

A re-login should take the effect, if not, reboot.

This way you dont need to worry about the yaru theme package updates. because you are having the symbolic link in local directory.

Exec= line can be changed in gnome.desktop in /usr/local/share/wayland-sessions too.

Now the "Default" theme becomes Yaru.

enter image description here

enter image description here

Note:
The tweaking is not limited like paths, file names, configs etc.
The above procedure suites your requirement.