Monster!! (WIP)

This time, is the time for monsterwm. Lately I use this minimalist wm, yes it’s a tiling wm, and figure something out. Monsterwm is awesome. It comes with pre-config. Much like dwm, you must config the wm before compile it so you can use it. I don’t really like the concept of pre-config wm at first. I think, such a pain in the ass. We must make, make install, then log out from X and relogin. But after using it for a while, I found this wm is pretty customizable.


What I want, is to make this clone of xmonad desktop using some other wm. For that, I will use monsterwm with some of its pre-configuration and make another desktop that resembles it.

xmonad with the song of bump of chicken - knife


Okay, let’s move to the documentation

First, you clone it using git. In this case, I’m using its branch ‘uselessgap’ so I can add a Gap between each window that stacked.

credit to c00kiemon5ter for making this awesome wm.

$ git clone https://github.com/c00kiemon5ter/monsterwm.git
$ cd monsterwm
$ git checkout uselessgap
$ cd monsterwm

If you ls inside its directory, you can see there is config.def.h. Or usually just config.h. It’s okay. We will just proceed to the next step. Configuring monsterwm’s pre-config.

(~/g/monsterwm) (master) ls
config.def.h  config.h  LICENSE  Makefile  monsterwm.1  monsterwm.c  README.md


Edit config.h or config.def.h using your favorite editor. I’m using vim, just so you know. Inside, we will stumble upon many line of code, so I will skip some code, and just edit the ones that i need.

 1 /** modifiers **/
 2 #define MOD1            Mod1Mask
 3 #define MOD4            Mod4Mask
 4 #define MOD5            Mod5Mask
 5 #define CONTROL         ControlMask
 6 #define SHIFT           ShiftMask
 7 
 8 /** generic settings **/
 9 #define MASTER_SIZE     0.76
10 #define SHOW_PANEL      True
11 #define TOP_PANEL       True
12 #define PANEL_HEIGHT    16
13 #define DEFAULT_MODE    TILE
14 #define ATTACH_ASIDE    True
15 #define FOLLOW_WINDOW   False
16 #define FOLLOW_MOUSE    False
17 #define CLICK_TO_FOCUS  True
18 #define FOCUS_BUTTON    Button3
19 #define BORDER_WIDTH    3
20 #define FOCUS           "#181818"
21 #define UNFOCUS         "#141414"
22 #define MINWSZ          50
23 #define DEFAULT_DESKTOP 0
24 #define DESKTOPS        3

