实现Linux待机的命令

liushi 2007-11-13

Linux待机命令有

#xset dpms force standby

#xset dpms force off

脚本:

#!/bin/bash

# default display on current host

DISPLAY=:0.0

# find out if DPMS is enabled

STATUS=`/usr/X11R6/bin/xset -display $DISPLAY -q | grep -e 'DPMS is'`

# enable DPMS if disabled

if [ "$STATUS" == " DPMS is Disabled" ]

then

echo "Enabling DPMS ..." >>/etc/acpi/actions/stay.txt

/usr/X11R6/bin/xset -display $DISPLAY +dpms

fi

# find out if the monitor is on

STATUS=`/usr/X11R6/bin/xset -display $DISPLAY -q | grep 'Monitor'`

if [ "$STATUS" == " Monitor is On" ]

then

echo "[`date`] Turning display OFF" >>/etc/acpi/actions/stay.txt

/usr/X11R6/bin/xset -display $DISPLAY dpms force off

else

echo "[`date`] Turning display ON" >>/etc/acpi/actions/stay.txt

/usr/X11R6/bin/xset -display $DISPLAY dpms force on # turn monitor on

/usr/X11R6/bin/xset -display $DISPLAY s activate # un-blank monitor

fi

exit 0

每次运行把记录写进/etc/acpi/actions/stay.txt 文件里.

相关推荐

年轻就要对味 / 0评论 2015-07-13
夫子与歌 / 0评论 2013-05-11