Skip to content

Instantly share code, notes, and snippets.

@Gen2ly
Created May 31, 2012 14:08
Show Gist options
  • Save Gen2ly/2843630 to your computer and use it in GitHub Desktop.
Save Gen2ly/2843630 to your computer and use it in GitHub Desktop.
Power management as a regular user
#!/bin/bash
# Power management as a regular user
case $1 in
shutdown | S )
echo " Shutting Down..."
dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" \
/org/freedesktop/ConsoleKit/Manager \
org.freedesktop.ConsoleKit.Manager.Stop > /dev/null ;;
restart | R )
echo " Restarting System..."
dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" \
/org/freedesktop/ConsoleKit/Manager \
org.freedesktop.ConsoleKit.Manager.Restart > /dev/null ;;
suspend | s )
echo " Suspending to RAM..."
dbus-send --system --print-reply --dest="org.freedesktop.UPower" \
/org/freedesktop/UPower org.freedesktop.UPower.Suspend > /dev/null ;;
hibernate | h )
echo " Suspending to Disk..."
dbus-send --system --print-reply --dest="org.freedesktop.UPower" \
/org/freedesktop/UPower org.freedesktop.UPower.Hibernate > /dev/null ;;
blankmon | b )
echo " Sleeping Monitor..."
sleep 1 && xset s activate ;;
* )
echo " ${0##*/} <shutdown(S)|restart(R)|suspend(s)|hibernate(h)|blank(b)>"
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment