Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a keyboard with a "sleep" button that does indeed make my computer go to sleep. The problem is that Ubuntu can't really handle sleep on my computer, causing it go into a non-responsive mode, having the CPU fan spinning at full speed and it stops receiving any input.

Hibernation instead works mainly as it should. I would like to set the sleep key to hibernate, but the keyboard settings' hotkeys tab doesn't have this "sleep" keybinding and though I could make new one with hibernate --force as the command, it would require root rights to run.

How can I change the keyboard sleep button action to hibernate?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

If you have administrator privileges on your machine, you could try prepending gksudo to the front of your command, like so:

gksudo -S hibernate --force

Then when you press the key, you will be presented with a password entry popup, and hibernation should occur if you enter it correctly.

If you want this command to look nicer and be more self-descriptive when run, you can alternatively use the following:

gksudo -S -m "Enter your administrator password to hibernate." hibernate --force

(You can change the message between the quotation marks with anything you like.)

share|improve this answer
    
But i was wondering also where its defined that this sleep button suspends the computer :S –  Allu2 Nov 17 '11 at 18:26
    
@Allu2 I wouldn't know about that, but nonetheless my provided commands could be bound to that key and should provide the same functionality. –  WarriorIng64 Nov 17 '11 at 18:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.