Advertisement
Ikem

ck-shutdown

Oct 14th, 2012
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.86 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. print_usage(){
  4.  
  5. echo "Usage: ck-shutdown [OPTION]"
  6. echo
  7. echo "Options:"
  8. echo
  9. echo "  -s, --stop                       shutdown computer system"
  10. echo "  -r, --restart                    restart computer system"
  11. echo "  -h, --help                       print this help"
  12. echo
  13. echo "Example:"
  14. echo
  15. echo "ck-shutdown --stop"
  16. }
  17.  
  18. stop(){
  19.  
  20. dbus-send --system --dest=org.freedesktop.ConsoleKit --type=method_call --print-reply --reply-timeout=2000 /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
  21. }
  22.  
  23. restart(){
  24.  
  25. dbus-send --system --dest=org.freedesktop.ConsoleKit --type=method_call --print-reply --reply-timeout=2000 /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
  26. }
  27.  
  28. case $1 in
  29.     -s|--stop)    stop;;
  30.     -r|--restart) restart;;
  31.     -h|--help)    print_usage;;
  32.     *)            print_usage;;
  33. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement