Score:1

How to use the default Yaru Gnome-Shell theme on Ubuntu 21.04 in a Gnome session?

de flag
DMT

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?

Score:2
br flag

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.

DMT avatar
de flag
DMT
Thanks, that did the trick! I've used these commands `mkdir -p ~/.themes/YaruExtracted/gnome-shell` followed by `gresource extract /usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource /org/gnome/shell/theme/Yaru/gnome-shell.css > ~/.themes/YaruExtracted/gnome-shell/gnome-shell.css`.
DMT avatar
de flag
DMT
BTW, I assume, that the source file of the Yaru Gnome-Shell theme is updated regularly, therefore I have to periodically extract the updated theme too? If yes, is there a proper way for the extraction when the source has changed?
br flag
I Understand your point. I Will see how best it can be automated. Will get back soon.
br flag
@DMT I have edited the Answer. Please go through it and comment back.
DMT avatar
de flag
DMT
Thank you for this very detailed explanation!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.