Skip to content

Example Setup

Samuel Hand edited this page Mar 8, 2016 · 7 revisions

This is a brief tutorial on how to setup use x11fs to create your own standalone window manager. sxhkd will be used as the keybinding daemon.

This tutorial assumes you start X using startx with a .xinitrc file. Although you could probably carry this over fairly simply to a script for a display manager I don't know exactly how to do that. Please edit this page if you do.

First off, install x11fs like so:
git clone https://github.com/sdhand/x11fs
make
sudo make install

Then install sxhkd. This may well be in your distros repositories.

Next create an sxhkd configuration file, by default this should live in .config/sxhkd/sxhkdrc a very small example configuration file is provided below

#run a terminal
super + Return
    urxvt

#Close a window
super + q 
    WID=$(cat $X11FS/focused); \
    rmdir $X11FS/$WID

#Move a window
super + h 
    WID=$(cat $X11FS/focused); \
    POS=$(cat $X11FS/$WID/geometry/x) ; \ 
    echo $(($POS-6)) > $X11FS/$WID/geometry/x

super + j 
    WID=$(cat $X11FS/focused); \
    POS=$(cat $X11FS/$WID/geometry/y) ; \ 
    echo $(($POS+6)) > $X11FS/$WID/geometry/y

super + k 
    WID=$(cat $X11FS/focused); \
    POS=$(cat $X11FS/$WID/geometry/y) ; \ 
    echo $(($POS-6)) > $X11FS/$WID/geometry/y

super + l 
    WID=$(cat $X11FS/focused); \
    POS=$(cat $X11FS/$WID/geometry/x) ; \ 
    echo $(($POS+6)) > $X11FS/$WID/geometry/x

#exit
super + Escape
    pkill -f "bash -c cat $X11FS/event | focuser"

You then want to copy paste this script to somewhere on your path, and call it focuser

while IFS=": " read ev wid; do
case $ev in
	# Focus new windows
	CREATE) $(<$X11FS/$wid/ignored) || echo $wid > $X11FS/focused ;;

	# Mapping requests
	MAP) $(<$X11FS/$wid/ignored) || echo $wid > $X11FS/focused  ;;

	# Focus entered window
	ENTER)  $(<$X11FS/$wid/ignored) || echo $wid > $X11FS/focused ;;
esac
done

Finally, tie this all together in a .xinitrc

export X11FS=<your mointpoint here>
x11fs $X11FS
sxhkd &
bash -c "cat $X11FS/event | focuser"
fusermount -u $X11FS

When you run startx, you should be able to use super+Enter to start a terminal, super+{h,j,k,l} to move windows around and super+q to close a window. Windows will automatically focus when you mouse over them.

The next step would be to add bindings to resize windows. I leave this as an exersize to the reader.

Clone this wiki locally