Skip to main content

Crate wayle_power_profiles

Crate wayle_power_profiles 

Source
Expand description

Power profile management via power-profiles-daemon D-Bus.

§Quick Start

use wayle_power_profiles::PowerProfilesService;

let service = PowerProfilesService::new().await?;

// Check current profile
let profile = service.power_profiles.active_profile.get();
println!("Current profile: {profile}");

// List available profiles
for p in service.power_profiles.profiles.get() {
    println!("  {} (driver: {})", p.profile, p.driver);
}

§Watching for Changes

use wayle_power_profiles::PowerProfilesService;
use futures::StreamExt;

// React to profile changes
let mut stream = service.power_profiles.active_profile.watch();
while let Some(profile) = stream.next().await {
    println!("Profile changed to: {profile}");
}

§Profile Control

use wayle_power_profiles::PowerProfilesService;
use wayle_power_profiles::types::profile::{PowerProfile, PerformanceDegradationReason};

// Switch to performance mode
service.power_profiles.set_active_profile(PowerProfile::Performance).await?;

// Check if performance is degraded (e.g., thermal throttling)
let degraded = service.power_profiles.performance_degraded.get();
if degraded != PerformanceDegradationReason::None {
    println!("Performance degraded: {degraded}");
}

§Reactive Properties

All fields are Property<T>:

  • .get() - Current value snapshot
  • .watch() - Stream yielding on changes

§Service Fields

FieldTypeDescription
active_profilePowerProfileCurrently active profile
performance_degradedPerformanceDegradationReasonWhy performance is degraded
profilesVec<Profile>Available profiles and their drivers
actionsVec<String>Daemon-supported actions
active_profile_holdsVec<ProfileHold>Applications holding a profile

§Configuration

MethodEffect
with_daemon()Switch profiles from scripts or other processes
use wayle_power_profiles::PowerProfilesService;

let service = PowerProfilesService::builder()
    .with_daemon()
    .build()
    .await?;

§D-Bus Interface

When with_daemon() is enabled, the service registers on the session bus.

  • Service: com.wayle.PowerProfiles1
  • Path: /com/wayle/PowerProfiles
  • Interface: com.wayle.PowerProfiles1

See dbus.md for the full interface specification.

§Control Methods

Re-exports§

pub use core::PowerProfiles;

Modules§

core
Reactive power profile state.
dbus
D-Bus interface for CLI control. D-Bus interface for the power profiles service.
types
Power profile type definitions.

Structs§

PowerProfilesService
Entry point for power-profiles-daemon integration. See crate-level docs.
PowerProfilesServiceBuilder
Builder for configuring and creating a PowerProfilesService instance.

Enums§

Error
Power profiles service errors