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?


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.)

  • 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. – Christopher Kyle Horton Nov 17 '11 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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