How to prevent my screen from either dimming or the screen-lock starting when watching YouTube?
HOWTO: Disable screen saver while Flash is running
Create a bash text file containing
#!/bin/bash
# Cleanup any bad state we left behind if the user exited while flash was
# running
gconftool-2 -s /apps/gnome-screensaver/idle_activation_enabled --type bool true
we_turned_it_off=0
while true; do
sleep 60
flash_on=0
for pid in `pgrep firefox` ; do
if grep libflashplayer /proc/$pid/maps > /dev/null ; then
flash_on=1
fi
ss_on=`gconftool-2 -g /apps/gnome-screensaver/idle_activation_enabled`
if [ "$flash_on" = "1" ] && [ "$ss_on" = "true" ]; then
gconftool-2 -s /apps/gnome-screensaver/idle_activation_enabled \
--type bool false
we_turned_it_off=1
elif [ "$flash_on" = "0" ] && [ "$ss_on" = "false" ] \
&& [ "$we_turned_it_off" = "1" ]; then
gconftool-2 -s /apps/gnome-screensaver/idle_activation_enabled \
--type bool true
we_turned_it_off=0
fi
done
done
Make the script executable by running:
chmod +x ~/path/to/script/flash_saver.sh
Run the script:
~/path/to/script/flash_saver.sh
If you prefer, you can set this script to run at logon by doing the following:
- Run the program "Startup Applications"
- Click "Add"
- Under name type "FlashMonitor" or something you will recognise
- Under command type the path to the script
- Under comment (if you want) type a brief description. E.g. "Stops screen turning off when Flash is running"
Source: HOWTO: Disable screen saver while Flash is running - ubuntuforums
EDIT
This probably will not work if you are using an Ubuntu version newer than 12.04 (have tried in 13.04 and 13.10 and it just does not work at all). It seems the main developer is not working anymore in this project, so the chances of it being fixed are not good.
In my system (Ubuntu 11.10) i use Caffeine. You can try if it works in Xubuntu too. It adds a notification area icon where you can enable/disable screensaver for some programs. To install Caffeine, do the following:
sudo add-apt-repository ppa:caffeine-developers/ppa
sudo apt-get update
sudo apt-get install caffeine
Then execute in a terminal:
caffeine -p &
You can then choose the programs that should disable the screensaver:vlc
for VLC, mplayer
for Movie Player, etc.
Hope it helps.
There is a nice little script on GitHub called lightsOn which should do the trick you want.
Basically it looks for full screen video (flash in firefox or chromium, mplayer or vlc) and if so disable xscreensaver and also the auto power-manager dim screen capability.
from the script itself:
HOW TO USE: Start the script with the number of seconds you want the checks for fullscreen to be done. Example: "./lightsOn.sh 120 &" will Check every 120 seconds if Mplayer, VLC, Firefox or Chromium are fullscreen and delay screensaver and Power Management if so. You want the number of seconds to be ~10 seconds less than the time it takes your screensaver or Power Management to activate. If you don't pass an argument, the checks are done every 50 seconds.
Thus call the script from your autostart folder as per my answer here.
Adjust the script for whether you are running flash/vlc/mplayer
remember to give the script execute rights to run i.e.
chmod +x lightsOn.sh
Not entirely what you're after but this little script would register a mouse movement each time it was run. You could drop it into cron to run once every x-amount-of-time. That would stop the screen from turning off, and a 1 1 movement of the mouse is barely noticeable if it runs when you're NOT watching a video
#!/bin/bash
#move the mouse
xte 'mousermove 1 1'
I totally got this idea from an xkcd comic by the way. http://xkcd.com/196/