歡迎您光臨本站 註冊首頁

Fedora8實現定時休眠到內存-suspend to ram

←手機掃碼閱讀     火星人 @ 2014-03-25 , reply:0

在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實現定時休眠到內存-suspend to ram已經有574次圍觀

http://coctec.com/docs/linux/show-post-166087.html