Fedora8实现定时休眠到内存-suspend to ram


在Windows下面有一个软件叫做eyeauard-眼睛卫士,可以设定每过一定时间自动锁定你的笔记本,强迫让你休息,对于整天伏案工作的人真的是必备工具。

现在切换到Fedora平台后,一直希望找到这样的工具,现在好像还没有,偶尔想到可以通过电源管理中的休眠,配合定时任务,让笔记本定时休眠就可以了,防止很多时候,一工作起来就忘记时间了。

我的OS:Fedora8

安装gnome-power-manager就可以了,一般默认都有的

vim /etc/crontab

添加如下:

0 8-18 * * * root /usr/bin/gnome-power-cmd.sh suspend

NOTE: 以上是休眠到内存,就是说很多东西存到内存,这样启动快。因为是存到内存,所以必须要有电源供应。笔记本有电池就可以了。

刚开始的时候,不知道那个命令可以实现休眠,因为都是点鼠标嘛。后来找到了上面的.sh文件,查看了一下内容,是个比较简单的脚本,就是写个函数,收到不同变量就执行不同的休眠方式或者reboot。

脚本内容如下:

CODE:#$1 = method name
execute_dbus_method ()
{
dbus-send --session --dest=org.freedesktop.PowerManagement \
--type=method_call --print-reply --reply-timeout=2000 \
/org/freedesktop/PowerManagement \
org.freedesktop.PowerManagement.$1
if [ $? -eq 0 ]; then
echo "Failed"
fi
}

if [ "$1" == "suspend" ]; then
echo "Suspending"
execute_dbus_method "Suspend"
elif [ "$1" == "hibernate" ]; then
echo "Hibernating"
execute_dbus_method "Hibernate"
elif [ "$1" == "reboot" ]; then
echo "Rebooting"
execute_dbus_method "Reboot"
elif [ "$1" == "shutdown" ]; then
echo "Shutting down"
execute_dbus_method "Shutdown"
elif [ "$1" == "" ]; then
echo "command required: suspend, shutdown, hibernate or reboot"
else
echo "command '$1' not recognised, only suspend, shutdown, hibernate or reboot are valid"
exit 1
fi


出自:雨中的文森特

相关内容