This seems to be surprisingly difficult information to find. Be warned, this post is scatterbrained.
Until now, the only way I knew to start a window manager from scratch was to run
# run X startx
Then running the manager explicitly:
# run Gnome gnome-session # run Unity unity # run i3wm i3
which caused the session to change. Historically you would run
gnome-session --replace or
unity --replace to actually replace the stock X session (or any other that was running), but this seems to be a thing of the past (Unity’s mentions the
--replace command is included for compatibility).
Well all along it turns out you colud have specified the window manager name as an argument to
Edit: Digging a little deeper, it turns out
startx is just a shell script wrapper around
xinit. This is where
.xinitrc seems to come in to play (
startx checks for it).
There’s a file
~/.xinitrc that seems important. Out of the box this file doesn’t exist, so it’s unclear how Ubuntu is deciding what window manager to use on login. That said, there are details for customizing it here:
There seems to be a file
~/.dmrc that says this:
Maybe this is important?
LightDM the Display Manager appears to be the owner of this file.
LightDM logs in using the session specified in the ~/.dmrc of the user getting logged in automatically.
LightDM is the display manager running in Ubuntu. It starts the X servers, user sessions and greeter (login screen). The default greeter in Ubuntu is Unity Greeter.
This above page details some other information that seems relevant.
Help, I can’t see my Desktop!
- You can get to a text terminal using
This seems to suggest a system is a setup something like:
- Display Manager (LightDM)
- Display Server (X11)
- Window Manager (whatever)
Suggesting the Display Manager is the fallback you rely on for getting a terminal even after everything is messed up (i.e. the
ALT+CTRL+Fx feature, when things go bad).
GDMSESSION can tell you what’s currently running.
printf 'Desktop: %s\nSession: %s\n' "$XDG_CURRENT_DESKTOP" "$GDMSESSION" # My i3wm session: Desktop: i3 Session: i3
This is just informational though. Source: https://askubuntu.com/a/227669.
Window managers in a container window? EDIT: Yes
I’ve seen Weston (the Wayland sample) running in a Window from another desktop.
In the above case they simply ran weston explicitly. Huh.
This seems a good way to develop.
EDIT: This seems to suggest the
weston command runs Weston in an X window: https://wiki.archlinux.org/index.php/wayland#Weston. The actual window manager is
Quickly digging through the code, it looks like they actually implemented an x11 window by hand. No external tool required. Just x11.
xnest and xserver-xephyr
It turns out these commands let you run X11 in a window, that you can then attach a window manager to.
# xephyr is probably already installed sudo apt install xnest xserver-xephyr`
According to humans:
xnest- it should allow OpenGL applications to work
xserver-xephyr- better (?) support for x11 features, except OpenGL is a software renderer
- supposedly you can use something called
virtualglto work around this, but there’s no stock Ubuntu package (there is a PPA though)
- supposedly you can use something called
Overwhelming Xephyr seems to be preferred, despite limitations.
Doing it seems to require a long command line and a config file.
I wouldn’t be surprised if I’m just looking at the wrong references. I would prefer something more like
Native x11 apps
I forgot that APIs like SDL, GTK+, and Qt are built on top of something. Here’s some references for creating a barebones X11 window.
Using an API is preferred, since it means we can rely on standards for theming.
-- symbol in a
xinit invocation separates arguments about the client to be run from the arguments to the x server itself.
startx CLIENT_ARGS -- SERVER_ARGS xinit CLIENT_ARGS -- SERVER_ARGS
startx- simple frontend to
xinit- x window system initializer https://www.x.org/archive/X11R6.7.0/doc/xinit.1.html
xserver- x server arg reference (i.e. things after
So given this as reference:
sudo startx gnome-session -- :1 vt2
This starts a
gnome-session client on display
:1 and TTY2 (i.e.
At least on my Ubuntu, the default display is
:0, so it’s important that you specify a different display for this.
Curiously it starts with an
xterm window open, and when you close it, it closes.
sudo startx unity -- :1 vt2 doesn’t actually work.
gnome-session sessions are stored here:
ll /usr/share/gnome-session/sessions/ -rw-r--r-- 1 root root 767 Oct 6 00:30 gnome-flashback-compiz.session -rw-r--r-- 1 root root 771 Oct 6 00:30 gnome-flashback-metacity.session -rw-r--r-- 1 root root 701 Oct 11 12:57 gnome-login.session -rw-r--r-- 1 root root 2185 Oct 13 07:33 gnome.session -rw-r--r-- 1 root root 692 Oct 13 07:33 ubuntu.session -rw-r--r-- 1 root root 101 Oct 13 07:33 unity.session
[GNOME Session] Name=Unity RequiredComponents=unity-settings-daemon; DesktopName=Unity:Unity7:ubuntu
[GNOME Session] Name=Display Manager RequiredComponents=org.gnome.Shell;org.gnome.SettingsDaemon.A11yKeyboard;org.gnome.SettingsDaemon.A11ySettings;org.gnome.SettingsDaemon.Clipboard;org.gnome.SettingsDaemon.Color;org.gnome.SettingsDaemon.Datetime;org.gnome.SettingsDaemon.Housekeeping;org.gnome.SettingsDaemon.Keyboard;org.gnome.SettingsDaemon.MediaKeys;org.gnome.SettingsDaemon.Mouse;org.gnome.SettingsDaemon.Power;org.gnome.SettingsDaemon.PrintNotifications;org.gnome.SettingsDaemon.Rfkill;org.gnome.SettingsDaemon.ScreensaverProxy;org.gnome.SettingsDaemon.Sharing;org.gnome.SettingsDaemon.Smartcard;org.gnome.SettingsDaemon.Sound;org.gnome.SettingsDaemon.Wacom;org.gnome.SettingsDaemon.XSettings;
gnome.session (basically the same)
[GNOME Session] Name=Ubuntu RequiredComponents=org.gnome.Shell;org.gnome.SettingsDaemon.A11yKeyboard;org.gnome.SettingsDaemon.A11ySettings;org.gnome.SettingsDaemon.Clipboard;org.gnome.SettingsDaemon.Color;org.gnome.SettingsDaemon.Datetime;org.gnome.SettingsDaemon.Housekeeping;org.gnome.SettingsDaemon.Keyboard;org.gnome.SettingsDaemon.MediaKeys;org.gnome.SettingsDaemon.Mouse;org.gnome.SettingsDaemon.Power;org.gnome.SettingsDaemon.PrintNotifications;org.gnome.SettingsDaemon.Rfkill;org.gnome.SettingsDaemon.ScreensaverProxy;org.gnome.SettingsDaemon.Sharing;org.gnome.SettingsDaemon.Smartcard;org.gnome.SettingsDaemon.Sound;org.gnome.SettingsDaemon.Wacom;org.gnome.SettingsDaemon.XSettings;
I don’t know how this helps us yet, but meh.
Supposedly this works:
sudo startx gnome-session --session=ubuntu -- :1 vt2
EDIT: No, but that said I think it’s just exiting right away.
--session seems to be what starts the
xterm, and given the lack of errors it looks more like there was no application loaded that needed to load, so the
gnome-session ended early.