Advertisement
szabozoltan69

power.sh

Apr 28th, 2014
240
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. # Suspend, hibernate, restart or shutdown the computer without sudo!
  4. # by Chris Wong
  5. # Released to the public domain.
  6.  
  7. NAME=$0
  8.  
  9. usage() {
  10. echo "Usage: $NAME suspend|hibernate|restart|shutdown"
  11. exit 42 # :D
  12. }
  13.  
  14. if [ $# -ne 1 ] ; then
  15. usage
  16. else
  17. THINGY_UPOWER="dbus-send --system --print-reply --dest=org.freedesktop.UPower /org/freedesktop/UPower"
  18. THINGY_CONSOLEKIT="dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager"
  19. case $1 in
  20. suspend)
  21. $THINGY_UPOWER org.freedesktop.UPower.Suspend
  22. ;;
  23. hibernate)
  24. $THINGY_UPOWER org.freedesktop.UPower.Hibernate
  25. ;;
  26. restart)
  27. $THINGY_CONSOLEKIT org.freedesktop.ConsoleKit.Manager.Restart
  28. ;;
  29. shutdown)
  30. $THINGY_CONSOLEKIT org.freedesktop.ConsoleKit.Manager.Stop
  31. ;;
  32. *)
  33. usage
  34. ;;
  35. esac
  36. fi
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement