Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #201275 > unrolled thread

Disable and Enable Screensaver via Bash Script

Started byMatthew Crews <mailinglists@mattcrews.com>
First post2018-10-16 02:00 +0200
Last post2018-10-17 22:00 +0200
Articles 6 — 5 participants

Back to article view | Back to linux.debian.user


Contents

  Disable and Enable Screensaver via Bash Script Matthew Crews <mailinglists@mattcrews.com> - 2018-10-16 02:00 +0200
    Re: Disable and Enable Screensaver via Bash Script <tomas@tuxteam.de> - 2018-10-16 09:20 +0200
      Re: Disable and Enable Screensaver via Bash Script Cindy-Sue Causey <butterflybytes@gmail.com> - 2018-10-16 13:20 +0200
        Re: Disable and Enable Screensaver via Bash Script Étienne Mollier <etienne.mollier@mailoo.org> - 2018-10-16 23:00 +0200
      Re: Disable and Enable Screensaver via Bash Script Matthew Crews <mailinglists@mattcrews.com> - 2018-10-17 20:50 +0200
        Re: Disable and Enable Screensaver via Bash Script "tomas@tuxteam.de" <tomas@tuxteam.de> - 2018-10-17 22:00 +0200

#201275 — Disable and Enable Screensaver via Bash Script

FromMatthew Crews <mailinglists@mattcrews.com>
Date2018-10-16 02:00 +0200
SubjectDisable and Enable Screensaver via Bash Script
Message-ID<wJkWd-5nC-1@gated-at.bofh.it>
Hi all,

Currently I am running Stretch with XFCE (window manager is XFWM4). I
presently use Xscreensaver for my screen saver. Caffeine indicator
doesn't work with XFCE as far as I've been able to tell, so if I want to
temporarily disable the screensaver I need to do so manually, and
re-enable it manually.

I'm wondering, is there a way to perform this feature with a bash
script? What I'm looking for is a bash script that does the following,
in sequence:

1. Disable Xscreensaver
2. Run a given application
3. When the application closes, re-enable Xscreensaver

Any help would be appreciated. Thanks.

-Matt

[toc] | [next] | [standalone]


#201286

From<tomas@tuxteam.de>
Date2018-10-16 09:20 +0200
Message-ID<wJrO1-1dS-1@gated-at.bofh.it>
In reply to#201275

[Multipart message — attachments visible in raw view] — view raw

On Mon, Oct 15, 2018 at 11:51:48PM +0000, Matthew Crews wrote:
> Hi all,
> 
> Currently I am running Stretch with XFCE (window manager is XFWM4). I
> presently use Xscreensaver for my screen saver. Caffeine indicator
> doesn't work with XFCE as far as I've been able to tell, so if I want to
> temporarily disable the screensaver I need to do so manually, and
> re-enable it manually.
> 
> I'm wondering, is there a way to perform this feature with a bash
> script? What I'm looking for is a bash script that does the following,
> in sequence:
> 
> 1. Disable Xscreensaver
> 2. Run a given application
> 3. When the application closes, re-enable Xscreensaver

"One" way to do it would be to issue periodically "xscreensaver-command -deactivate"
while your application is running [1].

Here [2] is a practical example, for video players.

Enjoy

[1] https://www.jwz.org/xscreensaver/man3.html
[2] https://www.jwz.org/xscreensaver/faq.html#dvd
-- tomás

[toc] | [prev] | [next] | [standalone]


#201303

FromCindy-Sue Causey <butterflybytes@gmail.com>
Date2018-10-16 13:20 +0200
Message-ID<wJvyi-3sw-9@gated-at.bofh.it>
In reply to#201286
On 10/16/18, tomas@tuxteam.de <tomas@tuxteam.de> wrote:
> On Mon, Oct 15, 2018 at 11:51:48PM +0000, Matthew Crews wrote:
>> Hi all,
>>
>> Currently I am running Stretch with XFCE (window manager is XFWM4). I
>> presently use Xscreensaver for my screen saver. Caffeine indicator
>> doesn't work with XFCE as far as I've been able to tell, so if I want to
>> temporarily disable the screensaver I need to do so manually, and
>> re-enable it manually.
>>
>> I'm wondering, is there a way to perform this feature with a bash
>> script? What I'm looking for is a bash script that does the following,
>> in sequence:
>>
>> 1. Disable Xscreensaver
>> 2. Run a given application
>> 3. When the application closes, re-enable Xscreensaver
>
> "One" way to do it would be to issue periodically "xscreensaver-command
> -deactivate"
> while your application is running [1].
>
> Here [2] is a practical example, for video players.
>
> Enjoy
>
> [1] https://www.jwz.org/xscreensaver/man3.html
> [2] https://www.jwz.org/xscreensaver/faq.html#dvd


SMPlayer has a preexisting preference option where you can toggle this
very feature on and off. It's found under:

Options > Preferences > General > Video

Down at the bottom of that tab, it says, "Disable Screensaver". The
tooltip says the screensaver will become enabled again when the video
stops playing.

A quick test drive shows that toggling that line on and off changes
the "disable_screensaver=true" line in
~/.config/smplayer/smplayer.ini. Not sure what that touches next,
though, and I need to keep moving onto something else this morning. In
the meantime, I'm imagining it touching something close to what tomas
has shared. :)

Just mentioning it out loud because of tomas offering this up now.
Maybe it's a wishlist item that can be suggested to other packages
that don't offer the same. Between tomas' offering above and SMPlayer
already having similar implemented, it won't be as hard for other
packages to try to add this same *user friendly* feature if they know
it exists. :)

