newbie question: how to determine that the screen is locked

Dear all,

I hope this isn't too much of a newbie question, I have read all the
docs I can find before asking:

I want to detect, automatically via cron job on a couple of hundred
computers, whether or not screens are locked with gnome-screensaver
and if so, how long for and who by, in order to generate a management
friendly report, sigh.

I have no problem getting the root cron job to fake up user and X setup
to be able to run X-based status gathering queries as the appropriate
user, but I'm having difficulty finding a command to run, even as the
logged in user, to determine whether the screen is REALLY locked.

I know about "gnome-screensaver-command -t -q" which reports the
state (eg active) and the duration (eg. active for 10 minutes).  I also
tried various dbus-based queries, using the Gnome screensaver DBus

such as:

dbus-send --session \
          --dest=org.gnome.ScreenSaver \
          --type=method_call \
          --print-reply \
          --reply-timeout=20000 \
          /org/gnome/ScreenSaver \


dbus-send --session ...

However, all my experiments show that all 3 queries:

- "gnome-screen-saver -t -q"
- "dbus-send ... GetActiveTime"
- "dbus-send ... GetSessionIdleTime"

are simply reporting how long the screen saver has been active.  They
seem to make no distinction between active and locked!

The above Dbus documentation says explicitly under "SetActive":

   "Active means that the screensaver has blanked the screen and may
    run a graphical theme. This does not necessary[sic] mean that the
    screen is locked."

Ok, so that explains why GetActive* queries don't report on the
screen lock status, without saying what does.  I haven't found an
equivalent definition of "idle" in any of the docs so far.

The Dbus docs show that the screen saver has the method "Lock()" which
force locks the screen (which I've tested via dbus-send, very cool but
not what I want today), but there doesn't seem to be anything like an
"IsLocked()" method.  Clearly the screen saver itself knows whether it's
locked or not.  Surely there must be a rock solid way for me to find
out, or is this not exposed to view for some reason?


Duncan C. White, Systems Manager, Computing Support Group,
		 Dept of Computing, Imperial College London, SW7 2BZ, UK.
Email:	dcw doc ic ac uk			       Phone: 0207 594 8254
URL:                  Fax:   0207 594 8389

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