[GTALUG] Re-implementing xbattbar in Python

Giles Orr gilesorr at gmail.com
Fri Jan 10 08:48:26 EST 2020


On Thu, 9 Jan 2020 at 12:07, Lennart Sorensen
<lsorense at csclub.uwaterloo.ca> wrote:
>
> On Mon, Jan 06, 2020 at 03:41:59PM -0500, Giles Orr via talk wrote:
> > 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?
>
> I think the xpymon project could be a good starting point.
>
> https://github.com/h-ohsaki/xpymon/blob/master/xpymon
>
> It unfortunately uses x11util and perlcompat python modules that don't
> appear to be commonly packaged, but you could probably copy the required
> functions from those modules to use as needed.

You're right - that's an excellent starting point.  I found, and was
hoping to use, python-xlib:
https://github.com/python-xlib/python-xlib/tree/master/examples .  But
this is a more complete example.  I'd definitely like to excise the
perlcompat ...  Anyway, between the two I might actually get somewhere
with this idea.  Thanks!

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


More information about the talk mailing list