Crate ppd

Crate ppd 

Source
Expand description

§ppd-rs

ppd-rs is a Rust interface for the Power Profiles Daemon (PPD), which allows applications to interact with system power profiles on Linux systems.

This library provides a Rust API for the D-Bus interface exposed by the Power Profiles Daemon, allowing applications to:

  • Get the current active power profile
  • List available power profiles
  • Switch between power profiles
  • Hold a profile for a specific application
  • Release profile holds
  • Configure power-related actions
  • Query and configure battery-aware behavior

§Usage

use ppd::{PpdProxyBlocking, Result};
use zbus::blocking::Connection;

fn main() -> Result<()> {
    let connection = Connection::system()?;
    let proxy = PpdProxyBlocking::new(&connection)?;
     
    // Get current profile
    let current_profile = proxy.active_profile()?;
    println!("Current profile: {}", current_profile);
     
    // List available profiles
    let profiles = proxy.profiles()?;
    for profile in profiles {
        println!("Profile: {}", profile.profile);
    }
     
    Ok(())
}

Re-exports§

pub use error::PpdError;
pub use error::Result;

Modules§

error
Error handling for the ppd library Error handling for the ppd-rs library

Structs§

Action
Represents a configurable power-related action
ActiveHold
Represents an active profile hold
PpdProxy
Power Profiles Daemon D-Bus interface
PpdProxyBlocking
Power Profiles Daemon D-Bus interface
Profile
Represents a power profile configuration
ProfileReleased
A ProfileReleased signal.
ProfileReleasedIterator
A Iterator implementation that yields ProfileReleased signals.
ProfileReleasedStream
A Stream implementation that yields ProfileReleased signals.