XScreenSaver是在X-windows下一个标准的屏幕保护和锁定软件,具有高可配置性,内含超过100个显示模式。但是当我们在X-windows下运行游戏时,不想让XScreenSaver老是跳出来干扰,于是写了这个shell脚本。 它可以在运行一个特定的命令时暂时使xscreensaver失去功能,即在此期间用kill命令杀死xscreensaver的进程,直到相关命令停止运行。
该shell脚本(run-without-xscreensaver.sh)的代码如下:
#!/bin/sh # http://hektor.umcs.lublin.pl/~mikosmul/computing/shell-scripts/run-without-xscreensaver # Written by Michal Kosmulski <mkosmul _at_ users _dot_ sourceforge _dot_ net> # This script is hereby put in the public domain. # # Run the program specified on the command line, disabling xscreensaver for the # time that program is running (useful for games) if [ $# -lt 1 ]; then echo "Usage: $0 command [command-parameters]" exit fi ( while true; do xscreensaver-command -deactivate &>/dev/null; sleep 30; done ) & pid="$!" eval "$@" kill "$pid" |