We can improve XMonad configuration, by removing extensive use of conky. Everytime I look at XMonad dotfiles, conky is used as a feed to dzen2 in statusbar. I can understand the need of using conky-dzen tier from portability between WM perpective. But portability have its drawback.

Removing Conky Dependency between XMonad and Dzen2

Conky is completely unnecessary, and you can replace conky with simple while sleep do bash script.

 $ while sleep 1; do date +'%a %b %d %H:%M:%S'; done | \
   dzen2 -ta r -h 25 -y -30 -w 200 -x -200

The second issue with conky is total control of color for theming. There is no way that xmonad configuration could alter colors inside conky. All colors should be in haskell variables, not as a constant inside the conky, nor inside bash script.

csbdTopBackground = "echo '^fg("++dcColor++")^p(;-10)^r("++screenWidth++"x5)' |"
    ++ " dzen2 -ta c -h 35 -w "++screenWidth++" "
    ++ dzenArgs ++ dzenColors

So here we are, the result os porting bunch of conkys and bash-scripts, and bundle it inside just one haskell script.

Source:


Screenshot Information
OS: Arch
+ WM: XMonad
+ Compositor: Compton
+ Statusbar: Dzen2 without Conky
+ Terminal: Termite
+ Viewer: VIM (Vi IMproved)

Conkyless XMonad: Comparation of Alsa Script

Let’s compare this code, and see how our code transformed.

  • That one right side console box contain haskell script for conkyless statusbar.

  • Those two left side console boxes contain conky and bash script.



There always a challenge. If you think that the script above is not easy to be read.

Yes, It is.

scriptMem = "\
 \  echo -n '^fg("++spColor++"):: ^fg()\
    \^i(.xmonad/assets/monitor/mem.xbm) ';\
 \  mem_total=$(free | awk 'FNR == 2 {print $2}');\
 \  mem_used=$(free | awk 'FNR == 2 {print $3}');\
 \  echo -n $[$mem_used * 100 / $mem_total];"


As you can see, each line is a bash command inside haskell. So the next step is to make the sleep loop as a native haskell script.

And pipe the native IO process to dzen2.


Well. As a haskell n00b. I must admit still don’t know how to do it.