3

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.

Adam Paetznick
  • 2,408
  • 2
  • 16
  • 13
  • 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 00: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

1 Answers1

1

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:

/usr/sbin/pm-suspend
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 05: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 09:57