*

Welcome, Guest. Please login or register.

Get your own OLPC - Buy an XO laptop on eBay!
Pages: [1]
Print
Author Topic: Beep/chirp if low battery?  (Read 5019 times)

Beep/chirp if low battery?

justdaniel
New

Posts: 2


September 14, 2009, 05:47:09 AM

Hi!

I've enjoyed the company of my xo, for quite a while now and I am using Mr. teapot's excellent intrepid adaptation, THANK YOU, Good Sir!

I was thinking, is there a way to make the poor thing chirp/beep when its hungry for power?

Did some searching and found this: http://groups.google.com/group/linux.debian.user/browse_thread/thread/a3d1d85054573e61/6474aa853e06bd1e?lnk=raot

However.... im not very good at computers Sad and it seems like there is no application for this, which is strange imho, with so many netbooks about.

Could someone help a hungry XO out? Cheesy
« Last Edit: September 14, 2009, 05:49:23 AM by justdaniel » Logged

#1 Re: Beep/chirp if low battery?

metal.lunchbox
Senior Contributor
**
Posts: 149


October 24, 2009, 01:24:01 PM

## Edited 10-31 fix link to Feather sound set ##
This should be a simple thing to do, but it will require some use of the terminal. All you have to do is edit the battery monitor script that checks the charge level of your battery and displays it in the panel and add a line that tells the script to play a sound if the charge is below a particular level. If you hover over the battery level in the panel a tooltip will pop up and you'll see that it calls a script called "bat_mon.sh" In the terminal you can find this script with a simple command:

Code:
which bat_mon.sh

you'll see that its in the directory where user installed executables are usually stored "/usr/bin/" . System sounds are stored in /usr/share/sounds and you can play most of them with aplay. Open the bat_mon script after backing it up

Code:
sudo cp /usr/bin/bat_mon.sh ~/bat_mon.sh
cd
gedit bat_mon.sh

insert a new line below the "else" on the third line from the bottom and add the following new line:

Code:
if [ "$cap" -le "10" ]; then
  aplay /usr/bin/sounds/purple/alert.wav
  notify-send -i /usr/share/icons/gnome/scalable/status/battery-low.svg "Warning!" "Battery charge is very low"
fi

save the file and move it to it back to /usr/bin :

Code:
sudo mv /usr/bin/bat_mon.sh /usr/bin/bat_mon.sh.old
sudo mv ~/bat_mon.sh /usr/bin/bat_mon.sh

Personally I find that the sounds that come with the teapot Intrepid distro are not adequate for most notifications. You can find alternative sets of system sounds and install them into /usr/share/sounds , just change the path in the above script to point to the sound you want to use. I like Feather sound set which can be found at gnome-look.org

james
« Last Edit: October 31, 2009, 02:37:35 PM by metal.lunchbox » Logged

xoxoxoxoxo

#2 Re: Beep/chirp if low battery?

mavrothal
Administrator
OLPC News Forum Expert
*****
Posts: 1289


October 26, 2009, 12:12:22 PM

if I am not mistaken, that should do it. I have not tested this so tell be sure to tell me if it works.
Works pretty well. Thanks
Just a small correction the sound path is  /usr/share/sounds/purple/alert.wav so the end of the bat_mon.sh file after editing looks something like that
Code:
else
 if [ "$cap" -le "20" ]; then
  aplay /usr/share/sounds/purple/alert.wav
  notify-send -i /usr/share/icons/gnome/scalable/status/battery-low.svg "Warning!" "Battery at ""$cap$percent"
 fi
 echo "$cap$percent$psrc";
fi

Please edit your post so I can quote only one post in the "solutions" Wink

PeditS:
Quote
this is a dynamic link and wget will not work. Must use a browser to download from here http://www.mediafire.com/?zghjanh224x
« Last Edit: October 27, 2009, 01:40:30 PM by mavrothal » Logged

XO-1: Is never going to run Flash, but is certainly flashy!
(If you want Flash, get an XO-1.5 running OLPC 11.2.0 or XOpup Grin )
Pages: [1]
Print
Jump to:  

Members
Total Members: 2406
Latest: sembik
Stats
Total Posts: 31943
Total Topics: 3843
Online Today: 43
Online Ever: 238
(April 18, 2011, 09:48:50 PM)
Users Online
Users: 0
Guests: 25
Total: 25