I define MOD1, MOD4, and MOD5 for altkey, superkey, and I already forgot what MOD5 means respectively. As you can see we can define anything in that header file. Underneath that code, we can find many keybindings configuration. So, I will leave that area in your preferences. I only change small parts for keybindings.

 1 static const char *menucmd[]	   = { "dmenu_run", "-fn", "terminus 9", NULL};
 2 static const char *filecmd[]	   = { "pcmanfm", NULL };
 3 static const char *termcmd[]	   = { "termite", NULL };
 4 static const char *webcmd[]	   = { "dwb", NULL };
 5 
 6 --- and so on
 7 
 8 /**
 9  * keyboard shortcuts
10  */
11 static Key keys[] = {
12     /* modifier		key            function           argument */
13     {  MOD1,            XK_p,          spawn,             {.com = menucmd}},
14     {  MOD1,            XK_w,          spawn,             {.com = webcmd}},
15     {  MOD1,            XK_t,          spawn,             {.com = filecmd}},
16     {  MOD1|SHIFT,      XK_Return,     spawn,             {.com = termcmd}},
17 
18 --- and so on


Aaaaand, we’re done. Just type make and then sudo make install in your terminal to make our ‘configed’ monsterwm on the run.

What now? If we try our monsterwm, it’s just a blank screen with some control of window. There will be no bar, no wallpaper, and no, I don’t like emptiness. So, the next step is to costumize the bar, the wallpaper, and the other complimentaries to make this wm okay to use.

For the top panel, I will use LemonBoy’s bar. It’s like dzen2, but with its own plus minus. You can use whatever panel you want. The configuration is pretty easy I think. There is no xft support on the LemonBoy’s bar, so if you want something that has xft support, you can use dzen2 or raedwulf’s version of bar with full xft support. Your choice.


Okay, we will begin.

First, monsterwm is not xmonad. So we must config it before start it. Means, we have to parse some of its output and change it. Confusing? I can’t tell you what actually I mean, so let’s just make some code. May the Code bless us with its understanding. I will make startup file to launch monsterwm and it’s complimentaries.

 1 ff="/tmp/monsterwm.fifo"             # this part is to parse the output of monsterwm
 2 [[ -p $ff ]] || mkfifo -m 600 "$ff"  # running on the wild
 3 
 4 xset +fp ~/.fonts/custom/ &          
 5 xset fp rehash &
 6 ~/.fehbg &
 7 compton -f -D8 -I0.05 -O0.05 &
 8 xsetroot -cursor_name left_ptr &
 9 sh ~/.wm/monsterwm/status.sh &
10 devmon &
11 wmname LG3D &
12 
13 # and above is just what i usually run side to side with most of my wm


And the rest is to put the output of our parsing into bar. For now, I’m too lazy to explaining what in the name of hell is the meaning of this code. Maybe later when I’m not busy.

 1 while read -r; do
 2     # filter output to only what we want to match and parse
 3     [[ $REPLY =~ ^(([[:digit:]]+:)+[[:digit:]]+ ?)+$ ]] && read -ra desktops <<< "$REPLY" || continue
 4     
 5     for desktop in "${desktops[@]}"; do
 6         # set values for
 7         # d - the desktop id
 8         # w - number of windows in that desktop
 9         # m - tiling layout/mode for that desktop
10         # c - whether that desktop is the current (1) or not (0)
11         # u - whether a window in that desktop has an urgent hint set (1) or not (0)
12         IFS=':' read -r d w m c u <<< "$desktop"
13  
14         # name each desktop 
15         case $d in
16             0) d=" term" s=" "   ;;
17             1) d=" web" s=" " ;;
18             2) d=" fun" s=" " ;;
19 	    3) d=" work" s=" " ;;
20         esac
21  
22        # name each layout/mode with a symbol underline=FF364069
23 	((c)) && b="#FF272727" u="#FFA93432" && case $m in
24             0) i="  %{B#FF333333}  %{B}" ;;
25             1) i="   ⮘ " ;;
26             2) i="  [B]" ;;
27             3) i="  [G]" ;;
28         esac  || b="#FF161616" u="#FF161616"
29  
30         # if the desktop has an urgent hint its color should be #ff0000
31         ((u)) && b="#FFFF7871"
32  
33         # if the desktop has windows print that number next to the desktop name
34         # else just print the desktop name
35         ((w)) && r+="%{B$b}%{U$u}%{+u} $d %{F#FF3E3E3E}[$w]%{F} %{-u}%{B}" || r+="%{B$b}%{U$u}%{+u} $d %{F#FF3E3E3E}[-]%{F} %{-u}%{B}"
36     done
37     # read from fifo and output to dzen2
38     printf "%s%s\n" "$r" "$i" && unset r
39 done < "$ff" | bar -p -d -g 300x17+0+0 -f '-*-stlarch-*-*-*-*-10-*-*-*-*-*-*-*,-*-lemon-*-*-*-*-10-*-*-*-*-*-*-*' -u 3 -B '#FF161616' -F "FF9A9A9A"&
40  
41 # pass output to fifo
42 monsterwm > "$ff"


The code above will make the bar look like this.

monsterbar

Next, we will try to make statusbar beside the main bar. My purpose is to make something like the following screenshot. Including the wallpaper, terminal (which is rxvt-unicode), and the other complimentaries that running in the terminal. Here is the screenshot what it has to be if we continue tweaking.

monsterwm


You can get the codes above here Monster!!