Skip to main content

Prevent your computer from going to sleep with configurable activity simulation

Project description

NJStayAwake

License Python PyPI

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!)

๐Ÿ“ฅ Download Latest Release

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:

  1. Select Mode: Choose from Minimal, Mouse, Keyboard, or Full
  2. Configure Settings: Adjust intervals, patterns, and keys
  3. Click Start: Begin preventing sleep
  4. View Stats: See real-time activity count and uptime
  5. 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-awake immediately!

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) or StayAwake (Linux/Mac)
  • dist/stay-awake-cli.exe - CLI application (Windows) or stay-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.bat or StayAwake.exe
    • Mac/Linux: Run ./run_gui.sh or python gui.py
  • 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

๐ŸŒŸ 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

njstayawake-1.0.0.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

njstayawake-1.0.0-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file njstayawake-1.0.0.tar.gz.

File metadata

  • Download URL: njstayawake-1.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

Hashes for njstayawake-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5bcf13733865c75ba1868d7801f307a06592c256bbdf4ea62d855fd2753ed260
MD5 e0c8ef62c8e0d0b31c4b4bc2ab809e32
BLAKE2b-256 08cd02ee5bb9363b156f71e780c64d136e7f9231181e307895ced9fd8ef2efda

See more details on using hashes here.

File details

Details for the file njstayawake-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: njstayawake-1.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

Hashes for njstayawake-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b59ec444020a6b6e14f0bc7819f18f65f2ee35d3f5f6a7e9cc30c0e4eddaa27
MD5 669f59daafeb772d7ef7a2b69b65bf8a
BLAKE2b-256 86887dabf548a841543bb93abf7a0febb0c354b4338ea9acb866fc3e70399c98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page