28

For some reason Ubuntu had not been having good support for suspend. Creating the /etc/polkit-1/localauthority/50-local.d/com.ubuntu.disable-suspend.pkla file with the below disabled suspend option in the main menu in 12.04. But, the same doesn't work after moving from 12.04 to 14.04.

[Disable suspend by default]
Identity=unix-user:*
Action=org.freedesktop.upower.suspend
ResultActive=no

How to disable suspend in 14.04?

4

3 Answers 3

30

Create a new file called /etc/polkit-1/localauthority/50-local.d/com.ubuntu.disable-suspend.pkla with the following contents:

[Disable suspend (upower)]
Identity=unix-user:*
Action=org.freedesktop.upower.suspend
ResultActive=no
ResultInactive=no
ResultAny=no

[Disable suspend (logind)]
Identity=unix-user:*
Action=org.freedesktop.login1.suspend
ResultActive=no
ResultInactive=no
ResultAny=no

[Disable suspend when others are logged in (logind)]
Identity=unix-user:*
Action=org.freedesktop.login1.suspend-multiple-sessions
ResultActive=no
ResultInactive=no
ResultAny=no

and then reboot.

This tells PolicyKit to automatically say "no" whenever anything asks if it's OK/possible to suspend. Logout menus will react to this by automatically removing the 'Suspend' menu choice.

I don't quite understand why, but the upower setting is needed for KDE but does not affect Unity. The login1 settings are needed for Unity but do not affect KDE.

2
  • 2
    Awesome :) Still works for 18.04, Bionic Beaver!
    – M K
    May 8, 2018 at 19:34
  • This also seems to work in 21.10. Thanks. Dec 27, 2021 at 23:40
9

For me it is important to just disable the "automatic Suspend"
Because I still want to be able to do the "manual Suspend"
in /etc/polkit-1/localauthority/50-local.d/com.ubuntu.disable-suspend.pkla

So, I used:

[Disable suspend (upower)]
Identity=unix-user:*
Action=org.freedesktop.upower.suspend
ResultActive=no
ResultInactive=no
ResultAny=no

[Disable suspend (logind)]
Identity=unix-user:*
Action=org.freedesktop.login1.suspend
ResultActive=yes
ResultInactive=no
ResultAny=yes

[Disable suspend when others are logged in (logind)]
Identity=unix-user:*
Action=org.freedesktop.login1.suspend-multiple-sessions
ResultActive=yes
ResultInactive=no
ResultAny=yes

Now I can click "Suspend" in the logoff menu. But the PC keeps running unless I send it to "Suspend".

1
  • I'm afraid this doesn't work anymore in 16.04: My laptop still goes to sleep after about 5 idle minutes.
    – MERose
    Jan 11, 2017 at 16:00
1

You can't. This is a bug in polkit in 14.04. As a workaround, you can

chmod 000 /usr/lib/pm-utils/bin/pm-action

It would help if you vote up the above-mentioned launchpad bug.

2
  • Changed the permissions as mentioned and Suspend was still enabled. ---------- 1 root root 2903 Nov 6 16:26 pm-action Apr 25, 2014 at 7:23
  • 1
    It's still in the menu - only polkit can change that - but choosing it should have no effect now, because pm-action will fail to run.
    – Daniel
    Apr 26, 2014 at 14:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .