LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   LinuxQuestions.org Member Success Stories (https://www.linuxquestions.org/questions/linuxquestions-org-member-success-stories-23/)
-   -   Enable/Disable Screensaver While Gaming (https://www.linuxquestions.org/questions/linuxquestions-org-member-success-stories-23/enable-disable-screensaver-while-gaming-4175657999/)

dugan 07-25-2019 12:07 AM

Enable/Disable Screensaver While Gaming
 
I'm still having issues with the screensaver (I use xscreensaver) going on when I'm in the middle of games. I'd be playing on the gamepad and I would get interrupted.

I understand that there are two factors involved:
  • the games (and programs like WINE, emulators, etc) aren't disabling the screen saver like they should (solve with caffeine)
  • the gamepad's actions aren't holding off the screensaver like they should (solve with joystickwake)
I looked at the existing solutions and of course I said: I'm going to roll my own.

A script to enable_blanking:
Code:

#!/usr/bin/env bash

sed -i 's/\(timeout:\s\+\)[0-9:]\+/\10:10:00/g' ~/.xscreensaver

A script to disable_blanking:
Code:

#!/usr/bin/env bash
sed -i 's/\(timeout:\s\+\)[0-9:]\+/\112:00:00/g' ~/.xscreensaver

Notice that all they do is sed the xscreensaver config file and change the blanking interval there. This works because that file gets automatically reloaded whenever it's changed.

For desktop integration, I just put them in my PATH and launch them from dmenu.

Oh, and to show the current screen blanking interval?

A script to show_blank_interval:
Code:

#!/usr/bin/env bash
cat ~/.xscreensaver | awk '/timeout/ {print $2}'

You just put that into any status indicator that shows command output: i3bar, xmobar, conky, whatevever.

Here's my line in ~/.conkyrc:

Code:

${exec show_blank_interval}

dugan 07-25-2019 10:05 AM

This should work better.

This should internally call the XResetScreenSaver function to do it properly.

enable_blanking:

Code:

#!/usr/bin/env_bash
xset s on
xset +dpms

disable_blanking:
Code:

#!/usr/bin/env bash
xset s off
xset -dpms

show_blank_interval
Code:

#!/usr/bin/env bash
xset q | awk '/timeout:/ {timeout=$2} /DPMS is/ {dpms=$3} END { print dpms, timeout}'

Again: I launch the enable/disable scripts from dmenu, and put show_blank_interval in Conky.


All times are GMT -5. The time now is 01:52 PM.