linux - Bash Script as ScreenSaver -


i trying create script use movie screensaver, once movie opened, system freezes , reboots.

i have been pulling hairs off of head because cannot figure out why happens. tried same script in machine , worked many months...

the machine worked on linux mint 13 machine , 1 didn't work on linux mint 17 machine.

the script following:

#!/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 on " >> mylog.log      else         ./test.sh &      fi  else     if [ $(pidof mplayer) ];then          pkill mplayer      else         echo "screen off." >> mylog.log      fi  fi  done 

the idletime program same xprintidle... uses x server system's idle time. test.sh script follows:

#!/bin/bash  mplayer -nostop-xscreensaver movie.mp4 -fs -loop 0 

thank you!

what's happening denial of service attack.

if have 2 mplayer processes, script starts bombing system, starting infinite number of mplayers possible.

use shellcheck. have warned missing quotes in if [ $(pidof mplayer) ]. correct code is:

if [ "$(pidof mplayer)" ]   echo "there 1 or more mplayer processes" else   echo "there no mplayer processes." fi 

it can more directly written

if pidof mplayer > /dev/null    ... 

ps: can replace while true while sleep 1, reduce script's cpu usage 100% <1% no loss of functionality.


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -