Page 2 of 7 FirstFirst 1234 ... LastLast
Results 11 to 20 of 67

Thread: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line

  1. #11
    Join Date
    Jan 2006
    Location
    Waterloo, ON, Canada
    Beans
    210
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line

    Quote Originally Posted by akin1231 View Post
    That's a negative. None of these actions work for me. The button on the GUI for supend works really well but I need to run a script before any suspend action is invoked.

    I just need to figure out what that Suspend button does. How would I figure this out? Many thanks!
    Also if it's different, I need to run the same script if suspend is due to idle time
    How do they behave? -- Could you please provide some command & response "quotes"?
    ~Fermmy

  2. #12
    Join Date
    Feb 2008
    Beans
    722

    Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line

    I'm trying to create a keyboard shortcut but it doesn't work.

    /usr/sbin/pm-suspend
    returns "This utility may only be run by the root user." !!!

    The built-in Suspend in Keyboard Shortcuts doesn't work either.


    pmi action suspend
    returns"The program 'pmi' is currently not installed. You can install it by typing:
    sudo apt-get install powermanagement-interface"



    Pressing Ctrl+Alt+Delete brings up the Shutdown Dialog but it doesn't have focus or is behind the current window


    Some fixing is needed here....
    Last edited by Rebelli0us; November 7th, 2009 at 06:21 PM.

  3. #13
    Join Date
    Jan 2006
    Location
    Waterloo, ON, Canada
    Beans
    210
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line

    Well, do
    Code:
    sudo apt-get install pmi
    Then you can use
    Code:
    sudo pmi action suspend
    As far as being able to bind that to a keyboard shortcut ... I believe it's expected that your keyboard shortcut couldn't auto suspend because it requires root access. The workaround would be to bind it to "gksu pmi action suspend" possibly, but you'll still have to type your root password.

    I'm not sure how, but I'm guessing the right course of action would be to figure out how the "suspend" button works in gnome-gui ... maybe tie into that somehow and invoke the command that it invokes...?
    ~Fermmy

  4. #14
    Join Date
    Mar 2006
    Location
    Stockholm, Sweden
    Beans
    694
    Distro
    Ubuntu Development Release

    Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line

    In Karmic:

    Code:
    sudo apt-get install powermanagement-interface
    Then run:

    Code:
    sudo visudo
    And add this line, using your own username:

    Code:
    yourusername ALL=NOPASSWD: /usr/sbin/pmi
    Save (Ctrl + X).

    Now you should not have to enter a password for this command.

  5. #15
    Join Date
    Feb 2008
    Beans
    722

    Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line

    The "Suspend" command in Keyboard Shortcuts doesn't work. Why?

    Also, why should a user have to type a password to suspend computer? That's bizarre.. machine is set to auto-suspend anyway..

  6. #16
    Join Date
    Mar 2005
    Beans
    Hidden!

    Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line


    ** SOLUTION NOT REQUIRING ROOT/SUDO **


    Introducing... gnome-power-control
    No sudo, no root, no fuss!

    I found the solutions in this thread and elsewhere inadequate, because they just bypassed the problem by using sudo. I have solved this problem by writing a simple script.

    THE SCRIPT
    Code:
    #!/bin/bash
    #
    # gnome-power-control
    # Author: AgenT
    
    case $1 in
    suspend)
    echo Suspending
        dbus-send --print-reply \
            --system \
            --dest=org.freedesktop.DeviceKit.Power \
            /org/freedesktop/DeviceKit/Power \
            org.freedesktop.DeviceKit.Power.Suspend
    ;;
    hibernate)
    echo Hibernating
        dbus-send --print-reply \
            --system \
            --dest=org.freedesktop.DeviceKit.Power \
            /org/freedesktop/DeviceKit/Power \
            org.freedesktop.DeviceKit.Power.Hibernate
    ;;
    *)
    echo Not supported command: '"'$1'"'
    echo Usage: $0 '<suspend|hibernate>'
    exit 1
    ;;
    esac
    SETUP
    1) Save the above as: gnome-power-control

    2) Change file permissions to execute (right click on file -> properties -> permissions)

    3) optional: move this script into your ~/bin/ folder for easy access!

    USAGE
    To suspend: gnome-power-control suspend
    To hibernate: gnome-power-control suspend

    BINDINGS
    Once in your ~/bin/ folder, you can bind other programs to use this! For example, create a Compiz shortcut to execute gnome-power-control suspend, or create a launcher on your toolbar to do the same thing!

    DOES NOT WORK?
    If this does not work for you, you either don't have DeviceKit (in Ubuntu 9.10) or if you do, then your suspend/hibernate is not working correctly.
    STOP!
    Before you sign up to Dropbox, click here to read my post showing you how to get an additional 500mb free! That's 2.5GB of free space!

  7. #17
    Join Date
    Feb 2008
    Beans
    722

    Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line

    Quote Originally Posted by AgenT View Post

    ** SOLUTION NOT REQUIRING ROOT/SUDO **


    Introducing... gnome-power-control
    No sudo, no root, no fuss!

    I found the solutions in this thread and elsewhere inadequate, because they just bypassed the problem by using sudo. I have solved this problem by writing a simple script.

    THE SCRIPT
    Code:
    #!/bin/bash
    #
    # gnome-power-control
    # Author: AgenT
    
    case $1 in
    suspend)
    echo Suspending
        dbus-send --print-reply \
            --system \
            --dest=org.freedesktop.DeviceKit.Power \
            /org/freedesktop/DeviceKit/Power \
            org.freedesktop.DeviceKit.Power.Suspend
    ;;
    hibernate)
    echo Hibernating
        dbus-send --print-reply \
            --system \
            --dest=org.freedesktop.DeviceKit.Power \
            /org/freedesktop/DeviceKit/Power \
            org.freedesktop.DeviceKit.Power.Hibernate
    ;;
    *)
    echo Not supported command: '"'$1'"'
    echo Usage: $0 '<suspend|hibernate>'
    exit 1
    ;;
    esac
    SETUP
    1) Save the above as: gnome-power-control

    2) Change file permissions to execute (right click on file -> properties -> permissions)

    3) optional: move this script into your ~/bin/ folder for easy access!

    USAGE
    To suspend: gnome-power-control suspend
    To hibernate: gnome-power-control suspend

    BINDINGS
    Once in your ~/bin/ folder, you can bind other programs to use this! For example, create a Compiz shortcut to execute gnome-power-control suspend, or create a launcher on your toolbar to do the same thing!

    DOES NOT WORK?
    If this does not work for you, you either don't have DeviceKit (in Ubuntu 9.10) or if you do, then your suspend/hibernate is not working correctly.
    Thank you.

    Is there a straightforward way to directly create a new file in /bin folder? .. like in windows right click > new.

    So I created new file as you described, in Desktop, then tried to drag it to /bin folder... "access denied", it's sickening.... I thought it was MY computer.

    So, how do I invoke command "gnome-power-control suspend" and assign it to a Keyboard shortcut?

  8. #18
    Join Date
    Mar 2005
    Beans
    Hidden!

    Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line

    Quote Originally Posted by Rebelli0us View Post
    Thank you.

    Is there a straightforward way to directly create a new file in /bin folder? .. like in windows right click > new.

    So I created new file as you described, in Desktop, then tried to drag it to /bin folder... "access denied", it's sickening.... I thought it was MY computer.

    So, how do I invoke command "gnome-power-control suspend" and assign it to a Keyboard shortcut?
    Not into /bin/ but into ~/bin/ which is short for /home/YOUR_USERNAME/bin/
    ~ is short for your home directory.

    And it's not sickening that you cannot add into /bin on Linux. It's one of the reasons why there are no viruses, etc. in Linux, but there are a TON on windows. It's called common sense security. Yes it's your computer, and yes, if you want to, you can add a file into /bin but only as root user. Again, common security, which Windows has always lacked.

    If you want more information, I suggest reading up on the linux permission system.
    STOP!
    Before you sign up to Dropbox, click here to read my post showing you how to get an additional 500mb free! That's 2.5GB of free space!

  9. #19
    Join Date
    Feb 2008
    Beans
    722

    Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line

    Quote Originally Posted by AgenT View Post
    Not into /bin/ but into ~/bin/ which is short for /home/YOUR_USERNAME/bin/
    ~ is short for your home directory.

    And it's not sickening that you cannot add into /bin on Linux. It's one of the reasons why there are no viruses, etc. in Linux, but there are a TON on windows. It's called common sense security. Yes it's your computer, and yes, if you want to, you can add a file into /bin but only as root user. Again, common security, which Windows has always lacked.

    If you want more information, I suggest reading up on the linux permission system.
    Thanks again, I meant sickening in the sense that somebody with my experience cannot do simple things in Linux, even with your kind help. And "access denied" offers no help.

    So I'm browsing, there is no BIN dir in /home/YOUR_USERNAME/ ??

    I did a search, there's a dozen BIN dirs, I thought BIN is like windows\system32

    I also tried executing "gnome-power-control" from where it is (desktop) but nothing happens. I did the "permissions" "allow execute". I just assume this is like a batch file, and once it works I can assign it a keyboard shortcut??

    Help! Why is something simple so hard????

  10. #20
    Join Date
    Jan 2008
    Location
    Manchester UK
    Beans
    13,636
    Distro
    Ubuntu

    Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line

    Just make one. Although it`s not there by default, it`s in your path by default, even if it`s not there.

    Or it always used to be, using Hardy so things might have changed.

    Edit -

    Rereading that, it doesn`t sound very clear unless you understand paths. If a directory is in your path then you can execute any binary in that directory typing the name of the program.

    To see what I mean, try typing
    Code:
    ls /usr/bin/
    One of the first programs you`ll see is the very commonly used apt-get. I`m guessing you type
    Code:
     sudo apt-get install blah blah blah
    all the time.

    If /usr/bin was not in your path you would have to type
    Code:
    sudo /usr/bin/apt-get install blah blah blah
    because bash would not search /usr/bin to find it.

    Other distros include ~/bin as a default directory, Ubuntu does not, but it does include ~/bin in your default path. So you can create ~/bin and bash will search it

    To see which directories are in your path type
    Code:
    echo $PATH
    Edit 2 -

    I`m not sure that made it clearer, anyway, research your path if your interested
    Last edited by nothingspecial; November 15th, 2009 at 07:31 PM.

Page 2 of 7 FirstFirst 1234 ... LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •