Bug 116304 - Provide a way to check if the display is locked
Summary: Provide a way to check if the display is locked
Status: RESOLVED FIXED
Alias: None
Product: kscreensaver
Classification: Miscellaneous
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: kscreensaver bugs tracking
URL:
Keywords:
Depends on:
Blocks: 224450
  Show dependency treegraph
 
Reported: 2005-11-14 03:27 UTC by kde2eran
Modified: 2015-01-23 09:23 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kde2eran 2005-11-14 03:30:14 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources

Knowing whether the display is locked can be useful for security applications. However, there is currently no way to check this. The locking is activated by kde_desktop, which informs only kdm (by sending "lock" to its socket, see kdebase/kdesktop/lock/lockprocess.cc), and kdm keeps this information to itself.

I suggest adding an "is_locked" command to the kdm socket interface, which will query whether the current display is locked (i.e., returns d->hstent->lock ? "1\n" : "0\n" ). Or maybe, to allow for future expansion, a "status" command that will return a list of keywords, currently either "locked" or "unlocked". 

This way the locking status can then be checked easily, e.g., using "kdmctl is_locked".

BTW, it would be useful to also have ways to get notified of change (by event instead of polling), and to check the status of the screen saver (as opposed to locking). But these probably can't be done by kdm.
Comment 1 Oswald Buddenhagen 2006-01-15 19:41:29 UTC
doing this via kdm is certainly simple, but really ugly. the "lock" command is only a hint, and ugly enough as it is. it would be way better if kdm could find this out another way ... which brings us back to your request.

unfortunately, i know neither what exists nor what would make sense if we need to invent something (and convince everybody else to use it).
Comment 2 Lubos Lunak 2006-01-20 17:13:25 UTC
This has nothing to do with kdm. There's dcop interface for kdesktop (dcop kdesktop KScreensaverIface) but there's no isLocked(), only isBlanked(), and that's KDE-specific anyway. I myself don't quite see the purpose of finding out whether the screen is locked.
Comment 3 kde2eran 2006-01-20 17:29:47 UTC
Here's one use for this functionality:
  http://thinkwiki.org/wiki/Script_for_theft_alarm_using_HDAPS
It activates an alarm if the laptop is physically moved when the display is locked. To check the locking, it employd an ugly distribution-specific kludge.
More generally, a locked screen indicates the user doesn't want others to mess with the computer, and this may have implications for other devices.
Comment 4 Lubos Lunak 2006-01-20 17:39:21 UTC
I guess just checking whether the screen is blanked can do as well there.
Comment 5 kde2eran 2006-01-20 18:02:16 UTC
No, a blanked screen means just that the user hasn't typed/mouses for a while, not that he wants to restrict access. When you sit with a laptop on your lap in a lecture, you don't want an alarm to go off whenever the screensaver kicks in.
Comment 6 Oswald Buddenhagen 2006-01-20 19:59:24 UTC
i have to agree with eran, in all points.
the kdm "lock" command is a security feature: prevent auto-relogin if the session (was) crashed while the screen locker was running. it would be *very* advantageous if this worked out of the box without making all screen lockers kdm-aware first.
Comment 7 Oswald Buddenhagen 2008-04-25 22:40:53 UTC
in kde4, the GetActive function and the ActiveChanged signal of the the org.freedesktop.ScreenSaver D-Bus interface can be used to track the saver's status. it does not tell whether the saver is actually a locker, though.
Comment 8 Martin Flöser 2015-01-23 09:23:33 UTC
In Plasma 5 the signal and function from comment #7 is a sufficient solution. It reflects correctly whether the screen is locked. As there are no screen savers any more it will return "true" whenever the screen is locked.