How to use Xephyr for Window Manager Development

Search for a command to run...

No comments yet. Be the first to comment.
Remember my post about switching to VSCode? Well, plot twist: the very next day after publishing it, I switched to WebStorm. And guess what? I've been on JetBrains IDEs ever since. I know, I know. Another "why I switched editors" post. But hear me ou...

I had been doing some basic interpreter work in Go and wanted to redo it in another language to solidify my understanding. Naturally, I chose Odin, it’s another great language, with a Go-like, easy-to-approach syntax and no unnecessary complexity. I ...

Why Emacs Keybindings? I've always preferred Emacs-style editing, especially the way it handles cursor movement and text manipulation. Even though I have switched to using VSCode for most of my development work, I often found myself missing the intui...

In my previous post about building C/C++ projects with CMake, I shared a simple CMakeLists.txt setup for compiling a basic project. Today, I’ll dive into a specific need that many developers encounter: linking libraries directly from project folders ...

Some time ago, I wrote a post about using Vim to look cool and why that’s not a good idea. Now, funny enough, here I am—having switched to VSCode after years of hopping between Vim and Emacs. This isn’t one of those "Vim sucks, I'm going back to VSCo...

To future me:
You don't need to install Arch Linux on your laptop or buy a new laptop or install it on a vm to try window management development. Xephyr is just enough for testing the basics. Just make sure you press Ctrl + Shift to lock focus when trying to do any binding in the window manager been tested.
The most basic command to start the window manager in a nested session is to do something like
startx i3 -- /usr/bin/Xephyr :1
# with specifying window size
startx i3 -- /usr/bin/Xephyr -screen 800x500 :1
just make sure to use the full path to the Xephyr.
Above method works, but most of the times when you are just starting out you may not have a way to launch apps inside the window manager. For that using a keybinding agent like sxhkd will be very useful. To do that we need to be able to run other programs besides the window manager while launching.
To do that we can use a xinitrc to add the programs we need to launch.
so we can create a xinitrc file with the following content.
sxhkd ~/.config/sxhkd/sxhkdrc &
xterm & # also launching a terminal just in case
# assuming the window manager
# executable is called main and is in the current directory
exec ./main
then you can also have another script to call xinit and open Xephyr with the relevant options
#!/bin/sh
set -e
#!/bin/sh
set -e
make # just calling make to build the project once more,
# so we can just use this one script to just build and run
XEPHYR=$(which Xephyr)
xinit ./xinitrc -- \
"$XEPHYR" \
:100 \
-ac \
-screen 800x500 \
-host-cursor