I'm looking for a cross Linux method to detect if screensaver (both XScrenSaver and non-XSCreenSaver) is running or if locked screen is up. Bash or C method would be awesome. Can you please help me find this method?

I was going by this x11 method here:https://askubuntu.com/questions/567309/methods-to-detect-screensaver-and-or-locked (spent two weeks on it!: https://github.com/Noitidart/_scratchpad/blob/master/ScreensaverWindowExists%20addon%20test%20template.js)

But that method fails on Ubuntu (and maybe Mint) which are the most common Linux distributions.


2 Answers 2


To what end?

Presumably you want to take some action if it is running, and possibly stop when the screensaver ends.

I solved the former problem on my machine with xautolock.


this is extracted from: http://blogs.technet.com/b/heyscriptingguy/archive/2005/08/10/how-can-i-tell-if-the-screen-saver-is-active.aspx

"When the screen saver runs, it typically runs a file with a .scr file extension. If we want to know whether or not the screen saver is running all we have to do is check and see if there are any processes running that have an executable name ending in .scr. If there are, that probably means the screen saver is running."

  • Thanks for the comment ricard, thats a windows solution it looks like.
    – Noitidart
    Jan 4, 2015 at 3:42
  • Welcome to Unix & Linux. As the site name indicates, answers about Windows are not useful here. Jan 4, 2015 at 23:53

You must log in to answer this question.

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