Goal: A script that continuously show date and time, with Dzen2, and Conky.
Before you dip your toe to scripting, you might desire to know the reason by reading this overview.
Piping and Forking in Many Languages
This article is one part of a collection. All integrated, one related to another. So we can compare each other quickly.
A Very Bashful Start
Welcome to n00berland. Begin with simple script. We will use this loop as a source feed to pipe. This step won’t introduce Pipe nor Fork.
This script only show an infinite loop showing local time.
Each updated in one second interval.
We manage this interval by delaying,
Call to this simple code would produce time marching, one after another, below the command line prompt.
Port to other Language
I respect the reader, that you are smart.
You might be wondering, why I have to put
this very basic script in this tutorial.
This script may looks simple in BASH,
and have very similar looks in most popular scripting language.
But it would have very different approach in other language.
As you can see in an obscure language below,
Haskell has no loop, but using
External Command as Source Feed
Beside previous simple loop that is used as Internal Command,
this tutorial also provide Conky as External Command
I made it as simple as possible.
A Native Pipe Between External Command
This step is overview of Pipe between two external command.
This is a very simple. Only using
This very short script is using
as pipe source feed and
less as pipe target.
Showing time and date forever in the console.
This infinite pipe run in time-less fashioned.
I had made additional dirname function, relative to the BASH source, to locate the conky script assets.
You can see, how simple it is.
This would have
less output similar to this below.
Your wallpaper might be different than mine.
A Native Pipe from Internal Function
Using internal function as source feed to external command is straight forward. This should be self explanatory.
Other language has more complex mechanism for this.
Most common is using
From this step forward, this would looks different in other language.
Fork in bash is also simple.
All it takes is just
This step use internal function as source feed, as continuation of previous step.
This step use dzen2, with complete parameters. This dzen2 is forked, running in the background. Detached from the script, no need to wait for dzen2 to finish the script.
This step also add system command that kill any previous dzen2 instance. So it will be guaranteed, that the dzen2 shown is coming from the latest script.
Fork Code in Function
Let’s have a look again at the line below. It is the heart above script.
In more complex situation that need more flexibility,
we can separate the pipe
| in different function.
Polishing The Script
This step, we use conky again, as a source feed. And also parameterized dzen2 as continuation of previous step.
This step add optional transset transparency, detached from script. So we have two forks, dzen and transset.
Finally, we have this complete script.
This would have
dzen2 output similar to this below.
You may use transset-df instead of transset.
I also provide Lemonbar, instead of Dzen2. The code is very similar.
Coming up Next
There already an advance case of Pipe and Fork. Multitier, and bidirectional.
There above are some simple codes I put together. I’m mostly posting codes so I won’t have any problems finding it in the future.
Thank you for reading.
- August 2017
- July 2017
- June 2017
- May 2017
- Piping and Forking Overview
- Debugging Conky
- Piping and Forking in Haskell
- Piping and Forking in Lua
- Piping and Forking in PHP
- Piping and Forking in Ruby
- Piping and Forking in Python
- Piping and Forking in Perl
- Standalone Lemonbar Using Conky
- Getting XLFD Font
- Standalone CLI System Monitoring Using Conky
- Standalone Dzen2 Statusbar Using Conky
- Standalone Statusbar Overview
- Create XBM for your Dzen2
- Standalone Dzen2 Statusbar Using BASH