Re: Checking whether Gnome screensaver currently active

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

 



On Tuesday, January 18, 2011 08:52:57 pm Robert Nichols wrote:
> On 01/18/2011 12:28 PM, Rick Sewill wrote:
> > On Tuesday, January 18, 2011 09:00:22 am Robert Nichols wrote:
> >> On 01/18/2011 01:34 AM, Rick Sewill wrote:
> >>> On Monday, January 17, 2011 10:57:00 pm Robert Nichols wrote:
> >>>> On 01/17/2011 09:57 PM, Rick Sewill wrote:
> >>>>> Question please:
> >>>>> 
> >>>>> Can you use
> >>>>> gnome-screensaver-command -q
> >>>>> 
> >>>>> man gnome-screensaver-command
> >>>>> 
> >>>>> I'm currently trying out KDE so I don't know
> >>>>> what is returned by the above command for the
> >>>>> various gnome-screensaver states.
> >>>> 
> >>>> As I said in my original message, when run from a cron job that fails:
> >>>>         ** Message: Failed to connect to the D-BUS daemon:
> >>>>         /bin/dbus-launch terminated abnormally with the following
> >>>>         error: Autolaunch error: X11 initialization failed.
> >>>> 
> >>>> And yes, I did try it with "DISPLAY=:0.0" in the environment.
> >>> 
> >>> You have a good puzzle!
> >>> 
> >>> I read all the responses for the problem,
> >>> http://www.mail-archive.com/debian-kde@xxxxxxxxxxxxxxxx/msg30421.html
> >>> 
> >>> I tried to condense their answer to the following...please give it a
> >>> try:
> >>> 
> >>> I created a file, ${HOME}/bin/testscreensaver
> >>> ===== Please begin contents of file testscreensaver with following line
> >>> #!/bin/bash
> >>> 
> >>> # We must set the DISPLAY variable so dbus is happy.
> >>> 
> >>> export DISPLAY=:0.0
> >>> 
> >>> # We must find the DBUS_SESSION_BUS_ADDRESS so dbus is happy.
> >>> 
> >>> for pid in $(pgrep -u $USER)
> >>> do
> >>> 
> >>>       declare DBUS_SESSION_BUS_ADDRESS=$(cat /proc/${pid}/environ | \
> >>>       
> >>>               tr '\0' '\n' | grep "DBUS_SESSION_BUS_ADDRESS=")
> >>> 
> >>> # I looked for the first DBUS_SESSION_BUS_ADDRESS found.
> >>> 
> >>>       [ -z "${DBUS_SESSION_BUS_ADDRESS}" ] || break
> >>> 
> >>> done
> >>> 
> >>> 
> >>> # Strip off the DBUS_SESSION_BUS_ADDRESS= string at the beginning.
> >>> DBUS_SESSION_BUS_ADDRESS="${DBUS_SESSION_BUS_ADDRESS:25}"
> >>> 
> >>> # I echo it for debugging purposes...you probably don't want to echo
> >>> it. echo "Set bus address to<${DBUS_SESSION_BUS_ADDRESS}>"
> >>> 
> >>> # If I have a string, I call the gnome-screensaver-command
> >>> [ -z "${DBUS_SESSION_BUS_ADDRESS}" ] || gnome-screensaver-command -q
> >>> 
> >>> ===== Please end file testscreensaver with previous line
> >> 
> >> Hmmm, in that script you're not doing anything with
> >> DBUS_SESSION_BUS_ADDRESS beyond testing for non-null (it's not
> >> exported), so "Set bus address to" is a misnomer.  "Found bus address"
> >> might be more to the point.  It does test whether this user currently
> >> has a session, which is useful.
> > 
> > Please see "man dbus-daemon".
> > 
> > I believe the variable, DBUS_SESSION_BUS_ADDRESS, must be set for desktop
> > applications to find the per-session daemon to have interprocess
> > communication amongst themselves.  From "man dbus-daemon", I am
> > referring to the per-session daemon, not the systemwide daemon.
> 
> Look again at the script you posted and explain where it does anything but
> set and test for non-null an internal shell variable that has no special
> meaning to the shell itself.  Had you in some manner exported that variable
> so that gnome-screensaver-command could see it, then I would have more
> reason to believe you.

I stand corrected. 

 I ran a test without DBUS_SESSION_BUS_ADDRESS set.
Only the export DISPLAY=:0.0 seems to be needed.



Attachment: signature.asc
Description: This is a digitally signed message part.

-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux