玩flightgear的时候是用的摇杆,但是屏保是不理会摇杆的动作的,所以经常飞一半就屏保了,然后还得晃晃鼠标,甚至有一次屏保以后X挂了,于是我毫无悬念的坠毁了。郁闷。所以在flightgear启动的时候禁用屏保。
网上找的脚本,在这里:https://raw.github.com/unhammer/lightsOn/68066bdaf645abd7f1b8e95fc7ae20b6d11d63fd/lightsOn.sh
其中和屏保有关的是这一段:
# reset inactivity time counter so screensaver is not started
if [ "$screensaver" == "kscreensaver" ]; then
qdbus org.freedesktop.ScreenSaver /ScreenSaver SimulateUserActivity > /dev/null
else
xscreensaver-command -deactivate > /dev/null
fi
#Check if DPMS is on. If it is, deactivate and reactivate again. If it is not, do nothing.
dpmsStatus=`xset -q | grep -ce 'DPMS is Enabled'`
if [ $dpmsStatus == 1 ];then
xset -dpms
xset dpms
fi
也就是说xscreensaver的话是可以关闭的,而kde的kscreensaver则是要每隔一段时间模拟一个动作,让屏保以为鼠标动了一下。所以把flightgear的启动脚本改成:
#!/bin/bash
fgfs --fg-root=/usr/share/flightgear/data --show-aircraft | less
/home/xjpvictor/scripts/fgfs-disablescreensaver &
echo -e "\nSelect aircraft.."
read a
if [ $a ];then
optirun fgfs --enable-fullscreen --fg-root=/usr/share/flightgear/data --fg-scenery=/home/xjpvictor/.fgfs/scenery:/home/xjpvictor/.fgfs/terrasync-scenery:/usr/share/flightgear/data/Scenery --disable-auto-coordination --prop:/sim/rendering/multi-sample-buffers=true --prop:/sim/rendering/multi-samples=4 --prop:/sim/rendering/multithreading-mode=CullThreadPerCameraDrawThreadPerContext --airport=ZSCN --aircraft=$a
else
optirun fgfs --enable-fullscreen --fg-root=/usr/share/flightgear/data --fg-scenery=/home/xjpvictor/.fgfs/scenery:/home/xjpvictor/.fgfs/terrasync-scenery:/usr/share/flightgear/data/Scenery --disable-auto-coordination --prop:/sim/rendering/multi-sample-buffers=true --prop:/sim/rendering/multi-samples=4 --prop:/sim/rendering/multithreading-mode=CullThreadPerCameraDrawThreadPerContext --airport=ZSCN
fi
killall fgfs-disablescreensaver
另外新建一个脚本,/home/xjpvictor/scripts/fgfs-disablescreensaver
#!/bin/bash
while [ 1 ];do
qdbus org.freedesktop.ScreenSaver /ScreenSaver SimulateUserActivity > /dev/null
xset -dpms
xset dpms
sleep 120
done
试验了一下,效果不错,可以安心的飞不会出现屏保了。当然缺点是如果要飞overnight的话,屏幕会一直亮着,可以增加一个选项什么的,但我还在练五边,暂时不需要了。