Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line
Quote:
Originally Posted by
akin1231
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"?
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....
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...?
Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line
In Karmic:
Code:
sudo apt-get install powermanagement-interface
Then run:
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.
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..
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.
Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line
Quote:
Originally Posted by
AgenT
** 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?
Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line
Quote:
Originally Posted by
Rebelli0us
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.
Re: [SOLVED] HowTo sleep / standby / hibernate / suspend from command line
Quote:
Originally Posted by
AgenT
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????
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 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