Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using a Linux (RHEL6) workstation. I have a small script I wrote which locks and unlocks the screen via xscreensaver when I connect or disconnect my USB thumb drive, which effectively turns it into a physical key to my workstation. The problem is that there doesn't seem to be a good way to unlock xscreensaver from the command line. xscreensaver-command -deactivate, counterintuitively, only "simulates user activity" and still requires a password to unlock the screen. xscreensaver-command -exit only kills the parent daemon xscreensaver if there is not a screensaver running. As the man page for xscreensaver-command -exit warns,

Warning: never use kill -9 with xscreensaver while the screensaver is active.  If you are using a virtual root window  manager,
that can leave things in an inconsistent state, and you may need to restart your window manager to repair the damage.

Indeed, I am currently using pkill xscreensaver as my method to get rid of the screensaver from a script, which often results in zombie processes and other messes. How can I unlock the screensaver safely from a script/the command line?

share|improve this question
    
Given the philosophy underlying its design, I strongly doubt that stock xscreensaver will unlock without a password by any method short of the forcible kill you're currently using. Your best option would likely be to modify the source to include something like a "-forceunlock" option, and build your own binary from that. – Aaron Miller Jul 8 '13 at 17:39
    
Thank you Aaron. I don't see how your link is relevant, but I trust that you're correct. If this were an answer, I would accept it, though it is not what I want to hear. – jayhendren Jul 8 '13 at 18:17
    
Comment converted to answer, and expanded to give greater background. Glad to be of help! (And, hey, it probably won't be all that hard to modify the source -- inasmuch as I'm competent to pass any kind of judgment on jwz's code, I have found it extremely well-written and easy to work with.) – Aaron Miller Jul 8 '13 at 18:42
up vote 2 down vote accepted

Given xscreensaver's near-monomaniacal focus on security, as hinted at by the answers in jwz's xscreensaver FAQ and further elucidated in On Toolkits, I strongly doubt that stock xscreensaver will unlock without a password by any method short of the forcible kill you're currently using. Your best option would likely be to modify the source to include something like a "-forceunlock" option, and build your own binary from that.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .