Re: Sending session DBus message from system cron job?
On Sunday 21 March 2010, Glennie Vignarajah wrote: > Le 21/03/2010 vers 09:56, dans le message intitulé "Re: Sending > session DBus message from system cron job?", Michael > Schuerig(Michael Schuerig > > ) a écrit: > > On Wednesday 10 March 2010, Glennie Vignarajah wrote: > > > Le 09/03/2010 vers 17:49, dans le message intitulé "Sending > > > session > > Hello, > > > Failed to open connection to "session" message bus: Did not receive > > a reply. Possible causes include: the remote application did not > > send a reply, the message bus security policy blocked the reply, > > the reply timeout expired, or the network connection was broken. > > It's seems that session bus needs a DISPLAY. > Use the DISPLAY variable associated with DBUS_SESSION_BUS_ADDRESS > Have a look at http://cweiske.de/tagebuch/DBus notify-send over > network.htm I didn't get it to work with DISPLAY and XAUTHORITY either, so I reverted to my rough method NEPOMUK="org.kde.nepomuk.services.nepomukstrigiservice" SUSPEND="/nepomukstrigiservice org.kde.nepomuk.Strigi.suspend" RESUME="/nepomukstrigiservice org.kde.nepomuk.Strigi.resume" case "$1" in on|resume) CMD="$RESUME" ;; off|suspend) CMD="$SUSPEND" ;; *) echo "Usage: $0 {on|off}" exit 1 ;; esac . /usr/share/acpi-support/power-funcs for x in /tmp/.X11-unix/* ; do displaynum=`echo $x | sed s,/tmp/.X11-unix/X,,` getXuser if [ x"$XUSER" != x"" ] ; then sudo -u $XUSER dbus-send --session --type=method_call -- \ dest=$NEPOMUK $CMD fi done I'm using sudo instead of su because, on my system, su triggers an unecessary password prompt from libpam_mount. Michael -- Michael Schuerig mailto:mich...@schuerig.de http://www.schuerig.de/michael/ -- To UNSUBSCRIBE, email to debian-kde-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/201003211542.26034.mich...@schuerig.de
Re: Sending session DBus message from system cron job?
Le 21/03/2010 vers 09:56, dans le message intitulé "Re: Sending session DBus message from system cron job?", Michael Schuerig(Michael Schuerig ) a écrit: > On Wednesday 10 March 2010, Glennie Vignarajah wrote: > > Le 09/03/2010 vers 17:49, dans le message intitulé "Sending session Hello, > Failed to open connection to "session" message bus: Did not receive a > reply. Possible causes include: the remote application did not send a > reply, the message bus security policy blocked the reply, the reply > timeout expired, or the network connection was broken. It's seems that session bus needs a DISPLAY. Use the DISPLAY variable associated with DBUS_SESSION_BUS_ADDRESS Have a look at http://cweiske.de/tagebuch/DBus notify-send over network.htm Regards, -- http://www.glennie.fr If the only tool you have is hammer, you tend to see every problem as a nail. -- To UNSUBSCRIBE, email to debian-kde-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/201003211452.34159.glen...@glennie.fr
Re: Sending session DBus message from system cron job?
On Wednesday 10 March 2010, Glennie Vignarajah wrote: > Le 09/03/2010 vers 17:49, dans le message intitulé "Sending session > I use this code: > > - > for _PID in $(pgrep -u $USER startkde) ; do > _ID="$(cat /proc/$_PID/environ | tr '\0' '\n' |awk - > FDBUS_SESSION_BUS_ADDRESS= '/DBUS_SESSION_BUS_ADDRESS=/ {print $2}')" > _DBUS_BUS_ADDRESS="$_ID $_DBUS_BUS_ADDRESS" > done > --- > In order to find DBUS sockets, and then > > --- > for _BUS_ID in $_DBUS_BUS_ADDRESS ; do > DBUS_SESSION_BUS_ADDRESS=$_BUS_ID dbus-send --type=method_call -- > dest=org.kde.screensaver /ScreenSaver > org.freedesktop.ScreenSaver.Lock done I'm by now using this method to send a message from a (system) cron job and unfortunately it does not work as I hoped. I've changed pgrep -u $USER startkde to pgrep startkde as I want to stop all nepomuk indexers during a backup. However, I get an error message in the output from the cron job, implying that the message could not be sent, and indeed, the indexer is not disabled. This is the message: Failed to open connection to "session" message bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken. Is there a way to work around this? Michael -- Michael Schuerig mailto:mich...@schuerig.de http://www.schuerig.de/michael/ -- To UNSUBSCRIBE, email to debian-kde-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/201003210956.22091.mich...@schuerig.de
Re: Sending session DBus message from system cron job?
On Wednesday 10 March 2010, Glennie Vignarajah wrote: > Le 09/03/2010 vers 17:49, dans le message intitulé "Sending session > DBus message from system cron job?", Michael Schuerig(Michael > Schuerig ) a écrit: > > > > Hello, > > > I'd like to disable the desktop search indexer while the > > cron-triggered backup is running. I've figured out the relevant > > DBus messages I need > > > for that: > I use this code: [snip] Thanks! Yes, that's better. Michael -- Michael Schuerig mailto:mich...@schuerig.de http://www.schuerig.de/michael/ -- To UNSUBSCRIBE, email to debian-kde-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/201003101505.38120.mich...@schuerig.de
Re: Sending session DBus message from system cron job?
Le 09/03/2010 vers 17:49, dans le message intitulé "Sending session DBus message from system cron job?", Michael Schuerig(Michael Schuerig ) a écrit: Hello, > I'd like to disable the desktop search indexer while the cron-triggered > backup is running. I've figured out the relevant DBus messages I need > for that: I use this code: - for _PID in $(pgrep -u $USER startkde) ; do _ID="$(cat /proc/$_PID/environ | tr '\0' '\n' |awk - FDBUS_SESSION_BUS_ADDRESS= '/DBUS_SESSION_BUS_ADDRESS=/ {print $2}')" _DBUS_BUS_ADDRESS="$_ID $_DBUS_BUS_ADDRESS" done --- In order to find DBUS sockets, and then --- for _BUS_ID in $_DBUS_BUS_ADDRESS ; do DBUS_SESSION_BUS_ADDRESS=$_BUS_ID dbus-send --type=method_call -- dest=org.kde.screensaver /ScreenSaver org.freedesktop.ScreenSaver.Lock done --- in order to lock all my kde sessions. I don't if this is better, with this methode, there is no need to "su" and you're immune to stalled sockets in /tmp/.X11-unix/. HTP, -- http://www.glennie.fr If the only tool you have is hammer, you tend to see every problem as a nail. -- To UNSUBSCRIBE, email to debian-kde-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/201003101306.50165.glen...@glennie.fr
Sending session DBus message from system cron job?
I'd like to disable the desktop search indexer while the cron-triggered backup is running. I've figured out the relevant DBus messages I need for that: qdbus org.kde.nepomuk.services.nepomukstrigiservice \ /nepomukstrigiservice isSuspended qdbus org.kde.nepomuk.services.nepomukstrigiservice \ /nepomukstrigiservice suspend qdbus org.kde.nepomuk.services.nepomukstrigiservice \ /nepomukstrigiservice resume I'm still looking for an elegant way to find all running sessions. Currently, the best I can think of looks something like this . /usr/share/acpi-support/power-funcs CMD=one of the above for x in /tmp/.X11-unix/* ; do displaynum=`echo $x | sed s,/tmp/.X11-unix/X,,` getXuser if [ x"$XUSER" != x"" ] ; then su -c "$CMD" $XUSER fi done Well, it works, but it sure isn't elegant. Michael -- Michael Schuerig mailto:mich...@schuerig.de http://www.schuerig.de/michael/ -- To UNSUBSCRIBE, email to debian-kde-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/201003091749.18943.mich...@schuerig.de