Re: Checking whether Gnome screensaver currently active

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

 



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.

OK, now it looks like I might just have been hit by a glitch.  On another
machine, I found that

     DISPLAY=:0.0 gnome-screensaver-command -q

works just fine in a cron job.  After rebooting the desktop system where I'd
been having the problem (system had been up 22 days with me poking around
trying things), it works fine there, too.

So, all I can say is, "Sorry for contributing to the noise here."  At least
I've learned a few things from some of the responses.  Thanks, all.

-- 
Bob Nichols     "NOSPAM" is really part of my email address.
                 Do NOT delete it.

-- 
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]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux