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

Re: Activating gnome-screensaver from /etc/acpi/sleepbtn.sh



Andrew Sackville-West wrote:
> So you have to somehow get that variable out of your X session, maybe
> by putting that set | grep command at the end of your .xinitrc or
> whatever you use to launch X. and then you've got to somehow export
> that variable so that the gnome-screensaver-command can access it. 

I solved it now.

This approach seems a little bit more robust as it doesn't involve the
individual user doing anything to make it work.

GS_PID=`pgrep -u $user -f "gnome-screensaver"

DBUS_SESSION_BUS_ADDRESS=`grep -z DBUS_SESSION_BUS_ADDRESS \
                          /proc/$GS_PID/environ | \
                          sed -e 's/DBUS_SESSION_BUS_ADDRESS=//'`

export DBUS_SESSION_BUS_ADDRESS; su $user -c "$GNOMESCREENSAVER_LOCK"

-- 
Regards / Med vänlig hälsning:
  Marcus Libäck <marcus at terminal dot se>
  http://terminal.se/



Reply to: