[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

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
> 
> <michael@schuerig.de>) 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:michael@schuerig.de
http://www.schuerig.de/michael/


Reply to: