Author Topic: Battery status icons  (Read 2059 times)

Mijzelf

  • Full Member
  • ***
  • Posts: 140
Battery status icons
« on: April 26, 2009, 04:17:15 PM »
I found that the (console-) output of desktop-backend (which is started by /sbin/run_backend, which is started by startx) contains lines like:
Code: [Select]
SEND ATOM[_NET_ADD_MINI_ICON] DATA [7|/share/pixmaps/Battery_75.png]where the png represents the current battery status. I've no experience in writing X programs, but I suppose it shouldn't be hard to pipe the output to another program, which shows the icon somehow.

wicknix

  • Hero Member
  • *****
  • Posts: 630
Re: Battery status icons
« Reply #1 on: April 26, 2009, 05:56:38 PM »
Yea i tried looking into that a little bit, but it seems hard coded and not sure a hex edit would work. I was just happy to see that the low battery warning pop up actually still worked which seemed good enough for me. I still get about 20 minutes run time after that pop up displays which should give the user plenty of time to save their work and power down.

I also noticed that cat /proc/apm gives a false reading (seems to constantly say its on ac power and the percentage is wayyyy off) which is why no 'standard' battery applet works properly.  :-\

Cheers.

Mijzelf

  • Full Member
  • ***
  • Posts: 140
Re: Battery status icons
« Reply #2 on: April 30, 2009, 08:11:39 PM »
So far I've got a program which gives the batterystatus in the program title bar. So you can read it on the taskbar.

The program is called 'battery' (yes!) and can be downloaded here. Unpack the tarball, and copy battery to /bin. The rest is sourcecode, I hope someone else will make a great program of it. (Actually I borrowed almost all code from xlassie, an email notifier)

The program is split in 2 sections: battery -backend will filter the output of desktop-backend, and put the name of the current status icon in /tmp/7.txt. The other part polls this file, and reads the numerical part of the icon name, and puts it in its windowname.

To get this running edit /sbin/run-backend:
Code: [Select]
<snip>
if [ $# = 0 ] ; then
desktop-backend | battery -backend &
else
desktop-backend $* | battery -backend &
fi
<snip>
Now reboot. After you've rebooted enter
Code: [Select]
battery &in a terminal.  This gives a small window which you can minimize by rightclicking on it. You can also start this by letting jwm swallow it, or any other way, as long as the X-server is started already.

The windowname will be 'Unknown' as long as desktop-backend hasn't specified an icon yet, '-' as the laptop is connected to mains, and a percentage (0,25,50,75,100) when running on battery.





wicknix

  • Hero Member
  • *****
  • Posts: 630
Re: Battery status icons
« Reply #3 on: May 01, 2009, 11:46:15 PM »
Coolbeans! I'll have to give it a whirl later.  ;)

Cheers.

duttydea

  • Full Member
  • ***
  • Posts: 136
  • You wont know untill you search, then ask!!
Re: Battery status icons
« Reply #4 on: May 03, 2009, 01:48:27 PM »
I have tried to implement this on my LLL.

When I call "battery" i get the window with a "-", This is the same with or without the charger plugged in.

What is the correct format for the "/tmp/7.txt" file?

Doesn't the /tmp/ folder clear on every reboot?..

« Last Edit: May 03, 2009, 04:34:21 PM by duttydea »
______________________________________________
CnM MiniBook : 3MX RC3.1 / Custom Debian (DLA)
Desktop: XP PRO & Vista
Linux Knowledge: Restricted to 3MX & Debian Etch (Basic)

Mijzelf

  • Full Member
  • ***
  • Posts: 140
Re: Battery status icons
« Reply #5 on: May 03, 2009, 07:19:47 PM »
On this moment the content of /tmp/7.txt on my LLL is
Code: [Select]
/share/pixmaps/Battery_50.png]and my battery statuswindow says 50. When the statuswindow says '-', 7.txt doesn't contain any numbers.

/tmp is cleaned each boot in by the /etc/init.d/rcS script.

Mijzelf

  • Full Member
  • ***
  • Posts: 140
Re: Battery status icons
« Reply #6 on: May 07, 2009, 07:26:19 AM »
@Wicknix: Where did you find jwm-system-monitor? Google leads me to this forum only.

wicknix

  • Hero Member
  • *****
  • Posts: 630
Re: Battery status icons
« Reply #7 on: May 08, 2009, 01:15:51 AM »
@Wicknix: Where did you find jwm-system-monitor? Google leads me to this forum only.

It's actually part of the 'real' matchbox desktop (not the hacked up XIP version in the default OS). I forget what its original file name was as i renamed it so i could remember it.. heh. In rc3.1 i think i renamed it to jwm-sysmon (less to type). Anyway its part of the matchbox taskbar 'plugins'. One of few that that worked on jwm. I was hoping the battery status and wifi plugin would have worked, but they didn't.  :'(

Cheers.

Mijzelf

  • Full Member
  • ***
  • Posts: 140
Re: Battery status icons
« Reply #8 on: May 09, 2009, 08:52:46 PM »
So I downloaded matchbox-panel-0.8.2.tar.gz, studied the applets, and wrote my own icon applet.

To install download the package here,
extract it,
copy icon-applet to /bin,
edit /sbin/run-backend:
Code: [Select]
<snip>
if [ $# = 0 ] ; then
desktop-backend | icon-applet &
else
desktop-backend $* | icon-applet &
fi
<snip>
Reboot.

After a while (1 minute after the desktop) the batteryicon will appear in the taskbar.

I also added the stock EPC700 icons. I think they are better than the icons shipped with 3MX (more contrast). If you want to use them, copy the png files to /share/pixmaps

Mijzelf

  • Full Member
  • ***
  • Posts: 140
Re: Battery status icons
« Reply #9 on: May 11, 2009, 08:42:10 AM »
There seems to be a big delay in my applet.  :(

My applet reads stdin, and echos it to stdout, while adding some extra comments. (This makes it possible to cascade the applet).

But!
When you start desktop-backend in a terminal, it directly starts outputing data.
I expected desktop-backend | icon-applet to do the same, but is doesn't. It starts generating outputs with a big delay. The pipe in-between buffers data until a certain amount (4kB?) is reached, before it flushes.

So I need to start it with a smaller (less buffer) pipe, a pipe which flushes on newline, or a 'console-style' pipe, when such a thing exists.

Does anybody know if there is a way to tell bash to use a different pipe, or to change the pipe properties from within my applet?


wicknix

  • Hero Member
  • *****
  • Posts: 630
Re: Battery status icons
« Reply #10 on: August 17, 2009, 01:48:33 AM »
I changed it up a little bit. I didn't like either set of battery icons so i packed up Retro's battery icons. Much easier to see. I also made a slight change to the editing of run-backend. Only add icon-applet once and the delay doesn't seem too bad.

if [ $# = 0 ] ; then
   desktop-backend | icon-applet &
else
   desktop-backend $* &
fi

Here's a look at the icons:

Download here: http://www.hostwork.com/users/matt/alpha400/battery-pixmaps.zip

Screen shot showing full charge:

Cheers

wicknix

  • Hero Member
  • *****
  • Posts: 630
Re: Battery status icons
« Reply #11 on: August 17, 2009, 01:52:16 AM »
My post was flagged as spam.. to view it click 'reply', then scroll down to see my post.  ::)