Go Back   maemo.org - Talk > Software > Applications
 
Register FAQ Community Calendar Today's Posts Search

Notices

Reply
 
Thread Tools
  #1  
Old 2010-12-20, 01:16
kstep's Avatar
kstep kstep is offline
 
Join Date: Dec 2010
Posts: 18
Thanks!: 7
Thanked 52 Times in 7 Posts
Default [Announce] Dbuscron - the cron-like DBUS scheduler

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 =).
Reply With Quote
The Following 14 Users Say Thank You to kstep For This Useful Post:
  #2  
Old 2010-12-21, 13:03
kstep's Avatar
kstep kstep is offline
 
Join Date: Dec 2010
Posts: 18
Thanks!: 7
Thanked 52 Times in 7 Posts
Default Re: [Announce] Dbuscron - the cron-like DBUS scheduler

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.
Reply With Quote
The Following User Says Thank You to kstep For This Useful Post:
  #3  
Old 2010-12-21, 13:07
kstep's Avatar
kstep kstep is offline
 
Join Date: Dec 2010
Posts: 18
Thanks!: 7
Thanked 52 Times in 7 Posts
Default Re: [Announce] Dbuscron - the cron-like DBUS scheduler

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
Reply With Quote
The Following 3 Users Say Thank You to kstep For This Useful Post:
  #4  
Old 2010-12-21, 13:55
hawaii's Avatar
hawaii hawaii is offline
 
Join Date: Jun 2009
Posts: 1,030
Thanks!: 317
Thanked 792 Times in 376 Posts
Default Re: [Announce] Dbuscron - the cron-like DBUS scheduler

Good stuff.
Reply With Quote
  #5  
Old 2010-12-21, 14:28
joerg_rw's Avatar
joerg_rw joerg_rw is offline
 
Join Date: Mar 2010
Location: SOL 3
Posts: 2,222
Thanks!: 3,399
Thanked 12,651 Times in 1,970 Posts
Default Re: [Announce] Dbuscron - the cron-like DBUS scheduler

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
Reply With Quote
The Following 3 Users Say Thank You to joerg_rw For This Useful Post:
  #6  
Old 2010-12-21, 15:09
Matan Matan is offline
 
Join Date: Jul 2007
Posts: 1,224
Thanks!: 2
Thanked 1,763 Times in 651 Posts
Default Re: [Announce] Dbuscron - the cron-like DBUS scheduler

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.
Reply With Quote
The Following 3 Users Say Thank You to Matan For This Useful Post:
  #7  
Old 2010-12-21, 15:16
kstep's Avatar
kstep kstep is offline
 
Join Date: Dec 2010
Posts: 18
Thanks!: 7
Thanked 52 Times in 7 Posts
Default Re: [Announce] Dbuscron - the cron-like DBUS scheduler

Thank you all to your comments. I will put your ideas on my todo list.
Reply With Quote
  #8  
Old 2010-12-22, 16:29
kstep's Avatar
kstep kstep is offline
 
Join Date: Dec 2010
Posts: 18
Thanks!: 7
Thanked 52 Times in 7 Posts
Default Re: [Announce] Dbuscron - the cron-like DBUS scheduler

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.
Reply With Quote
The Following 2 Users Say Thank You to kstep For This Useful Post:
  #9  
Old 2010-12-22, 17:24
kstep's Avatar
kstep kstep is offline
 
Join Date: Dec 2010
Posts: 18
Thanks!: 7
Thanked 52 Times in 7 Posts
Default Re: [Announce] Dbuscron - the cron-like DBUS scheduler

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
Reply With Quote
  #10  
Old 2010-12-22, 18:37
kstep's Avatar
kstep kstep is offline
 
Join Date: Dec 2010
Posts: 18
Thanks!: 7
Thanked 52 Times in 7 Posts
Default Re: [Announce] Dbuscron - the cron-like DBUS scheduler

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 With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 21:38.