LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Can bash check if screensaver is running? (https://www.linuxquestions.org/questions/linux-newbie-8/can-bash-check-if-screensaver-is-running-844089/)

zensunni 11-13-2010 02:12 PM

Can bash check if screensaver is running?
 
I have a bash script that messages the user periodically.

Is there any way in the script to check if the screensaver is running, so the script doesn't spam messages while the user is away?

The xscreensaver process is always running in the background, I've noticed.

What would be the best way to go about this?

colucix 11-13-2010 02:27 PM

The gnome-screensaver offers the possibility to query the state of the screensaver with the following command:
Code:

gnome-screensaver-command -q
I don't know if there is something similar for xscreensaver, but the process continuously running in the background puzzles me. I have xscreensaver on my current system, but there is no active process while I'm working at my desktop.

syg00 11-13-2010 05:10 PM

Interestingly gnome screensaver shows up in the process list. The query responds with "inactive" and "not inhibited".
The things you learn ...

Bratmon 11-13-2010 07:09 PM

Code:

xscreensaver-command -time
Prints that, and a bunch of other information besides.

zensunni 11-19-2010 02:31 PM

Thanks Bratmon. But no cigar. I've created this script:

Code:

#!/bin/bash

for (( ; ; ))
do

  #sleep 3600
  #sleep 600
  sleep 5
  xscreensaver-command -time

done

It's output is a long stream of this:
Code:

xscreensaver-command: no screensaver is running on display :0.0
xscreensaver-command: no screensaver is running on display :0.0
xscreensaver-command: no screensaver is running on display :0.0
xscreensaver-command: no screensaver is running on display :0.0
(etc, etc)

When I leave my computer alone and the screensaver turns on, I would expect the output to start streaming something other than the above, but it's the same.

So, I'm still at square one.


All times are GMT -5. The time now is 10:23 PM.