Prevent your computer from going to sleep with configurable activity simulation
Project description
NJStayAwake
NJStayAwake is a lightweight, configurable Python application that prevents your computer from going to sleep by simulating user activity. Perfect for presentations, long downloads, or when you need to keep your system active.
โจ Features
-
Multiple Activity Modes
- ๐ฏ Minimal: Single key press (least intrusive)
- ๐ฑ๏ธ Mouse: Mouse movement only
- โจ๏ธ Keyboard: Multiple key presses
- ๐ Full: Combined mouse and keyboard activity
-
Flexible Mouse Patterns
- Linear: Simple back-and-forth movement
- Circle: Smooth circular motion
- Random: Unpredictable nearby positions
-
Comprehensive Configuration
- Command-line arguments for quick adjustments
- JSON configuration file support
- Customizable intervals, keys, and patterns
- Adjustable logging levels
-
Professional Features
- Graceful shutdown with Ctrl+C
- Activity logging and statistics
- Configuration persistence
- Cross-platform support (Windows, macOS, Linux)
๐ฆ Installation
Option 1: Download Standalone EXE (Easiest - No Python Required!)
Windows:
- ๐ฑ๏ธ GUI: Download
NJStayAwake.exe- Just double-click to run! - ๐ป CLI: Download
njstayawake-cli.exe
Linux:
- ๐ฑ๏ธ GUI: Download
NJStayAwake- Run:chmod +x NJStayAwake && ./NJStayAwake - ๐ป CLI: Download
njstayawake-cli
macOS:
- ๐ฑ๏ธ GUI: Download
NJStayAwake- Right-click โ Open (first time) - ๐ป CLI: Download
njstayawake-cli
No extraction needed! Direct download and run! ๐
Option 2: Clone and Install (For Developers)
git clone https://github.com/jjnanthakumar/njstayawake.git
cd njstayawake
pip install -e .
Option 3: Install via pip (Automatically Published!)
pip install njstayawake
Then run:
# GUI
njstayawake-gui
# CLI
njstayawake --mode mouse --interval 60
Note: PyPI package is automatically published when new versions are released on GitHub!
Requirements (for Python installation)
- Python 3.8 or higher
- pyautogui (automatically installed)
- tkinter (comes with Python, for GUI)
๐ Quick Start
GUI Application (Easiest!)
# Run the graphical interface
python gui.py
# Or if installed via pip
njstayawake-gui
# Or just double-click NJStayAwake.exe (Windows)
The GUI provides:
- ๐จ User-friendly interface
- ๐ Real-time status and statistics
- โ๏ธ Easy configuration
- ๐พ Save/Load settings
- ๐ด Start/Stop buttons
Command-Line Interface
# Run with default settings (minimal mode, 60 second interval)
python cli.py
# Or if installed via pip
njstayawake
# Or use njstayawake-cli.exe (Windows)
Common Use Cases
# Presentation mode - minimal interference
python cli.py --mode minimal --interval 120
# Mouse movement only - subtle activity
python cli.py --mode mouse --pattern circle --interval 60
# Full activity mode for maximum effectiveness
python cli.py --mode full --interval 90
# Custom keyboard key
python cli.py --mode keyboard --key ctrl --presses 2
# Save your favorite configuration
python cli.py --mode mouse --pattern random --interval 45 --save-config
๐ Usage Examples
GUI Application
The GUI is self-explanatory:
- Select Mode: Choose from Minimal, Mouse, Keyboard, or Full
- Configure Settings: Adjust intervals, patterns, and keys
- Click Start: Begin preventing sleep
- View Stats: See real-time activity count and uptime
- Click Stop: Stop the service when done
Features:
- Visual status indicator (green = running, red = stopped)
- Real-time uptime counter
- Save/Load configuration files
- All settings in one window
Command-Line Arguments
# Basic options
python cli.py --mode mouse # Mouse movement mode
python cli.py --interval 30 # Activity every 30 seconds
python cli.py --duration 1.0 # Slower mouse movements
# Mouse customization
python cli.py --pattern circle # Circular mouse pattern
python cli.py --mouse-distance 100 # Larger movement radius
# Keyboard customization
python cli.py --key f15 # Use F15 key (less intrusive)
python cli.py --presses 5 # Multiple key presses
# Logging
python cli.py --log-level DEBUG # Detailed logging
python cli.py --log-file stay-awake.log # Log to file
# Configuration management
python cli.py --show-config # Show current settings
python cli.py --save-config # Save settings to file
python cli.py --config custom.json # Load custom config
Configuration File
Create a configuration file to save your preferences:
python cli.py --mode full --interval 120 --pattern circle --save-config
This creates a config file at:
- Windows:
%APPDATA%\StayAwake\config.json - Linux/Mac:
~/.config/stay-awake/config.json
Example config.json:
{
"interval": 120,
"duration": 0.5,
"mode": "full",
"mouse_distance": 75,
"mouse_pattern": "circle",
"keyboard_key": "shift",
"keyboard_presses": 2,
"log_level": "INFO",
"log_file": null,
"enable_tray": false
}
Programmatic Usage
from config import Config
from core import StayAwake
# Create custom configuration
config = Config(
mode="mouse",
interval=60,
mouse_pattern="circle",
mouse_distance=50
)
# Start the service
app = StayAwake(config)
app.start() # Runs until Ctrl+C
๐ฎ Activity Modes
Minimal Mode
- Best for: When you need minimal interference
- Activity: Single shift key press
- Detectability: Very low
- Use case: Video calls, presentations
Mouse Mode
- Best for: Keeping screen active
- Activity: Mouse movement (linear/circle/random)
- Detectability: Low to medium
- Use case: Watching videos, monitoring dashboards
Keyboard Mode
- Best for: Applications that detect keyboard activity
- Activity: Multiple key presses
- Detectability: Medium
- Use case: Terminal sessions, SSH connections
Full Mode
- Best for: Maximum reliability
- Activity: Both mouse movement and key presses
- Detectability: Medium to high
- Use case: Long running tasks, downloads
๐ ๏ธ Advanced Configuration
Environment-Specific Settings
Development:
python cli.py --mode minimal --interval 30 --log-level DEBUG
Production/Presentation:
python cli.py --mode mouse --pattern circle --interval 120 --log-level WARNING
Custom Patterns
The mouse patterns can be adjusted:
--mouse-distance 25- Smaller, subtle movements--mouse-distance 150- Larger, more noticeable movements--pattern random- Less predictable pattern
Keyboard Alternatives
Use less intrusive keys:
- F13-F24 function keys (rarely mapped)
- Scroll lock
- Num lock
Example:
python cli.py --mode keyboard --key f15 --presses 1
๐ Statistics and Monitoring
When you stop the service (Ctrl+C), you'll see statistics:
============================================================
Stay Awake Service Stopped
============================================================
Total activities performed: 42
Total runtime: 1h 15m 30s
============================================================
๐๏ธ Building Standalone Executables
Automatic Builds via GitHub Actions
No manual tagging needed! Just commit and push:
git add .
git commit -m "feat: add new feature" # Use conventional commits
git push origin main
GitHub Actions automatically:
- Analyzes your commit message
- Bumps version (patch/minor/major)
- Builds executables for Windows, Linux, and macOS
- Creates GitHub release with direct download links
- Uploads individual executables (no ZIP needed!)
- Publishes package to PyPI with matching version
- Users can
pip install stay-awakeimmediately!
Commit Message Guide:
feat:- New feature (bumps minor version)fix:- Bug fix (bumps patch version)BREAKING CHANGE:- Major change (bumps major version)
See COMMITS.md for full conventional commits guide.
Manual Build (Local)
Create executables that run without Python installed:
Build EXE (All Platforms)
# Install PyInstaller
pip install pyinstaller
# Run the build script
python build_exe.py
This creates:
dist/StayAwake.exe- GUI application (Windows) orStayAwake(Linux/Mac)dist/stay-awake-cli.exe- CLI application (Windows) orstay-awake-cli(Linux/Mac)
Manual Build Commands
# Build GUI version
pyinstaller --onefile --windowed --name=StayAwake gui.py
# Build CLI version
pyinstaller --onefile --console --name=stay-awake-cli cli.py
Distribution
The executables in the dist folder can be:
- Shared with others
- Run on any computer (no Python needed)
- Placed anywhere on your system
- Added to Windows startup folder for auto-start
โ๏ธ Configuration Options
| Option | Description | Default |
|---|---|---|
--mode |
Activity mode (minimal/mouse/keyboard/full) | minimal |
--interval |
Seconds between activities | 60 |
--duration |
Mouse movement duration (seconds) | 0.5 |
--mouse-distance |
Mouse movement distance (pixels) | 50 |
--pattern |
Mouse pattern (linear/circle/random) | linear |
--key |
Keyboard key to press | shift |
--presses |
Number of key presses | 1 |
--log-level |
Logging level (DEBUG/INFO/WARNING/ERROR) | INFO |
--log-file |
Path to log file | None |
--config |
Load config from file | None |
--save-config |
Save current config | - |
--show-config |
Display current config | - |
๐ง Troubleshooting
Permission Issues (macOS/Linux)
Some systems require accessibility permissions:
- macOS: System Preferences โ Security & Privacy โ Accessibility
- Linux: May need to run with appropriate permissions
PyAutoGUI Errors
If you get failsafe errors, the application disables failsafe by default, but you can adjust the code if needed.
High CPU Usage
Increase the interval between activities:
python cli.py --interval 300 # 5 minutes
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
โ ๏ธ Disclaimer
This tool is intended for legitimate use cases such as:
- Preventing sleep during presentations
- Keeping connections alive during long tasks
- Development and testing purposes
Please use responsibly and in accordance with your organization's policies.
๐ฏ Three Ways to Use Stay Awake
1. ๐ฑ๏ธ GUI Application (Recommended for Most Users)
- Best for: Everyone, especially non-technical users
- How to run:
- Windows: Double-click
run_gui.batorStayAwake.exe - Mac/Linux: Run
./run_gui.shorpython gui.py
- Windows: Double-click
- Features: Visual interface, real-time stats, easy configuration
2. ๐ป Command-Line Interface (For Advanced Users)
- Best for: Automation, scripting, remote servers
- How to run:
python cli.py --mode mouse --interval 60 - Features: Full control via arguments, scriptable, lightweight
3. ๐ฆ Standalone Executable (No Python Required)
- Best for: Sharing with others, production use
- How to build:
python build_exe.py - Features: Runs anywhere, no installation needed
๐ Changelog
Version 1.0.0
- โ GUI application with real-time monitoring
- โ CLI with comprehensive arguments
- โ Multiple activity modes (Minimal, Mouse, Keyboard, Full)
- โ Three mouse patterns (Linear, Circle, Random)
- โ Configuration file support (JSON)
- โ Comprehensive logging system
- โ Graceful shutdown handling
- โ Cross-platform support (Windows, macOS, Linux)
- โ Executable build support
- โ Statistics and monitoring
๐ค Author
Nanthakumar J J
- GitHub: @jjnanthakumar
๐ Support
If you find this project helpful:
- โญ Star it on GitHub
- ๐ Report bugs or request features
- ๐ค Contribute improvements
- ๐ข Share with others who might find it useful
๐ Acknowledgments
- Built with Python and PyAutoGUI
- Uses tkinter for GUI
- Packaged with PyInstaller
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file njstayawake-2.0.0.tar.gz.
File metadata
- Download URL: njstayawake-2.0.0.tar.gz
- Upload date:
- Size: 20.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cefaaadf8ba6ffc597c62f73585582d34e44e8e6a89fc15ccd829772c8a2664
|
|
| MD5 |
946249c2228625bb9b02513432578d4c
|
|
| BLAKE2b-256 |
d0597b4e81601ec8d58561f0a81defacd911f576b0e5beea7e795ce76ccdffcd
|
File details
Details for the file njstayawake-2.0.0-py3-none-any.whl.
File metadata
- Download URL: njstayawake-2.0.0-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bd5689f3280c6b404c9d19840f8484a60349431afdb2c1a3d31d6735ac48cfe
|
|
| MD5 |
723ef47836672440fe71240963398ee5
|
|
| BLAKE2b-256 |
d56416654db30ba86a6dc3acebe9ae66b40ae21445ca9716308edabf97649c8b
|