Glass definitely not half full, I can't help but smell a really stinky
can of worms with this because of bugs it would surely trigger in the
early stages.... * sorry 'bout that!* :D

Cindy :)
-- 
Cindy-Sue Causey
Talking Rock, Pickens County, Georgia, USA

* runs with duct tape *

[toc] | [prev] | [next] | [standalone]


#201335

FromÉtienne Mollier <etienne.mollier@mailoo.org>
Date2018-10-16 23:00 +0200
Message-ID<wJEBz-fP-13@gated-at.bofh.it>
In reply to#201303
On 10/16/18 1:10 PM, Cindy-Sue Causey wrote:
> On 10/16/18, tomas@tuxteam.de <tomas@tuxteam.de> wrote:
>> On Mon, Oct 15, 2018 at 11:51:48PM +0000, Matthew Crews
>> wrote:
>>> Hi all,
>>>
>>> Currently I am running Stretch with XFCE (window manager is
>>> XFWM4). I presently use Xscreensaver for my screen saver.
>>> Caffeine indicator doesn't work with XFCE as far as I've
>>> been able to tell, so if I want to temporarily disable the
>>> screensaver I need to do so manually, and re-enable it
>>> manually.
>>>
>>> I'm wondering, is there a way to perform this feature with a
>>> bash script? What I'm looking for is a bash script that does
>>> the following, in sequence:
>>>
>>> 1. Disable Xscreensaver
>>> 2. Run a given application
>>> 3. When the application closes, re-enable Xscreensaver
>>
>> "One" way to do it would be to issue periodically
>> "xscreensaver-command -deactivate"
>> while your application is running [1].
>>
>> Here [2] is a practical example, for video players.
>>
>> Enjoy
>>
>> [1] https://www.jwz.org/xscreensaver/man3.html
>> [2] https://www.jwz.org/xscreensaver/faq.html#dvd
>
>
> SMPlayer has a preexisting preference option where you can
> toggle this very feature on and off. It's found under:
>
> Options > Preferences > General > Video
>
> Down at the bottom of that tab, it says, "Disable
> Screensaver". The tooltip says the screensaver will become
> enabled again when the video stops playing.
>
> A quick test drive shows that toggling that line on and off
> changes the "disable_screensaver=true" line in
> ~/.config/smplayer/smplayer.ini. Not sure what that touches
> next, though, and I need to keep moving onto something else
> this morning. In the meantime, I'm imagining it touching
> something close to what tomas has shared. :)
>
> Just mentioning it out loud because of tomas offering this up
> now.  Maybe it's a wishlist item that can be suggested to
> other packages that don't offer the same. Between tomas'
> offering above and SMPlayer already having similar
> implemented, it won't be as hard for other packages to try to
> add this same *user friendly* feature if they know it exists.
> :)
>
> Glass definitely not half full, I can't help but smell a
> really stinky can of worms with this because of bugs it would
> surely trigger in the early stages.... * sorry 'bout that!* :D
>
> Cindy :)
>

Good Day,

Just to add a complement of information, perhaps not necessary
in that precise case, but that can lurk in the dark.  Even if
XScreenSaver is disabled, DPMS settings can, sometimes, still
turn off your screen while you are comfortably watching your
favorite conference record.  You have to hunt for your mouse
while the presentation continues to slide (fortunately, no
password to provide, but still annoying ;-).

On well chosen aliases/functions/scripts, I happen to disable
this with:

	xset -dpms

And after the show, bring back the energy economy mode with:

	xset +dpms

The command is part of x11-xserver-utils, so should be pretty
much available everywhere, except maybe on some pizza boxes...

DPMS may be handled well by most video player, maybe not;
I haven't actually tested them all.  But this is definitely
something to be aware of, especially on custom tailored systems
where any screen saver is thought to have been removed.

Kind Regards,
-- 
Étienne Mollier <etienne.mollier@mailoo.org>

[toc] | [prev] | [next] | [standalone]


#201389

FromMatthew Crews <mailinglists@mattcrews.com>
Date2018-10-17 20:50 +0200
Message-ID<wJZ3j-4hf-1@gated-at.bofh.it>
In reply to#201286
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Tuesday, October 16, 2018 12:14 AM, <tomas@tuxteam.de> wrote:

> On Mon, Oct 15, 2018 at 11:51:48PM +0000, Matthew Crews wrote:
>
> > Hi all,
> > Currently I am running Stretch with XFCE (window manager is XFWM4). I
> > presently use Xscreensaver for my screen saver. Caffeine indicator
> > doesn't work with XFCE as far as I've been able to tell, so if I want to
> > temporarily disable the screensaver I need to do so manually, and
> > re-enable it manually.
> > I'm wondering, is there a way to perform this feature with a bash
> > script? What I'm looking for is a bash script that does the following,
> > in sequence:
> >
> > 1.  Disable Xscreensaver
> > 2.  Run a given application
> > 3.  When the application closes, re-enable Xscreensaver
>
> "One" way to do it would be to issue periodically "xscreensaver-command -deactivate"
> while your application is running [1].
>
> Here [2] is a practical example, for video players.
>
> Enjoy
>
> [1] https://www.jwz.org/xscreensaver/man3.html
> [2] https://www.jwz.org/xscreensaver/faq.html#dvd
> -- tomás


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!

[toc] | [prev] | [next] | [standalone]


#201393

From"tomas@tuxteam.de" <tomas@tuxteam.de>
Date2018-10-17 22:00 +0200
Message-ID<wK093-4U4-1@gated-at.bofh.it>
In reply to#201389

[Multipart message — attachments visible in raw view] — view raw

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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.user


csiph-web