[GTALUG] Re-implementing xbattbar in Python

Giles Orr gilesorr at gmail.com
Mon Jan 6 15:41:59 EST 2020


One of my favourite accessory programs for X is 'xbattbar' which puts a 
3px wide line all along one side of your X screen with part of it red 
and part of it blue to indicate how much battery remains.  Obviously 
there are many other battery indicators, and it's also obvious that this 
one has fallen out of favour: the original author vanished years ago 
(last updates circa 2010) and now it's no longer supported in Debian 
because the maintainer there has evidently lost interest.  I'm not sure 
it was ever supported as a package in Fedora.


By some judicious hacking of both the C and Python components from the 
most recent Debian source package, I've convinced it to build on Fedora 
31.  I'm not particularly happy with this solution as I'm well aware of 
my complete lack of C knowledge and only basic Python skills.  What I'd 
like to do is to re-implement this idea in pure Python with a more 
flexible vision.  'xbattbar' already allows you to use an accessory 
script (a couple are provided, in Python) to feed values to xbattbar.  
So I was thinking of re-implementing it without the idea that it's just 
for batteries, but could show you hard drive usage or network throughput 
(although sample rate becomes an issue then: xbattbar allows adjustment 
of sample rate, but by default it's every 5 or 10 seconds).


I think this is a good idea, but my limited Python experience barely 
extends beyond basic CLI and administrative scripts.  So the questions 
for all of you are, has someone already done this, and if not, where do 
I start on figuring out how to draw a bar on an X screen without a 
window around it?

--
Giles
https://www.gilesorr.com/
gilesorr at gmail.com



More information about the talk mailing list