FSO Tutorial (DBus rules)
So right now we have an LED on the AUX button that does nothing, lets change that! I want to be visually informed whether my GPS has a fix when I'm recording tracks, but I don't want to turn on the screen every couple seconds to check because that drains the battery (I know the LEDs are not much better on some models, but please bear with me :-).
The GPS subsystem will fire a DBus signal any time the fix is changed (No fix, 2D, 3D). The signal name is FixStatusChanged on the interface org.freedesktop.Gypsy.Device and the sole argument is an integer indicating the fix (Will be 0 if GPS is off, 1 for no fix, 2 and 3 for 2D/3D respectively).
Now lets look at the rules:
-
trigger: DbusTrigger(system, 'org.freesmartphone.ogpsd',
/org/freedesktop/Gypsy, 'org.freedesktop.Gypsy.Device', 'FixStatusChanged')
filters: HasAttr(arg0, 0)
actions: SetLed("gta02_aux_red", "dark")
-
trigger: DbusTrigger(system, 'org.freesmartphone.ogpsd',
/org/freedesktop/Gypsy, 'org.freedesktop.Gypsy.Device', 'FixStatusChanged')
filters: HasAttr(arg0, 1)
actions: SetLed("gta02_aux_red", "blink")
-
trigger: DbusTrigger(system, 'org.freesmartphone.ogpsd',
/org/freedesktop/Gypsy, 'org.freedesktop.Gypsy.Device', 'FixStatusChanged')
filters: Or(HasAttr(arg0, 2), HasAttr(arg0,3))
actions: SetLed("gta02_aux_red", "light")
-
These rules will trigger on the DBus signal 'org.freedesktop.Gypsy.Device.FixStatusChanged' from the bus name 'org.freesmartphone.ogpsd' (org.freedesktop.Gypsy will also work as ogpsd claims both) on the system bus send to the object path '/org/freedesktop/Gypsy'. If the first argument of the signal is zero (GPS turned off) the aux LED will be turned off, if it's one (searching for a fix) the LED will blink and if the argument is 2 or 3 (GPS has a fix) the LED will be on constantly.
Trackbacks
Use the following link to trackback from your own site:
http://totalueberwachung.de/blog/trackbacks?article_id=270