The challenge is, to process Hersbtclient Idle Event
HerbstluftWM event produced by
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.
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.
This is a three tier pipes, just like Dzen2, except Lemonbar pipe clickable areas to a shell.
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 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.
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.
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).
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
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.
HerbstluftWM Tag Status: Statusbar (not this article) Focusing on tags:
HerbstluftWM Event Idle: Advance Pipe and Fork (this article) Focusing on event:
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.
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.
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.
Zero Gap, Dual Panel.
The rest is in their respective article.
Let's get it started.
Dotfiles (Dzen2 Source Code)
Dotfiles (Lemonbar Source Code)
Thank you for Reading.