裝了ubuntu 10.04 發現xset dpms force off有一點問題,
xset dpms force off可以關閉屏幕但是一會儿屏幕就會亮了,
查一下資料說是跟gnome-power-manger有頭,所以在xset dpms force off前
用killall gnome-power-manger就可以了。
如果一定要使用gnome-power-manger可參考下面的文章(關閉屏幕要使用一個快捷鍵,啟用屏幕也用一個快捷鍵)
Back in the pre-Karmic days (or, the good ole’ days, as I call them) you could turn your laptop screen off by issuing this simple command:
I had a nice script set up and mapped to a keyboard shortcut to turn my screen off whenever I wanted (say if I was using my laptop to play music and wanted to save some battery life). In Karmic, however, a regression causes this command to turn your screen off only briefly. After a few seconds, your screen will turn back on, on its own. This might be an Intel-specific problem—I have the misfortune of having an Intel video card on my Ubuntu install—but I’m not sure.
To get around this problem, I created a slightly different (and slightly less ideal) script that turns the screen off when a shortcut key is pressed, and then turns it back on after they same key is pressed again. Here’s how to get it for your own laptop:
if [ -f $screenOffLockFile ] ;
then
rm $screenOffLockFile
else
touch $screenOffLockFile
sleep .5
while [ -f $screenOffLockFile ]
do
xset dpms force off
sleep 2
done
xset dpms force on
fi
(An explanation follows). Press ctrl+x to quit Nano, then y to save your script.
And that’s it. Press your shortcut key to turn your screen off, and press the shortcut key again to turn it back on.
When you first press the shortcut key with your screen on, the script will check if there’s a certain file in your /tmp/ directory. If it doesn’t find it, it will create it and then enter an infinite loop that turns your screen off every 2 seconds if the special file still exists (thus working around Karmic’s regression). When you press the shortcut key with your screen already off, it will delete the file and do nothing else, causing the first instance of the script to exit its infinite loop (since it no longer sees the special file) and turn your screen back on again.
It’s as simple as that. It’s not as ideal as the pre-Karmic solution, but it’ll have to do until Canonical QA gets their act together.