Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line
Quote:
Originally Posted by
nothingspecial
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
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
Edit 2 -
I`m not sure that made it clearer, anyway, research your path if your interested
Thank you. If path works the same as in windows then I do understand it, that’s why I tried to drag the “batch” file into the BIN directory. But as I’ve mentioned, batch isn’t not running! Thanks for explaining anyway for the benefit of other new users, who I’m sure are googling on how to make Suspend work.
My original question above was about the "Suspend" command in Keyboard Shortcuts NOT working. It only blanks the screen momentarily. So I thought of finding the suspend command and assign a keyb shortcut to it. But as you’re witnessing that’s not working either.
//
Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line
I know this thread is [solved] but I thought I could add some clarifications. I had the same problem/question about creating suspend and hibernate keyboard shortcuts.
The script works (thanks, AgenT!). The only thing is that ~/bin is not in your paths by default on ubuntu 9.10, so you can either create the script in one of your paths (you can find them with the command "echo $PATH" as AgenT mentionned) like /usr/bin. To do that, you'll need administrator rights so in a terminal type:
Code:
sudo gedit /usr/bin/gnome-power-control
Then you copy-paste the script and save.
Then you still need the admin rights to add the execute permession so in a terminal type:
Code:
sudo chmod a+x /usr/bin/gnome-power-control
Then the commands "gnome-power-control suspend" and "gnome-power-control hibernate" work, you can create keyboard shortcuts with them.
An other way would be to create the file in any directory and point there with you command. For instance, if you create it on your desktop the command will be "/home/YOURUSERNAME/Desktop/gnome-power-control suspend"
Cheers!
Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line
Quote:
Originally Posted by
victorfb
The only thing is that ~/bin is not in your paths by default on ubuntu 9.10,
I hate the way they keep changing things :D
Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line
Thank you, it's working now... almost
For now, I'm running it from the desktop by calling the full path. It turns out the $PATH command is CASE SENSITIVE ... %@!^&* and the delimiter is : instead of ; ..lol
/usr/bin IS in path but ONLY some guy named "root" is allowed to do it, ... I figured out how to login as root, how do I make that the default in the login screen?
Under keyboard shortcuts, can I just put the line from the script?
dbus-send --print-reply \
--system \
--dest=org.freedesktop.DeviceKit.Power \
/org/freedesktop/DeviceKit/Power \
org.freedesktop.DeviceKit.Power.Suspend
All in one line, I assume the \ is a line break?
Last question and most important: When I suspend this way there's NO prompt for password when I wake the machine. Whereas when I suspend from the Shutdown dialog or the Sleep key I get the normal pw login. How does one enable the password prompt for this command?
//
Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line
Ok I tried it. If you just want a Suspend command, you don't need to call the batch file or script. Just create a new Keyboard Shortcut with this command in one line:
dbus-send --print-reply --system --dest=org.freedesktop.DeviceKit.Power /org/freedesktop/DeviceKit/Power org.freedesktop.DeviceKit.Power.Suspend
As I mentioned above, with this method, there is still NO prompt for password on Resume, that needs fixing.
The reason I'm here, is because the built-in “Suspend” command doesn't work, so that needs fixing too.
Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line
Is this really solved??
I have pmi installed, but pmi action suspend does nothing. (none of the pmi commands do.) The "sudo /etc/acpi/sleep.sh sleep" does.
However, it is well and good for me to force the computer to sleep, but how can I get it to do it on its own? After 30 minutes of doing nothing, the way my Windows XP does?
I want my ubuntu server to sleep during the night (after some idle time) and then wakeup-on-lan when I try to use it over the internet (send a WOL packet first).
Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line
Quote:
Originally Posted by
grandsatrap
Is this really solved??
I have pmi installed, but pmi action suspend does nothing. (none of the pmi commands do.) The "sudo /etc/acpi/sleep.sh sleep" does.
However, it is well and good for me to force the computer to sleep, but how can I get it to do it on its own? After 30 minutes of doing nothing, the way my Windows XP does?
I want my ubuntu server to sleep during the night (after some idle time) and then wakeup-on-lan when I try to use it over the internet (send a WOL packet first).
Auto-suspend works on my machine, screen timeout also... it's in the POwer options.
Have you tried the Suspend command on my last post above?
In windows I can wake up machines on my home network via magic packet, and also suspend them with utility from Sysinternals, but I haven't tried it in Linux cos LAN configuration seems more technical.
Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line
Quote:
Originally Posted by
aoakley
There are several threads which unsuccessfully seek a command line method to hibernate or suspend in Ubuntu, WITHOUT requiring root or sudo access. After a bit of digging, I've come up with the answer.
This is tested on Ubuntu 8.04 (Hardy) with a Dell Inspiron 1520 laptop. I would appreciate feedback from users of other systems.
To suspend-to-RAM (aka sleep):
To suspend-to-disk (aka hibernate):
Code:
pmi action hibernate
If you want to lock the Gnome session first (ie. require a password on resumption), then issue the following command before pmi:
Code:
gnome-screensaver-command --lock
For example, you can use these commands to create a button (launcher) on a Gnome panel (taskbar) that instantly locks the screen and goes into sleep mode:
Right-click panel, Add to panel, Custom application launcher, Add, Name: Sleep , Command: gnome-screensaver-command --lock ; pmi action suspend
Wonderful,thank you so much for your help
Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line
These commands have worked the most reliably for me:
Code:
sudo s2ram
sudo s2disk
sudo s2both
Which are suspend-to-RAM (standby/suspend), suspend-to-disk (hibernate), and "hybrid", like the hybrid sleep feature of win7.
Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line
Quote:
Originally Posted by
aoakley
There are several threads which unsuccessfully seek a command line method to hibernate or suspend in Ubuntu, WITHOUT requiring root or sudo access. After a bit of digging, I've come up with the answer.
This is tested on Ubuntu 8.04 (Hardy) with a Dell Inspiron 1520 laptop. I would appreciate feedback from users of other systems.
To suspend-to-RAM (aka sleep):
To suspend-to-disk (aka hibernate):
Code:
pmi action hibernate
If you want to lock the Gnome session first (ie. require a password on resumption), then issue the following command before pmi:
Code:
gnome-screensaver-command --lock
For example, you can use these commands to create a button (launcher) on a Gnome panel (taskbar) that instantly locks the screen and goes into sleep mode:
Right-click panel, Add to panel, Custom application launcher, Add, Name: Sleep , Command: gnome-screensaver-command --lock ; pmi action suspend
Great! I have been looking for this. Works on my gigabyte 912 tablet pc.