PDA

View Full Version : [KDE] battery monitor


albright
2008-02-23, 17:52
There's another thread that shows how to use python
to control the LEDs; this can be easily integrated into
a battery monitor script so that when your battery gets
below a certain level the LEDs start blinking red.

For example, here's my battery monitor script:


#!/bin/sh
X=`battery-status | awk '{print $4}'`
if [ ${#X} -lt 5 ]
then
play-sound /usr/local/kde/share/sounds/KDE_Notify.wav &
kdialog --title "Battery Status" --msgbox ". . . . . . . . . $X . . . . . . . . ." &
python /home/user/blinkenlight &
fi


This runs every 10 minutes via cron (yes, if you look you
can find a cron that runs on the n810).

the python script looks like this (thanks to eber42):


#! /usr/bin/python

import time
import dbus
bus = dbus.SystemBus()
obj = bus.get_object('com.nokia.mce','/com/nokia/mce/request')
iface = dbus.Interface(obj,dbus_interface='com.nokia.mce.r equest')
led_pattern = 'PatternError'

# led on
iface.req_led_pattern_activate(led_pattern)

# wait 5s
time.sleep(5)

# led off
iface.req_led_pattern_deactivate(led_pattern)



Well, it's fun if nothing else ...

Duncan
2008-02-23, 21:25
You can control the LED from a shell script: no need for Python for something this simple. See Changing the led colour indicators? (http://www.internettablettalk.com/forums/showthread.php?t=15467)

albright
2008-02-23, 22:26
thanks for that - much "cleaner"

Is there any central collection of "how to control your
tablet" tutorials and such that deals with things like
controlling LEDs etc?

jamesc760
2008-03-03, 21:45
no, there's not a central place for these types of info. you have search/google/hunt for them all over the interweb. i know it sux, but iiwii and it's something we all learn to tolerate.

tso
2008-03-03, 22:49
sadly...

there is a wiki on this page, dropping it there would be a nice start. or at the very least a link.

hmm, a gui front end for cron is maybe something this
tablet could make use off...