Table of Content

This article is one part of a collection. All integrated, one related to another, featured with summary. So we can compare each other quickly.

Tutorial/ Guidance/ Article:

[ Event Idle Overview ]  [ BASH ]  [ Perl ]  [ Python ]  [ Ruby ]  [ PHP ]  [ Lua ]  [ Haskell ]

Example Using Dzen2:

[ BASH ]  [ Perl ]  [ Python ]  [ Ruby ]  [ PHP ]  [ Lua ]  [ Haskell ]

Example Using Lemonbar:

[ BASH ]  [ Perl ]  [ Python ]  [ Ruby ]  [ PHP ]  [ Lua ]  [ Haskell ]


The challenge is, to process Hersbtclient Idle Event

HerbstluftWM event produced by --idle command. Event based statusbar require us to create our own tools, to manage the flow from one process, and pipe the output to other process.

Interval based itself could be considered as timer event. To combine both herbstluftWM idle event and interval event, we need to create our own event producer.

$ herbstclient --idle

HerbstluftWM: Event Idle


How many Pipes ?

In shell it is basically just a pipe:


This is a two tier pipes, since content processing happened between pipe. The content processing itself is a complex part. And there are some pipe and fork combinations as well.

herbstclient --idle | content_processing | dzen2


This is a three tier pipes, just like Dzen2, except Lemonbar pipe clickable areas to a shell.

herbstclient --idle | content_processing | lemonbar | sh


The requirement of Dzen2 is unidirectional, it means one way communication. Simple.

The idle event as an input, feed the content process, the content process produce an output to Dzen2. While Dzen2 process act as a writer, idle event process act as a reader.


The requirement of Lemonbar is bidirectional, it means tow ways communication. Lemonbar read input and write output at the same time. Lemonbar process act as a reader and writer in the same time.

For each language we must carefully chose Pipe methods, that support bidirectional, since most pipe only support unidirectional.

Content Process

Content process live in an infinite loop which write to statusbar whether it is Dzen2 or Lemonbar. This has no issue with unidirectional loops But this create an issue in a application logic for bidirectional Lemonbar, which has another loop to write to shell.

Both loops live at the same time. There is no loop notation sufficient, to implement this complex logic, without blocking each other. The solution is to fork the infinite loop as a new process, outside the shell loop.

Combined Event

What if we want to put other stuff in our lovely panel, such as date? Or any system monitoring information such as CPU, Memory, HDD, temperature, uname or even MPD? This is an overview of what we want to achieve.

Statusbar: Event Screenshot

These system monitoring is usually called in interval based. Date can be based on one second interval. And other stuff can be groupped in longer interval. And uname called only once, or one hour interval if you wish.

Luckily we can treat these interval as event. Consider this combined event, consist of idle event (asynchronous) and interval event (synchronous).

combined_event | content_processing | statusbar

HerbstluftWM: Custom Event

Since we need to alter the original event, to create new combined event, sometimes we need an intermediate process. As an intermediate process in Perl, PHP, Ruby, and Haskell, we need to pipe both loop, into cat.

Since both event also loops that write in the same time, as the intermediate process being read. We need to fork both loop.

Multi Language Implementation

The original script has beenported from BASH, Perl, Python, Ruby, PHP, Lua, and finally the compiled Haskell.

Why Port ?

Because Piping and Forking is a very interesting topic. Challenging, and no sufficient tutorial in internet, especially for real life example. That is why I’m eager to pour them down in a blog.


You might desire to read previous post, that contain the basic of this tutorial, with simple example.

What is not in this Guidance

No Window Manager in this tutorial.

Separate Window Manager Tutorial, and Statusbar Tutorial.

One of the most complex part of Window Manager is Statusbar. It is considered third party. It deserve its own article. And I did wrote a specific article exploring statusbar.

The code given is complete, but I breakdown the tutorial into two parts.

  1. HerbstluftWM Tag Status: Statusbar (not this article) Focusing on tags: herbstclient tag_status

  2. HerbstluftWM Event Idle: Advance Pipe and Fork (this article) Focusing on event: herbstclient --idle

This will only discuss about Piping and Forking.

Dzen2 or Lemonbar.

What Statusbar ?

Lemonbar, as it is a continuation of previous part using Lemonbar.

Source code is available for both Dzen2 and Lemonbar.


. I accidentaly find a surprising performance, between using dual lemonbar and dual dzen2bar. Just see the CPU performance in percentage.

  • Dzen2: HerbstluftWM: Dzen2 Conky

  • Lemonbar: HerbstluftWM: Lemonbar Conky


I currently do not have multiple monitor to test yet.

Puting it all together.

I also created compact for version, for use with main HerbstluftWM configuration.

Directory Structure

The idea is Focus

We only use output script. But the tutorial will show the output script step by step, from simple code to the final form.

The project itself separated into panel, pipehandler, helper, output, gmc.

├── panel
├── 01-testparams
├── 02-testoutput
├── pipehandler
├── helper
├── output
└── gmc


Zero Gap, Dual Panel.

HerbstluftWM: Screenshot Dual Panel

Blog Post

The rest is in their respective article.

Let's get it started.

Dotfiles (Dzen2 Source Code)

Dotfiles (Lemonbar Source Code)

Thank you for Reading.