Estadobar: a simple status bar for dwm
What is it?
Here is something that I made for myself that might be useful for others who use the dwm window manager from suckless.org. It is a small Python program that creates a status bar: a display of information that parks itself (in default dwm configurations) in the upper-right corner of the screen. Here is a grab of the top third or so of my screen on a typical day, with estadobar running:
The strip at the top of the screen contains three areas. On the left, we have the list of tags, and layout information; the blue segment in the middle displays the title of the focussed window (I’m using the
st terminal emulator, also from suckless); and, on the right, the estadobar.
What does it display?
Here are the various segments of the bar:
From left to right, we have:
‣ A warning icon that appears when the CPU gets warm (yellow) or hot (red). It’s made from an APL character that vaguely looks like a CPU, to me.
‣ An icon showing the sound volume setting, mute + four levels.
‣ Four digits showing the load on (in my case) four logical CPU threads. 0 means 0 to 9%, 9 means 90 to 99%, and see below for the symbol that means 100%.
‣ The wifi network name and signal quality in %. The percent sign is omitted when the signal is at 100%, because this number fluctuates a bit, and I prefer it to always take up the same width.
‣ Free RAM + free swap.
‣ The battery charge % (% sign omitted also for 100%).
The above figure shows the bar when the CPU is hot, and the CPU loads are at approximately 85%, 85%, 100%, and 95%. The CPU should not get this hot, so you may want to check your ventilation.
Here it is trying to get us to plug in the charger.
Here is a low free RAM warning; may want to close some tabs. This also shows the volume at about 75%.
You need dwm, of course. To get the alert colors, you also need to have applied the
statuscolors patch. If I recall correctly, this patch would not install for me on a recent version of dwm, and I had to hand-patch it. But it was pretty simple.
The program that creates the estadobar is a single Python3 file called
statuses. Get it from my git repository with
git clone https://lee-phillips.org/estadobar
It is in the public domain. Please be nice and give me credit, and link back here, if you distribute it or a modified version. If you think your modifications or improvements are even slightly awesome, email me a patch, and I may merge it into the repository for others to enjoy. General advice or just praise are also welcome.
The program uses whatever happened to work on my system (xubuntu with many things uninstalled and others installed) to gather hardware information. This sort of thing varies quite a bit among different distributions, so some of the displays may not work for you until you fix it.
This works like any other status bar program used with dwm. Put the script anywhere, and add the line
while true; do /path/to/statuses; sleep 1; done &
.xinitrc file. Log out and back in, and you should see your estadobar. You can fiddle with the script, and in at most one second see the changes reflected in the bar. (The example above updates the display once per second; of course you can change that interval to something else—but it takes about 0.5 to 1 second to gather and parse the hardware information.)
You can invoke the
statuses script right from the terminal, before putting it in your
.xinitrc, to see what happens. If you also have it, or another status bar, installed, you should see the output in the status bar area until it is replaced by your installed one.
You can override estadobar’s gleaning of real hardware values with values that you give it on the command line; that’s how I made the example displays above. If you are sitting in the directory with
statuses, you can type
./statuses -h for a brief summary of the options. Some examples:
To set the fake battery charge to 12%:
./statuses -b 12
To set the fake CPU load as in the first example above, with the hot CPU warning:
./statuses -c 88∞9 -t 101
To set the fake free RAM and the volume as in the last example above:
./statuses -f 0.1 -v 75
Asynchronous, modular status bar that doesn’t depend on polling.