阅读内容

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

[日期:2008-05-08] 来源:Linux公社  作者:FedoraRE


在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


出自:雨中的文森特




相关资讯       Fedora8 
本文评论       全部评论
发表评论
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款


点评: 字数
姓名:

L
I
N
U
X


GOOGLE搜索
Google