title: Bash Script as ScreenSaver
body: <p>I am trying to create a script to use a movie as ScreenSaver, but once the movie is opened, the system freezes and reboots.</p>
  
  <p>I have been pulling hairs off of my head because I cannot figure out why this happens. I tried the same script in another machine and it worked perfectly for many months...</p>
  
  <p>The machine it worked on was a Linux Mint 13 machine and the one it didn't work on was a Linux Mint 17 machine.</p>
  
  <p>The script is the following:</p>
  
  <pre><code>#!/bin/bash
  screen_on=false;
  state=0;
  time_idle=1200;
  
  while true;do
  
  IDLE=$(./idletime)
  
  
  if [ $IDLE -gt $time_idle ];then
  
      if [ $(pidof mplayer) ];then
  
          echo "Screen is on " &gt;&gt; mylog.log
  
      else
          ./test.sh &amp;
  
      fi
  
  else
      if [ $(pidof mplayer) ];then
  
          pkill mplayer
  
      else
          echo "Screen is off." &gt;&gt; mylog.log
  
      fi
  
  fi
  
  done
  </code></pre>
  
  <p>The idletime program is actually the same as xprintidle... It uses the X Server to get the system's idle time.
  The test.sh script is as follows:</p>
  
  <pre><code>#!/bin/bash
  
  mplayer -nostop-xscreensaver movie.mp4 -fs -loop 0
  </code></pre>
  
  <p>Thank you!</p>