Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

PowerRules

latest-version latest-beta-version license

About

PowerRules allows you to define rules that automatically control the power state of your computer based on configurable conditions.

Rules are evaluated from top to bottom. The first matching rule executes its configured action.

Getting Started

Install with pip:

pip install powerrules

Create a policy file:

# yaml-language-server: $schema=https://raw.githubusercontent.com/LeoTN/PowerRules/main/assets/schema/powerrules_policy.schema.json

rules:
  - name: "Shutdown after nightly weekend backup"
    conditions:
      and:
        - process:
            name: "backup.exe"
            exists: false
        - window:
            title: "Backup Completed"
            exists: true
        - datetime:
            between:
              start: "23"
              end: "1:30"
        - datetime:
            weekday: ["Saturday", "Sunday"]
    action:
      type: shutdown

Validate the policy:

pwru policy validate

Show configured rules:

pwru policy show

Evaluate the policy once:

pwru policy run --once

Run continuously:

pwru policy run

Use a different policy file with --policy or -p:

pwru policy run --policy my-policy.yaml

Features

Feature Description
Rule-based power management Define ordered rules with conditions and power actions
Process conditions Match rules based on whether a process exists
Time conditions Match time ranges and weekdays
Window conditions Match window titles
Logical conditions Combine conditions using and, or, and not
Matching behavior How a value (process name, window title, etc.) should be matched. By default, an exact, case-sensitive match is used.
Power actions Shutdown, sleep, hibernate, and reboot
Continuous evaluation Evaluate policies repeatedly
First-match execution Only the first matching rule executes once per match

Supported Platforms

Platform Status
Windows 10/11 ✅
Linux ✅
macOS* ✅

* Hibernation is not supported on macOS.

Credits & License

  • Pydantic → configuration validation
  • PyYAML → YAML policy parsing
  • Typer → command-line interface
  • psutil → process information
  • PyWinCtl → window information
  • Inkscape → program used to design the logo

This repository is licensed under the MIT License.

Release files for powerrules 0.2.0b1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for powerrules 0.2.0b1
File Size Uploaded
powerrules-0.2.0b1.tar.gz 14.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for powerrules 0.2.0b1
File Interpreter ABI Platform
powerrules-0.2.0b1-py3-none-any.whl Python 3 none any Details

Total release size: 36.8 kB

Release files / powerrules-0.2.0b1.tar.gz

Download URL powerrules-0.2.0b1.tar.gz
Size 14.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9f30840ca1ebf2ed8b18a6e8d1e92aa2fdc5d1f298284bb8fe8e449ff7abba65
BLAKE2b-256 checksum
How to use checksums
0b06b101f61ebc268018d2d748fc5aceac3011ddf6d85f8259ed388e4dfb2407
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.12.3 Linux/6.17.0-1022-azure

Release files / powerrules-0.2.0b1-py3-none-any.whl

Download URL powerrules-0.2.0b1-py3-none-any.whl
Size 22.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0b08b27de299219f3d680816ba5c162f92b01da9bf2da14d917f411bd4f12b9a
BLAKE2b-256 checksum
How to use checksums
ebdfad67cb2919592c8bcabfcbe2e18c90793167c1f042ff91ebebf89f88ace8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.12.3 Linux/6.17.0-1022-azure
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page