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次圍觀