Is it possible to configure Ubuntu so that the power button causes suspend regardless of whether the session is locked or not?

See here, for example. That configuration does not work, however, if the session is locked.

Note that my question is essentially the same as this one, but the given answer doesn't fully answer the question.

  • please don't post duplicate questions, offer a bounty instead on the existing post, if you think the accepted answer does not properly address the question asked. another alternative is to comment on the answer to ask the poster to revise his/her answer. – Eliran Malka Oct 21 '12 at 23:25
  • try and force it by gsettings set org.gnome.settings-daemon.plugins.power button-power 'suspend'. – Eliran Malka Oct 21 '12 at 23:46
  • check out this related post, it might be helpful. – Eliran Malka Oct 22 '12 at 0:30
  • @Eliran: Indeed, I already linked to the post you mention. It does not work when the session is locked. Your comment regarding duplicates is still valid, though. I have offered a bounty for the original question. I invite others to improve the answer! – Adam Paetznick Oct 22 '12 at 19:31
  • great, by the way, have you tried deciphering the content of /etc/acpi/powerbtn.sh? it seems like it all comes down to the logic in that file. good luck anyhow. – Eliran Malka Oct 22 '12 at 20:07

Maybe not the cleanest solution, but works for me. To resolve the issue I added following at the beginning of file /etc/acpi/powerbtn.sh:

exit 0
  • This worked, but when I resume after suspend, the system immediately suspends again. This only happens once for each time I push the button, though, so it's still useful. – GordonM Jun 15 '16 at 5:47
  • Looks like the script is executed twice. Maybe there should be created lock file in the script to prevent executing it twice (if lock file exist script would simply exit). Then the lock file should be removed somehow after wake up. – Paweł Nadolski Jun 15 '16 at 9:57

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.