maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   [Announce] Dbuscron - the cron-like DBUS scheduler (https://talk.maemo.org/showthread.php?t=67194)

kstep 2010-12-20 01:16

[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 =).

kstep 2010-12-21 13:03

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.

kstep 2010-12-21 13:07

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

hawaii 2010-12-21 13:55

Re: [Announce] Dbuscron - the cron-like DBUS scheduler
 
Good stuff.

joerg_rw 2010-12-21 14:28

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

Matan 2010-12-21 15:09

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.

kstep 2010-12-21 15:16

Re: [Announce] Dbuscron - the cron-like DBUS scheduler
 
Thank you all to your comments. I will put your ideas on my todo list.

kstep 2010-12-22 16:29

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.

kstep 2010-12-22 17:24

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

kstep 2010-12-22 18:37

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!

kstep 2010-12-22 22:11

Re: [Announce] Dbuscron - the cron-like DBUS scheduler
 
Version 1.5.1 with bugfix released:
https://garage.maemo.org/frs/shownot...elease_id=4339

kstep 2010-12-25 18:49

Re: [Announce] Dbuscron - the cron-like DBUS scheduler
 
Ok, I made my way to extras-devel. The version is 1.5.2-2. It is essentially 1.5.1, the changes are in packaging configs only to make it build with autobuilder. I had to experiment a little to make it build correctly, so version is ...-2. I've just updated my dbuscron on my N900 from extras-devel. Test it please. Any feedback is wellcomed.

quipper8 2010-12-30 03:30

Re: [Announce] Dbuscron - the cron-like DBUS scheduler
 
anyone have a good script to use with this to put a notification when a specific contact comes online?

ie what is the dbus signal for that event and how do you script a notification just like an sms or other system notification

thanks for pointers in right directions

kstep 2010-12-30 12:28

Re: [Announce] Dbuscron - the cron-like DBUS scheduler
 
You can use
dbus-monitor
in XTerminal to monitor for events. Just run it and wait for contact go online.

You can use code from http://wiki.maemo.org/Phone_control#...teraction.29_2 to show mail-like notifications.

hawaii 2011-01-18 19:04

Re: [Announce] Dbuscron - the cron-like DBUS scheduler
 
For some reason, I am randomly getting python spitting out trace calls about dbuscron.shell missing.

This happens every few weeks. A re-install "solves" this temporarily, and it's back at it again. Any idea what is causing this?

kstep 2011-01-19 12:21

Re: [Announce] Dbuscron - the cron-like DBUS scheduler
 
I had this issue with both my procalc & dbuscron. I reinstalled it and everything worked fine, no idea what happened. Looked like something removed libraries from /usr/lib/pymodules/python2.5 required by programs. Could you reproduce the problem and report following info (from XTerminal):

ls -l /use/lib/pymodules/python2.5/dbuscron/ > bug.log
ps >> bug.log

then send me bug.log (to kstep(at)p-nut.info).

If I manage to reproduce the bug I will try to fix it asap.

hawaii 2011-01-19 14:56

Re: [Announce] Dbuscron - the cron-like DBUS scheduler
 
I will send once I am able to get the issue to happen again. I imagine it happens when something python related is installed, and possibly when the pymaemo-optify scripts are run, per chance?

Anyways, I'll get back to you once I have something.

Thanks.


All times are GMT. The time now is 11:48.

vBulletin® Version 3.8.8