Configure auto lock, auto screen blanking, and auto sleep settings
In some cases, you might need your computer always to be awake. For example, you might need to download a large file, run a long-running task, or keep your computer awake for a presentation. In this guide, we will show you how to avoid system sleep, keep screen awake, and avoid auto lock.
Default settings
Default settings for AnduinOS:
- Auto dim after inactivity: 15 minutes
- Lock screen right after screen is blanked
- Auto sleep after inactivity: 20 minutes (Battery)
- Auto sleep after inactivity: 30 minutes (AC Power)
- Power button action: Suspend(sleep)
- Closing the lid on an undocked laptop with no external display normally suspends it.
Keep the laptop running when you close the lid
On AnduinOS 2.x, systemd-logind handles the default lid-close action. Dconf Editor may still show the old lid-close-* keys shipped by Ubuntu. GNOME no longer reads them when the lid closes.
Create the directory for local logind settings if needed.
sudo install -d /etc/systemd/logind.conf.d
Open a drop-in file for your lid settings.
sudoedit /etc/systemd/logind.conf.d/90-lid-ignore.conf
Add the following settings to ignore lid-close events on battery, on AC power, and when docked.
[Login]
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
Save the file and reboot. To undo the change, remove the file you created and reboot again. For more about the lid settings, see the systemd-logind configuration reference.
Tune CPU power settings
You can tune the CPU power settings to save power or boost performance. To do this, you can use the cpupower command. The cpupower command is a tool to set and display CPU power settings. You can use the cpupower frequency-info command to display the current CPU power settings. You can use the cpupower frequency-set command to set the CPU power settings.
- Performance: Maximum performance, always boost the CPU frequency to the maximum. (Not recommended)
- Powersave: Dynamic frequency scaling. (Recommended)
sudo apt install -y linux-tools-common linux-tools-$(uname -r)
sudo cpupower frequency-info
sudo cpupower frequency-set -g powersave
Use the powerprofilesctl
powerprofilesctl is a command-line tool to manage power profiles on Linux. It allows you to switch between different power profiles, such as performance, balanced, and power saver.
powerprofilesctl provides three power profiles:
- Performance: Always keep the CPU frequency at the maximum level. (Not recommended)
- Balanced: Quickly boost the frequency when there is a load, using the
energy_performance_preferencesetting. (Recommended) - Power Saver: Use the most conservative
powersavestrategy, only boosting the frequency when absolutely necessary. (Recommended)
powerprofilesctl is available on AnduinOS by default. And can also be switched via the control center and the GNOME settings app.
To list all available power profiles, you can run the following command:
powerprofilesctl list
To get current power profile, you can run the following command:
powerprofilesctl get
To set the power profile to performance, you can run the following command:
powerprofilesctl set performance # Can be performance, balanced, or power-saver
Configure auto lock settings
⚠️ Configure auto lock settings
Avoiding auto lock can cause your computer to be vulnerable to unauthorized access. We recommend using this feature only when necessary. For example, running as kiosk mode.
To configure auto lock settings, you can follow these steps:
- Open the Settings app.
- Click on Privacy.
- Click on Screen.
- Set the Automatic Screen Lock toggle to ON or OFF.
To configure the time before the screen locks, you can set the Automatic Screen Lock Delay to the desired time.
To setup auto lock in the terminal, you can run the following command:
gsettings set org.gnome.desktop.screensaver lock-enabled true
gsettings set org.gnome.desktop.screensaver lock-delay <time-in-seconds-after-screen-blanking>
Avoid screen blanking using the terminal
⚠️ Avoid screen blanking using the terminal
Avoiding screen blanking can cause your computer to consume more power and may damage your screen. (Especially OLED screens) We strongly recommend using this feature only when necessary. For example, running a presentation or watching a movie.
To avoid screen blanking using the terminal, you can run the following command:
gsettings set org.gnome.desktop.session idle-delay 0
This command will prevent the screen from blanking when the computer is inactive.
To revert the changes, you can run the following command:
gsettings set org.gnome.desktop.session idle-delay 300
This command will allow the screen to blank after 5 minutes of inactivity. You can change the value to any number you want.
Avoid system sleep using the terminal
⚠️ Avoid system sleep using the terminal
Avoiding system sleep can cause your computer to consume more power. We recommend using this feature only when necessary. For example, running virtual machines, downloading large files, or hosting a server.
Use these settings to disable automatic suspend when the computer is idle.
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type 'nothing'
To disable sleep system-wide, mask the sleep targets.
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
To revert the changes, you can run the following command:
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'suspend'
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type 'suspend'
sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target
This restores automatic idle suspend and makes the sleep targets available again.
To further diagnose sleep issues, you can refer to the Diagnose Sleep guide.
Configure auto sleep settings
Also, you can set how long the system should wait before going to sleep when the computer is inactive while connected to AC power. To set the time, you can run the following command:
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout <time-in-seconds>
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout <time-in-seconds>
References
| Settings Path | Settings Key | Explanation | Default Value |
|---|---|---|---|
| org.gnome.desktop.session | idle-delay | The time in seconds before the system is considered idle. | uint32 900 |
| org.gnome.settings-daemon.plugins.power | idle-dim | Enables dimming the screen when idle to save power. | true |
| org.gnome.settings-daemon.plugins.power | idle-brightness | The brightness level (percentage) when the screen is dimmed due to inactivity. | 30 |
| org.gnome.settings-daemon.plugins.power | sleep-inactive-ac-timeout | The time in seconds before the system automatically suspends when inactive and on AC power. | 1800 |
| org.gnome.settings-daemon.plugins.power | sleep-inactive-ac-type | The action performed when the system is inactive and on AC power. | 'suspend' |
| org.gnome.settings-daemon.plugins.power | sleep-inactive-battery-timeout | The time in seconds before the system automatically suspends when inactive and on battery power. | 1200 |
| org.gnome.settings-daemon.plugins.power | sleep-inactive-battery-type | The action performed when the system is inactive and on battery power. | 'suspend' |
| org.gnome.settings-daemon.plugins.power | power-button-action | The action performed when the power button is pressed. | 'suspend' |
| org.gnome.settings-daemon.plugins.power | ambient-enabled | Enables the ambient light sensor to automatically adjust the brightness of the display. | true |
| org.gnome.desktop.screensaver | lock-enabled | Enables the auto lock screen feature when the screen is blanked. | true |
| org.gnome.desktop.screensaver | ubuntu-lock-on-suspend | Ubuntu specific setting to lock the screen when the system is suspended. | true |
| org.gnome.desktop.screensaver | lock-delay | Number of seconds after the screen is blank before locking the screen | uint32 0 |
| org.gnome.desktop.screensaver | logout-enabled | Disables automatic logout after a period of inactivity. | false |
To get the value of a setting, you can run the following command:
gsettings get <settings-path> <settings-key>
To set the value of a setting, you can run the following command:
gsettings set <settings-path> <settings-key> <value>
Comments (0)
No comments yet. Be the first to leave one!