LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-13-2010, 02:12 PM   #1
zensunni
Member
 
Registered: Feb 2008
Posts: 45

Rep: Reputation: 0
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?
 
Old 11-13-2010, 02:27 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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.
 
1 members found this post helpful.
Old 11-13-2010, 05:10 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Interestingly gnome screensaver shows up in the process list. The query responds with "inactive" and "not inhibited".
The things you learn ...
 
Old 11-13-2010, 07:09 PM   #4
Bratmon
Member
 
Registered: Jul 2009
Location: 75.126.162.205:80
Distribution: Arch / Mint 17
Posts: 297
Blog Entries: 3

Rep: Reputation: 50
Code:
xscreensaver-command -time
Prints that, and a bunch of other information besides.
 
1 members found this post helpful.
Old 11-19-2010, 02:31 PM   #5
zensunni
Member
 
Registered: Feb 2008
Posts: 45

Original Poster
Rep: Reputation: 0
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash: Check if a program is running naimslim89 Programming 12 05-08-2012 10:24 PM
[SOLVED] bash script - check process is running, if not start zee# Linux - Newbie 8 02-07-2010 05:50 PM
Bash script to check if process is running and send email depam Linux - Newbie 2 04-08-2009 12:11 AM
Obtain ip address and check for running process via Bash Script? xconspirisist Programming 10 09-12-2008 01:18 PM
running screensaver as background contrasutra Linux - Software 9 04-27-2003 07:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration