You can disable the screensaver by running xset s off
.
Enable it again by writing xset s 5
, where 5 is the number of seconds it takes your screensaver to come back on.
If you want to write a script, you could attempt to do something like this:
#!/bin/bash
# Wrapper around the main body to facilitate being run
# from a startup file like .xinitrc, ~/.config/autostart, ...
while :; do
if pgrep xscreensaver >/dev/null; then
METHOD="xscreensaver"
pkill xscreensaver
else
METHOD="xset"
xset s off
fi
# If you want to be really fancy:
## notify-send "Screensaver Disabled" $"The Flash plugin is running"
while ps ax | grep libflashplayer.so >/dev/null; do
sleep 1 # Sleep while waiting for Flash to exit
done
if [ "$METHOD" = "xscreensaver" ]; then
xscreensaver &
else
xset s 30
fi
# If you want to be really fancy:
## notify-send "Screensaver Enabled" $"The Flash plugin has exited"
sleep 30
done
At @snapfractalpop's request, a short use guide:
Put this somewhere in your home directory - it doesn't matter. You probably want to make a ~/bin
directory if you don't have anywhere for personal scripts already. For the purpose of this explanation, I'll assume you put it in ~/bin/youtube-scrn-svr.sh
.
chmod +x ~/bin/youtube-scrn-svr.sh
or make it executable some other way.
Assuming your DE is one of the common ones (XFCE, GNOME, and KDE can load scripts this way), create a file called ~/.config/autostart/flash-screensaver.desktop
and add the following to it.
[Desktop Entry]
Name=Flash Screensaver Disabler
Exec=/home/WHATEVER_YOUR_USERNAME_IS/bin/youtube-scrn-svr.sh
Terminal=false
Categories=Network;
StartupNotify=false
Try logging out and watching a suitably long video, and see if the screensaver is enabled.