Chapter 11. Changing system power settings
You can configure the power settings of your system to manage energy consumption and optimize performance. Changing the system power settings enables you to balance between energy conservation and performance.
11.1. Changing the power button behavior Copy linkLink copied to clipboard!
To customize the action of the power button, you can change its default behavior both when GNOME is running and when it is not running.
11.1.1. Changing the behavior of the power button when GNOME is not running Copy linkLink copied to clipboard!
To prevent the system from shutting down when you press the power button, you need to modify settings for the non-graphical systemd target. Select the option according to requirement.
Prerequisites
- You have administrative privileges.
Procedure
-
Edit the
/etc/systemd/logind.confconfiguration file to set theHandlePowerKeyvariable. To reboot the system when you press the power button, set the
rebootvalue:HandlePowerKey=rebootUse one of the following options:
-
poweroff: Shut down the computer. -
reboot: Reboot the system. -
halt: Initiate a system halt. -
kexec: Initiate akexecreboot. -
suspend: Suspend the system. -
hibernate: Initiate system hibernation. -
ignore: Do nothing.
-
Restart the
systemd-logindservice to apply the changes:# systemctl reload systemd-logind
11.1.2. Changing the behavior of the power button in GNOME Copy linkLink copied to clipboard!
To prevent the system from suspending when you press the power button, modify settings for the GNOME login screen and user session. You can select one of the options: physically on a system or virtually from a remote console.
Prerequisites
- You have administrative privileges.
Procedure
Create a local database for system-wide settings in the
/etc/dconf/db/local.d/01-powerfile:[org/gnome/settings-daemon/plugins/power] power-button-action=<value>Replace
<value>with one of the following power button actions:-
nothing: Does nothing. -
suspend: Suspends the system. -
hibernate: Hibernates the system. interactive: Shows a pop-up query asking the user what to do.In the interactive mode, when you press the power button, the system automatically powers off after 60 seconds. You can select a different behavior from the pop-up query.
-
Optional: To override existing settings and prevent other users from changing it, edit configuration in the
/etc/dconf/db/local.d/locks/01-powerfile:/org/gnome/settings-daemon/plugins/power/power-button-actionUpdate the system databases:
# dconf update- Log out and log in again for the system-wide settings to take effect.
Verification
- Press the power button and check if the system performs the action you configured.
11.2. Changing how your system behaves when you close the laptop lid Copy linkLink copied to clipboard!
When you close the lid of your laptop, it suspends by default to save battery. You can customize this behavior according to your preferences.
Some laptops can overheat if they are left running with the lid closed, especially in confined spaces. Consider whether changing this setting is safe for your laptop, especially if you intend to keep the laptop running with the lid closed for extended periods of time.
Prerequisites
- Administrative access
Procedure
-
Open the
/etc/systemd/logind.confconfiguration file. -
Look for the line that says
HandleLidSwitch=suspend. -
If the line starts with the
#symbol, remove it to enable the setting. Replace
suspendwith one of the following options:-
poweroffto shut down the computer. -
lockto lock the screen. -
ignoreto do nothing.
For example, to lock the screen upon closing the lid, use this setting:
HandleLidSwitch=lock-
- Save your changes and close the editor.