Notices


Reply
Thread Tools
kstep's Avatar
Posts: 18 | Thanked: 52 times | Joined on Dec 2010
#1
Hello, all!

I was missing for simple dbus scheduler for a long time (dbus-scripts is a no op for me for some reasons), so I created my own dbuscron daemon to monitor DBUS events and run commands on them.

The source code lies on github at http://github.com/kstep/dbuscron and deb-package can be taken from my blog at http://kstep.me/dbuscron_en.html.

The main idea of the scheduler is simple: it's just like good old cron but for DBUS messages. It's configured with /etc/dbuscrontab file in a crontab-like format. Here're some simple examples from my own config:

Code:
# bus(*S*ystem/*s*session) message_type(signal|method_call|method_return|error) source interface object_path member destination arguments command
# Stop player on headphones plug out
S signal * org.freedesktop.Hal.Device /org/freedesktop/Hal/devices/platform_headphone Condition * ButtonPressed;connection grep -q disconnected /sys/devices/platform/gpio-switch/headphone/state && run-standalone.sh /opt/userscripts/mpcontrol.sh stop
# Connect to ISP via PPTP on home WiFi network connection
S signal * com.nokia.wlancond.signal /com/nokia/wlancond/signal connected * wlan0 run-standalone.sh /opt/userscripts/tasks/connect-pptp.sh
# Disconnect PPTP
S signal * com.nokia.wlancond.signal /com/nokia/wlancond/signal disconnected * wlan0 run-standalone.sh /opt/userscripts/tasks/disconnect-pptp.sh
# Forward all notifications to my notebook via SSH (sic!)
s method_call * org.freedesktop.Notifications /org/freedesktop/Notifications SystemNoteInfoprint,Notify * * /opt/userscripts/tasks/whitebook-notify.sh
I can give you a lot of such examples and using them is as easy as adding new line in config and sending HUP to dbuscron daemon to make it reread this config. I think this example tells you more than thousand words, and if not, you can read more about it at http://kstep.me/dbuscron_en.html, as there're too many options to mention all of them here (and actually I have wrote so much about it in my blog, I got a little tired of describing all of them, sorry =).

As of stability, I run it on my N900 all the time for several weeks and haven't mentioned any critical bugs (and if I do, I will not wait to fix them asap, as I'm the main user of this program).

P.S. If you are interested in some of my scripts mentioned in this example, I can provide them as well (except private parts with passwords etc. of cause =).
 

The Following 14 Users Say Thank You to kstep For This Useful Post:
kstep's Avatar
Posts: 18 | Thanked: 52 times | Joined on Dec 2010
#2
On similarity to dbus-scripts I want to mention the following points:

+ the command can be not only single script name w/o spaces, it can be any
arbitrary string, include spaces and different shell-orientent
expressions etc.,
+ it can listen to both session & system buses at the same time (which is
critical to me),
+ it can (hopefully) run without run-standalone.sh,
+ it provides full DBUS message info to script in environment variables,
+ arguments are matched as strings, and they are converted to them in a
quite smart way, so you can match even bools ('1' for true and '0'),
arrays as '1,2,3' or dicts as 'a:1,b:2,c:3' (well, there's still small
bug in it I will target in closest release, but it's a really quick and
easy fix),
+ any scripts written for dbus-scripts, are already compatible with dbuscron,
just use "scriptname $DBUS_ARG0 $DBUS_ARG1 $DBUS_ARG2" as command in dbuscrontab,
or replace $1,$2,... in script with $DBUS_ARG0,$DBUS_ARG1,...,

- it doesn't match rules with fnmatch(), but with simple string comparison,
so no wildcards (except for '*', which is not wildcard exactly), but it
is in my todo list.
 

The Following User Says Thank You to kstep For This Useful Post:
kstep's Avatar
Posts: 18 | Thanked: 52 times | Joined on Dec 2010
#3
BTW, I'm in garage now at https://garage.maemo.org/projects/dbuscron/ and version 1.4 is out. Changelog:

bus: interface to set custom session bus
--sessionaddr option to set custom session bus address
parser: fixed typo
support \xXX escape characters in args field
parser: fix bug in syntax checker on starred fields
genchangelog: indent shortlog correctly
run dbuscron as user
support \uXXXX as well as \xXX in args field
Makefile: better compilation
 

The Following 3 Users Say Thank You to kstep For This Useful Post:
hawaii's Avatar
Posts: 1,030 | Thanked: 792 times | Joined on Jun 2009
#4
Good stuff.
 
joerg_rw's Avatar
Posts: 2,222 | Thanked: 12,651 times | Joined on Mar 2010 @ SOL 3
#5
Sounds nice.
You thought about some support scripts that will import and convert existing dbus-scripts settings? might be useful, as I'd not want to run both daemons concurrently, but rather migrate from dbus-scripts to Dbuscron.

Please give clear instructions how to install your program, so users don't need to figure out by themselves.

Many thanks, keep hacking :-)
/jOERG
__________________
Maemo Community Council member [2012-10, 2013-05, 2013-11, 2014-06 terms]
Hildon Foundation Council inaugural member.
MCe.V. foundation member

EX Hildon Foundation approved
Maemo Administration Coordinator (stepped down due to bullying 2014-04-05)
aka "techstaff" - the guys who keep your infra running - Devotion to Duty http://xkcd.com/705/

IRC(freenode): DocScrutinizer*
First USB hostmode fanatic, father of H-E-N
 

The Following 3 Users Say Thank You to joerg_rw For This Useful Post:
Posts: 1,224 | Thanked: 1,763 times | Joined on Jul 2007
#6
Having a configuration directory in addition to (or instead of) a configuration file is essential for allowing other programs to easily use this daemon. I hope you plan to add this feature.
__________________
My repository

"N900 community support for the MeeGo-Harmattan" Is the new "Mer is Fremantle for N810".

No more Nokia devices for me.
 

The Following 3 Users Say Thank You to Matan For This Useful Post:
kstep's Avatar
Posts: 18 | Thanked: 52 times | Joined on Dec 2010
#7
Thank you all to your comments. I will put your ideas on my todo list.
 
kstep's Avatar
Posts: 18 | Thanked: 52 times | Joined on Dec 2010
#8
New 1.5 release.

Release notes: https://garage.maemo.org/frs/shownot...elease_id=4337
Download from: https://garage.maemo.org/frs/?group_id=2007

Please read release notes carefully. I have implemented ideas of all people in this thread.
 

The Following 2 Users Say Thank You to kstep For This Useful Post:
kstep's Avatar
Posts: 18 | Thanked: 52 times | Joined on Dec 2010
#9
I have petitioned for extras-devel upload account and now am waiting for approvement. When I got it, I will put dbuscron into extras-devel, so it can be installed via application manager. For now you can download it from my garage account and install either by opening deb-package with application manager or via command line:

$ sudo gainroot
# dpkg -i path/to/package/dbuscron_1.5-1_all.deb
 
kstep's Avatar
Posts: 18 | Thanked: 52 times | Joined on Dec 2010
#10
If you like and use my dbuscron, please consider voting for it at my ohloh page (if it's not very difficult and time consuming for you, of cause):
https://www.ohloh.net/p/dbuscron
Thank you in advance!
 
Reply


 
Forum Jump


All times are GMT. The time now is 13:04.