-
-
Save copyninja/1593478 to your computer and use it in GitHub Desktop.
Suspend, hibernate, restart or shutdown the computer without sudo!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Suspend, hibernate, restart or shutdown the computer without sudo! | |
# by Chris Wong | |
# Released to the public domain. | |
NAME=$0 | |
usage() { | |
echo "Usage: $NAME suspend|hibernate|restart|shutdown" | |
exit 42 # :D | |
} | |
if [ $# -ne 1 ] ; then | |
usage | |
else | |
THINGY_UPOWER="dbus-send --system --print-reply --dest=org.freedesktop.UPower /org/freedesktop/UPower" | |
THINGY_CONSOLEKIT="dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager" | |
case $1 in | |
suspend) | |
$THINGY_UPOWER org.freedesktop.UPower.Suspend | |
;; | |
hibernate) | |
$THINGY_UPOWER org.freedesktop.UPower.Hibernate | |
;; | |
restart) | |
$THINGY_CONSOLEKIT org.freedesktop.ConsoleKit.Manager.Restart | |
;; | |
shutdown) | |
$THINGY_CONSOLEKIT org.freedesktop.ConsoleKit.Manager.Stop | |
;; | |
*) | |
usage | |
;; | |
esac | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment