Remote X11 Window Manager on XQuartz

It is relatively easy to forward an individual X11 application to the XQuartz X server running on macOS. However, what if you want to forward a window manager altogether? Conceptually it is simple because a window manager is just another X application, but there are some details which is the purpose of this post.

If you install XQuartz and try to start twm on a remote machine, it will likely complain something about not being able to control the root window. A window manager needs to take control of the root window, or your entire display, because it is supposed to manage the windows on that display for you. In the preferences of XQuartz, you will find an option under the “Output” panel that says “Full-screen mode”, and its description says that the option enables the X11 root window. However, if one simply enables that option and retries, twm will still complain. This is because XQuartz’s default xinitrc script starts a window manager1 for us when XQuartz is started. Let’s take a look.

The xinitrc script lives in /opt/X11/etc/X11/xinit. The first half of the script is to load the configuration which we do not need to touch. The stuff towards the end are the interesting bits.

# start some nice programs

if [ -d /opt/X11/etc/X11/xinit/xinitrc.d ] ; then
	for f in /opt/X11/etc/X11/xinit/xinitrc.d/?*.sh ; do
		[ -x "$f" ] && . "$f"
	unset f

twm &
xclock -geometry 50x50-1+1 &
xterm -geometry 80x50+494+51 &
xterm -geometry 80x20+494-0 &
exec xterm -geometry 80x66+0+0 -name login

It executes each of the scripts in /opt/X11/etc/X11/xinit/xinitrc.d, and then starts a bunch of applications, one of them being twm, a window manager. As mentioned earlier, a window manager needs to take control of the root window. If a window manager started by XQuartz already took control of the root window, the window manager running on the remote machine will have no root window to control. We should disable this behavior by commenting out the line.

Meanwhile, let’s also take a look at the scripts in /opt/X11/etc/X11/xinit/xinitrc.d. There are three scripts:,, and The first one loads fonts, which we do not need to touch. The second one runs any script present in ~/.xinitrc.d, which is also fine. The third one, on the other hand, tries to start the quartz-wm. It is a window manager that delegates to the native macOS window manager so the X windows look alike native applications. Because this is also a window manager, we should disable it as well by renaming the file to something that does not end with .sh.

It might be tempting to also disable the various other applications that XQuartz starts, like xclock and xterm. However, make sure that you leave at least one application running, otherwise XQuartz will quit immediately because it has no active window.

Now, if you try to start twm on a remote machine to which your local XQuartz X server is forwarded, twm should no longer complain, and XQuartz should display the window manager running on the remote machine in its full glory, like in this screenshot.

As a side node, sometimes you might need to install additional fonts on your remote machine. For example, for cwm to work in its default configuration, I needed to install xorg-fonts.

  1. Two, actually. As you will soon see, the script tries to start quartz-wm and twm in sequence. Of course only one of them (the first one) will successfully start. [return]