Preface
Goal: A guide how to write Dzen2 in Conky.
This is the continuation of dzen2 guidance. I case you have been missed it. Last week I have wrote a basic dzen tutorial using bash. And now we are going to continue with conky. It is much easier.
Article:
Reading:
Table of Content
-
Preface: Table of Content
1: Hello World in Command Line
Conky has evolved. Now conky configuration is a Lua script. So we are going to talk about Lua programming language here. And forget about the old conky style.
Reading:
Let’s do our very first conky.
Source:
There are two parts on that script above.
The conky.config
and the conky.text
.
The config will be persistent during this guidance
since we only need conky capability to dump text.
And we are going to do a lot with this text.
Now let’s run this conky. Conky will dump a formatted time text every one second interval. on the command line.
And see how the output goes through the nice command line interface.
It means you can debug your output via command line interface.
2: Simple conky-dzen2 in Script
Let’s show a simple dzen2 statusbar by put this conky
in a script conky-example/01.sh
.
Source:
Each code lines in script should be self explanatory. If you do not understand what each line does, you should go back to our previous lesson. There few things covered:
-
Pipeline in command line interface
-
Dzen2 parameters
-
BASH scripting
-
Optional transparency using either transset or transset-df
Since it require knowledge of dzen2 parameters, I suggest you this good reading.
After all, this is the output. You can see the amazingly simple dzen2 statusbar on top of the screen. With updated time every one second interval.
3: Decorating dzen2
This require knowledge of a few dzen2 tags.
-
Foreground Color:
^fg()
-
Background Color:
^bg()
-
Font:
^fn()
We are going to use AwesomeFont to show Icons. You need to get AwseomeFont installed properly in your system. Or maybe or just put proper font in your .font directory. -
Decoration:
^i()
This tag is used to show Icon from Image Glyph. But we are going to use it to make a better Powerline like statusbar.
Reading:
Here is a working example:
conky-example/02.sh
and
conky-example/02.lua
.
Source:
Just run it, and now you can see the output. Not a very pretty decoration. But I guess you get my point. Dzen output is amazingly very flexible to be configured.
4: Create Decoration for Your own Suite
Everybody has different requirement, taste and style.
Instead of giving .xbm
files,
I’d better give the Source Image. And explain the creation process.
Article:
The creation process has been explained in previous chapter. I only use use Inkscape and GIMP with very few steps. And yeah, very simple process.
XBM:
5: Dzen2 with Modularized Lua in Conky
“Let’s be tidy and get organized.”
We are going to make this Lua script themable with flexible segment monitoring statusbar. I have made quick-and dirty-scripts. It means you are free to accustomize the script for your quick-and-dirty needs. It is never intended to be a perfect script. It just works.
Le’ts see the file structure. It contains:
-
Main BASH script, top pipe Conky to Dzen2:
main.sh
. -
A Conky Configuration Resource, as a script entry point:
conky.lua
. You can freely modify this conky by changing theme (preset and assembly). -
Two submodule libraries:
helper.lua
andparts.lua
. -
One asset contain Google Material Color for convenience:
gmc.lua
. -
Two Themable Paths:
presets
for color andassemblies
. You can make your own preset and assembly.
The entry point conky.lua is very simple. I have put all the stuff in libraries.
Source:
The color preset is just simpler.
Source:
Before we go to far, and got you a headache, let’s see how the dzen2 output goes.
6: Assembly the Parts
Let’s assembly each segment parts to build a nice statusbar. This is the best parts about using conky as a lua programming language. The assemby process looks neat and tidy.
The image above is simply an output of
this assemblies/separator.lua
configuration.
Source:
You can change the color preset and dzen parameter to achieve other theme without a lot of effort. Just edit the conky.lua, and save. The dzen2 statusbar panel will updated automatically following the selected theme.
Here is another sample to create a bright back arrow without making a lot of effort.
assemblies/back-arrow.lua
configuration.
Source:
You can create you own theme based on this. And for me, there is a lot of things about dzen2 and conky that I haven’t covered yet. This deserve a specific article focused on each topic. I simply do not have time to optimize the theme. It is just a quick and dirty solution.
7: Real Life Dzen2 with Lua in Conky
Now the Final part. The dzen2 statusbar example for your desktop.
Dzen2 need six bars, while lemonbar only need two bars. For code comparation you should see both source code yourself.
Source:
Conclusion
Coding is Fun. Especially when it comes to dzen2-conky-lua tiers. Now I have to move on to compose the next tutorial.
That is all for now. Thank you for reading.
Have Fun