How do I run a scripts when screen saver activates?
I have a scripts, say foo.sh, I want to activate when the screen saver is active and deactivate when the user comes back on line.
Basically foo.sh is some custom processing I want to do in the computer idle times. I figure hooking into the screen saver or monitor power saver mode some how would be the ideal way to detect this. Does anyone have any suggestions. |
I don't know which script would need to be edited in order to stick your command in it (I too would like to find out), but I just thought I would mention that there's also another way you could approach this: Have a cron job run every minute checking to see whether a screensaver is running. If there is, your program gets started; if there's not (and your program is running), your program is stopped; if there's not (and your program isn't running), nothing is done.
Yes, this method sucks compared to what you currently have in mind, but it's an alternative nevertheless. Like I said, I too look forward to learning which script to edit in order to do this in a more kosher way. I don't have anything serious which I'd want to execute when the screensaver comes on but making an ogg/mp3 play would be cool. :) |
Good I idea... but if I was going to create a script like that I'd want to base it on more than the screen saver.
ie: what if the computer is on but no users are logged in. Also account for system load. I have discovered something about gnome screen savers. Creating them is very easy. I could design a new screen saver which calls say slideshow and my program. So far I've just found this... I haven't actually played with it yet. Code:
[mcarter@snow-faerie screensavers]$ cat /usr/share/applications/screensavers/frogs-slideshow.desktop |
Well no luck on the screen saver front. However I did find something to work. My script runs through a loop. The processing maxes the CPU for about 2 seconds. Then moves to the next.
So I put in a check after each processing to see if the tty has been idle for more than 15 minutes. (main command being "w") Does the trick. I just wish there was a better way to handle time. Code:
echo "Pausing for Computer to be idle" |
I'm looking to do the same. I want the machine to do some work when the screensaver is on and stop when the screen saver is off. One idea I had that might work is to base to activation and deactivation on whether the screen is locked or not. I almost ALWAYS lock my screen so I thought I could use that as a trigger but I really don't know how or where to get started looking.
Any thoughts? |
Quote:
I went a totally different route and looked for when the computer tty sessions were idle for 15 minutes. Code:
echo "Pausing for Computer to be idle" |
All times are GMT -5. The time now is 09:29 AM. |