home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / bin / gnome-power-cmd.sh < prev    next >
Encoding:
Text File  |  2007-04-13  |  1.4 KB  |  45 lines

  1. # Copyright (C) 2007 Richard Hughes <richard@hughsie.com>
  2. #
  3. # Licensed under the GNU General Public License Version 2
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14.  
  15. #$1 = method name
  16. execute_dbus_method ()
  17. {
  18.     dbus-send --session --dest=org.gnome.PowerManager        \
  19.           --type=method_call --print-reply --reply-timeout=2000    \
  20.           /org/gnome/PowerManager/Control             \
  21.           org.gnome.PowerManager.Control.$1
  22.     if [ $? -eq 0 ]; then
  23.         echo "Failed"
  24.     fi 
  25. }
  26.  
  27. if [ "$1" == "suspend" ]; then
  28.     echo "Suspending"
  29.     execute_dbus_method "Suspend"
  30. elif [ "$1" == "hibernate" ]; then
  31.     echo "Hibernating"
  32.     execute_dbus_method "Hibernate"
  33. elif [ "$1" == "reboot" ]; then
  34.     echo "Rebooting"
  35.     execute_dbus_method "Reboot"
  36. elif [ "$1" == "shutdown" ]; then
  37.     echo "Shutting down"
  38.     execute_dbus_method "Shutdown"
  39. elif [ "$1" == "" ]; then
  40.     echo "command required: suspend, shutdown, hibernate or reboot"
  41. else
  42.     echo "command '$1' not recognised, only suspend, shutdown, hibernate or reboot are valid"
  43.     exit 1
  44. fi
  45.