View Single Post
Posts: 145 | Thanked: 32 times | Joined on Dec 2007
#1
I believe that the following script will run
perpetually, checking the battery status
every five minutes. It will pop up a message
when the battery level falls below 10%.

Code:
#!/bin/sh
while true
do
sleep 300
X=`battery-status | awk '{print $4}'`
if [ "$X" \< "90" ]
then
  kdialog --title "Battery Status" --msgbox ". . . . . . . . .  $X  . . . . . . . . ."
fi
done
Some options in kdialog don't seem to work quite right but
the above works for me.

Of course, without the while loop, sleep etc the X=
and kdialog lines can form a script to get a popup
of the battery level whenever you want. But in that
case, this is better:

Code:
#!/bin/sh
X=`battery-status | awk '{print $4}'`
kdialog --geometry +15+450 --title "Battery Status" --passivepopup $X 4
geometry option does not work with msgbox - don't know why (but
that explains all the "dots").

You could put the first script in ~/.kde/Autostart

It does not seem to use any cpu that I can notice. One problem is
that the "busy cursor" bounces or blinks for the full timeout. I
wonder if there is a way to disable launch notification for particular
apps ...

Oh, and by the way, if you want to get rid of the script you'll
have to kill it from command line.
 

The Following User Says Thank You to albright For This Useful Post: