I'm running OpenSUSE Leap 42.3 with XFCE and it uses xscreensaver.
I want to somehow get True if screensaver is currently working. You can't just look at process list, xscreensaver always sits there.
Is there any easy way to do that?
I'm running OpenSUSE Leap 42.3 with XFCE and it uses xscreensaver.
I want to somehow get True if screensaver is currently working. You can't just look at process list, xscreensaver always sits there.
Is there any easy way to do that?
Use the subprocess
module to run xscreensaver-command
:
def check_screensaver():
p = subprocess.run(['xscreensaver-command', '-time'], stdout=subprocess.PIPE)
words = p.stdout.decode().split()
return 'blanked' in words
This simple code looks for the word 'blanked' in the output. You could parse it further to extract the time it was activated/deactivated.