How to know if a Linux machine is locked programmatically?
Hi,
In my program, I am tyring to find whether a linux machine is screen locked or not, but i am not finding any suitable command to do this. Please help me to know whether a machine is screen locked or not, any command ? Thanks, Prashant |
Hi,
Welcome to LQ! By the LQ Rules, we should not discus or present the means to crack a machine. Your post is on the fringe. I think your speaking of the WM lock screen function for some desktops. That too can be considered cracking. What exactly is your purpose for the program? Please be more specific. |
Ok..
So here is the story I have a program which gets loaded during system boot and remains up till the shutdown/reboot/logout. I want to handle a case where the user logs in and then lock the computer. If locked, execute PATH1 and if unlocked then execute PATH2. The execution of program will be different based on the system lock and unlock. So is there any way (command) to find out whether the system is Screen lock and unlock? Thanks, Prashant |
Quote:
I don't see how being able to poll the state of a locked desktop from a program would aid a cracker. their program would already be running. Anyway, I don't know what facilities are available to query/monitor this programatically but it sounds like it'd be in the realm of desktop integration, so perhaps there's something sent over dbus? |
Hi,
I can! For instance in a LAB environment were you lock screens while collecting data. Or locking it so colleagues won't have access while your away from the station... Other examples can be presented. When the screen or machine is locked it is done for the reason of securing it from access. |
Do a web search for "dbus screen lock". If your particular version of GNU/Linux supports HAL and DBUS, you can detect whether a screen is locked via HAL or DBUS.
|
Quote:
Anyway, the guy's not responded again, so I guess it doesn't matter. |
I too can't see any problems with this request.
The man page for xscreensaver-command has a perl script example that does it: http://manpages.ubuntu.com/manpages/...command.1.html |
What happens if you are locking your screen with xlock? xlockmore? slock? noctilucentsflufflyscreenlock? How would you go about detecting it then? As far as I can tell [by -briefly- inspecting some source code] X screen locking is accomplished by a program which spawns an X window, maximizes it and 'intercepts' [in need of a better word] key presses, etc. [X events].
|
Process named 'kdesktop_lock' ....
I have observed on KDE, when the computer is locked, one process named 'kdesktop_lock' starts running, so i chan check for this process and can decide whether the current machine running KDE is locked/unlock.
:) Should I rely on 'kdesktop_lock' process to find the lock/unlock state of a machine? What abt GNOME? Thanks all of you for this discussion. |
All times are GMT -5. The time now is 05:01 AM. |