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

王朝other·作者佚名  2008-05-21
窄屏简体版  字體: |||超大  

在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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航