[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Disable and Enable Screensaver via Bash Script



On Wed, Oct 17, 2018 at 06:43:38PM +0000, Matthew Crews wrote:

[...]

> Makes sense to me. So I would probably need to use a FOR or WHILE loop of some kind to periodically check if my application is running. Would need to play around with it.
> 
> Something else it looks like I could do is:
> 
> #!/bin/bash
> xscreensaver-command -exit   # causes the xscreensaver process to close
> /usr/bin/foo                 # runs my desired application
> xscreensaver                 # restarts xscreensaver process
> 
> While I think my above script will work, its a more brute-force method, and if something breaks then Xscreensaver might not turn back on gracefully. The FOR or WHILE loop would probably be more elegant.
> 
> In any case, this is exactly what I was looking for. Thank you!

This might be a starting point:

  sleep 10 &
  PROC=$!
  
  while true ; do
    echo beep
    kill -0 $! || exit
    sleep 1
  done

Many enhancements possible :-)

Cheers
-- t

Attachment: signature.asc
Description: Digital signature


Reply to: