TIL: How to Start Gnome Wayland Session From TTY

info: Better Version

veganomy posted a better version: https://github.com/hmajid2301/blog/issues/2

Copy org.gnome.Shell.desktop file locally:

snippet.txt
$ cp /usr/share/applications/org.gnome.Shell.desktop ~/.local/share/applications/org.gnome.Shell-Wayland.desktop
text 1 line
"snippet.txt" 1L

Edit it so that it so that it runs gnome-shell as a wayland compositor:

snippet.txt
$ less ~/.local/share/applications/org.gnome.Shell-Wayland.desktop
...
Exec=/usr/bin/gnome-shell --wayland
...
text 4 lines
"snippet.txt" 4L

Copy gnome.session file locally:

snippet.txt
$ cp /usr/share/gnome-session/sessions/gnome.session ~/.config/gnome-session/sessions/gnome-wayland.session
text 1 line
"snippet.txt" 1L

Edit it to use org.gnome.Shell-Wayland:

snippet.txt
$ less ~/.config/gnome-session/sessions/gnome-wayland.session
...
RequiredComponents=org.gnome.Shell-Wayland;gnome-settings-daemon;
...
text 4 lines
"snippet.txt" 4L

Now create an executable ~/.local/bin/gnome :

snippet.txt

#!/bin/sh

[ -r /bin/gnome-session ] && {
	export \
		EGL_PLATFORM=wayland \
		GDK_BACKEND=wayland \
		XDG_SESSION_DESKTOP=gnome
	/bin/gnome-session --session=gnome-wayland
}
text 10 lines
"snippet.txt" 10L

Make sure this directory is in your ~/.bash_profile $PATH : export PATH=~/.local/bin:$PATH

Now you can run a wayland session through TTY :

snippet.txt
$ gnome
text 1 line
"snippet.txt" 1L

Recently, I moved to Hyprland on Ubuntu. I wanted to start gnome in another TTY (teletype). It was more effort to find than I expected:

snippet.sh
# Go to teletype
CTRL+ALT+1

dbus-run-session -- gnome-shell --display-server --wayland
bash 4 lines
"snippet.sh" 4L

That’s it, short and sweet, this post! You now started gnome in a Wayland session.