Do you need your computer to stay awake for a long time? Maybe you’re downloading a big file, running a long process, or just want to keep your system active. Keep-Alive is a lightweight, easy-to-use tool that helps you prevent your computer from going to sleep.
It works on Linux, macOS, and Windows, and it’s perfect for anyone who needs their system to stay awake without any hassle.
Table of Contents
What is Keep-Alive?
Keep-Alive is a small program that stops your computer from sleeping. It’s great for:
- Keeping your system active during long downloads.
- Maintaining connections that need to stay alive.
- Preventing sleep during important tasks.
It’s simple to use, doesn’t need any complicated setup, and works on all major operating systems.
Key Features of Keep-Alive
- Configurable Duration: You can set how long you want your system to stay awake. For example, you can choose 2 hours, 30 minutes, or even 150 minutes (which is 2.5 hours).
- Cross-Platform: It works on macOS, Windows, and Linux.
- Lightweight: It doesn’t use much of your computer’s resources.
- Easy to Use: Just download it, run it, and your system will stay awake.
- No Configuration Needed: You don’t need to set anything up. It works right out of the box.
How Does Keep-Alive Work?
Keep-Alive uses different methods depending on your operating system to keep your computer awake:
On Linux:
- It uses
systemd-inhibit
to prevent sleep and lid switch actions. - If
systemd
is not available, it usesxset
commands or modifies GNOME settings.
On macOS:
- It uses the
caffeinate
command to prevent sleep, display sleep, and disk sleep. - It also simulates user activity to keep the system awake.
On Windows:
- It uses the
SetThreadExecutionState
API to prevent the system and display from sleeping. - It has a fallback method using PowerShell for extra reliability.
How to Install Keep-Alive in Linux
1. Download the Program:
curl -LO https://github.com/stigoleg/keep-alive/releases/latest/download/keep-alive_Linux_x86_64.tar.gz
2. Extract the Files:
After downloading, extract the files with this command:
tar xzf keep-alive_*_x86_64.tar.gz
3. Move the Program to PATH:
Move the program to your system's PATH, for example /usr/local/bin
:
sudo mv keepalive /usr/local/bin/
Building Keep-Alive from Source
Dependencies for Linux:
- Linux: You’ll need
systemd
(recommended) or X11, and a terminal that supports TUI applications. - Build Dependencies: If you want to build the program from source, you’ll need Go 1.21 or later. Make sure you've installed latest Go language on your system.
If you want to build Keep-Alive yourself, follow these steps:
Clone the repository:
git clone https://github.com/stigoleg/keep-alive.git cd keep-alive
Build the program:
go build -o keepalive ./cmd/keepalive
Prevent Your Linux System from Sleeping
Using Command-Line Options
You can run prevent your Linux system from sleeping using Keep-Alive with some simple commands.
Set a Duration:
Use the -d
flag to set how long you want your system to stay awake. For example:
keepalive -d 2h30m
This will keep your system awake for 2 hours and 30 minutes.
To see which version you’re using, type:
keepalive -v
If you need help, just type:
keepalive -h
Interactive Mode
If you prefer a menu-driven approach, you can use the interactive mode:
Start the program without any flags:
keepalive
- Use the arrow keys (↑/↓) or
j
/k
to navigate the menu. - Press Enter to select an option.
- Press q or Esc to quit.
Here's the visual demo:
Why Choose Keep-Alive?
- Reliability: It continuously monitors the system and restarts processes if they fail.
- Graceful Cleanup: When you stop the program, it restores your system’s original settings.
- Resource Efficiency: It uses very little of your computer’s resources while keeping it awake.
Conclusion
Keep-Alive is an useful utility for anyone needing to prevent their computer from sleeping during critical tasks. It is a simple, effective tool for keeping your computer awake without any user intervention.
Whether you’re downloading files, running long processes, or just need your system to stay active, Keep-Alive has you covered. It’s easy to install, easy to use, and works on all major platforms. Give it a try and say goodbye to unexpected system sleep!
Resource:
Recommended Read: