Trying to keep your laptop awake during presentations in addition to yourself? Need to prevent a Linux machine from sleeping or hibernating for extended periods of time, say for prolonged computations or remote connections? Find out here how to keep a Linux computer (and, optionally, its display) awake and prevent sleeping.
First, Will It Blend?
I have a few beans of Vienna roast here drawn from complex Ethiopian Arabica and a handful of continentally roasted sweet Colombian Robusta (or some such, who knows?). Throwing all puristic ambitions to the wind like finely ground coffee dust: will they blend?
Although some experts will tell you not to try to blend coffees yourself, as it is a fine art and very complicated, I always do it, simply being careful never to offer any to coffee experts.
Ah, how could one tire of Cheryl Mendelson’s beans of wisdom? So, let’s get brewing, keeping our Linux laptops alert and wakeful:
How to Keep a Linux Computer and Display Awake
Gnome (Caffeine)
Time needed: 2 minutes
To keep a Linux machine running Gnome from sleeping and turning off the display:
- Install the Caffeine Gnome shell extension.
Here’s why: The extension will both offer a simple way to keep Linux from sleeping and allow you to automate the job, e.g., for certain applications.
Here’s how: You can use Extension Manager, for instance, to download and install Caffeine. - Click the Gnome quick settings menu to the status bar’s right.
Gnome keyboard shortcut: Press Super S to open the menu.
- Select Caffeine to prevent system and screen from sleeping or locking.
For a while: Click the > item to pick a timer for Caffeine to disengage automatically after a while.
On a Mac? How to Disable Sleep on a Mac (Caffeinate -D and Pmset)
Prevent KDE Linux from Sleeping (Stimulator)
To prevent a KDE Linux desktop from sleeping, turning off the display or running a screensaver:
- Install and run Stimulator.
Here’s how: You can get Stimulator from Flathub, for example.
Not just KDE: Stimulator also works with Gnome as a (simpler) alternative to the Caffeine shell extension. - Enable Disable Automatic Suspending.
Optional: Also Disable Screen Blanking and Locking to keep the screen from turning off.
Keep Linux Awake from a Terminal (Wakepy)
To stop a Linux machine from either going to sleep or (also) from turning off the screen using a command-line utility:
- Install wakepy.
Prerequisite: Wakepy is a Python script, so Python3 needs to be installed on the machine.
Here’s how: Typically,pip install wakepy
will install wakepy most conveniently, but other methods are possible as well. - Run
wakepy -p
on a command line to keep both computer and display awake.
Display snooze: Alternatively, runwakepy -r
to keep the computer running but allow the display to turn off.
How to Keep a Linux Computer and Display Awake: FAQ
Can I have an application always prevent sleep?
Yes.
Using Caffeine, for instance, you can set up applications that always engage it when running, on the active workspace or in focus. While control is not more granular than that—e.g., different actions for conditions set by app—, it is a start.
To have an application enable Caffeine automatically:
- Open Caffeine settings.
Here’s how: You can access settings from Extensions or Extension Manager, for example. - Go to the Apps tab.
- Click + Add.
- Highlight the desired application.
- Click Select.
- Choose in what state the applications will engage Caffeine under Apps trigger Caffeine mode.
(How to keep a Linux computer and display awake tested with Gnome 47; first published October 2024)