Skip to content

Repository files navigation

Tea

A cross-platform system tray application that prevents your system from going to sleep. Built with Rust and Tauri 2.0.

Tea Icon

Features

  • Prevent system sleep with a single click
  • Screen Control Modes:
    • Keep Screen On: Prevents both system sleep and screen turning off (Windows only)
    • Allow Screen Off: Keeps system awake but allows screen to sleep/turn off
  • System tray integration for easy access
  • Start at login option
  • Cross-platform support (Windows, macOS, Linux)
  • Minimal resource usage
  • No visible interference with your work

Installation

Pre-built Binaries

Download the latest release for your platform from the Releases page.

Building from Source

Prerequisites

Build Steps

  1. Clone the repository

    git clone https://github.com/Swatto86/tea.git
    cd tea
  2. Build the application

    cargo tauri build

The compiled application will be available in src-tauri/target/release.

Usage

  1. Launch the application
  2. Click the system tray icon (appears in your taskbar/menu bar)
  3. Select "Disable Sleep" to prevent your system from sleeping
  4. Choose your screen mode:
    • Keep Screen On: Prevents screen from turning off (Windows: uses native API)
    • Allow Screen Off: Lets screen sleep but keeps system awake
  5. Optionally enable "Start at Login" for automatic startup

How it Works

Tea uses an intelligent approach combining F15 key simulation with platform-specific display control:

Windows Platform

  • Keep Screen On mode: Uses Windows SetThreadExecutionState API with ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED flags + F15 simulation for redundancy
  • Allow Screen Off mode: Uses only the Windows API with ES_SYSTEM_REQUIRED flag (no F15), which keeps the system awake while allowing the screen to sleep normally

Non-Windows Platforms (macOS, Linux)

  • Simulates a function key (F15) press every 60 seconds to prevent system sleep
  • Non-intrusive method that doesn't interfere with your work
  • Only "Keep Screen On" mode available - F15 simulation prevents both system and display sleep, making "Allow Screen Off" technically impossible on these platforms

Why F15?

F15 was chosen because it is non-standard on most keyboards and therefore unlikely to conflict with application shortcuts or user workflows. Most applications don't bind actions to F15, making it safe to simulate without interrupting your work.

State Persistence

Your preferences (sleep mode and screen control) are automatically saved to:

  • Windows: %LOCALAPPDATA%\tea\state.json
  • Linux: ~/.config/tea/state.json
  • macOS: ~/Library/Application Support/tea/state.json

Autostart

The "Start at Login" feature uses platform-specific mechanisms:

  • Windows: Registry entry at HKCU\Software\Microsoft\Windows\CurrentVersion\Run
  • macOS: LaunchAgent plist in ~/Library/LaunchAgents
  • Linux: Desktop file in ~/.config/autostart

Benefits

  • Minimal system impact with F15 key simulation
  • Works reliably in the background on all platforms
  • Additional Windows-specific screen control when needed
  • Preserves your settings between sessions

Development

Project Structure

tea/
├── src/ # Frontend (minimal - app is system tray only)
│ └── main.ts # Entry point (no interactive UI)
├── src-tauri/ # Rust backend code
│ ├── src/ # Source files
│ │ ├── main.rs # Application entry and tray setup
│ │ ├── commands.rs # Tauri command handlers
│ │ ├── core/ # Pure business logic
│ │ ├── persistence.rs # State file management
│ │ ├── platform.rs # Platform-specific power APIs
│ │ └── wake_service.rs # Background wake service
│ ├── icons/ # Application icons
│ └── Cargo.toml # Rust dependencies
├── tests/ # Test suite
│ ├── autostart.test.ts # Autostart documentation tests
│ ├── e2e.test.ts # End-to-end tests
│ └── frontend.test.ts # Frontend structure tests
└── README.md # This file

Testing

Run the test suite:

npm test# Watch mode
npm run test:run # Single run
npm run test:coverage # With coverage report

Note: Tea is a system tray-only application. The HTML window is not shown to users, so frontend tests validate basic structure while the real UI is the system tray menu.

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages