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
| Field | Type | Description |
|---|---|---|
active_profile | PowerProfile | Currently active profile |
performance_degraded | PerformanceDegradationReason | Why performance is degraded |
profiles | Vec<Profile> | Available profiles and their drivers |
actions | Vec<String> | Daemon-supported actions |
active_profile_holds | Vec<ProfileHold> | Applications holding a profile |
§Configuration
| Method | Effect |
|---|---|
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
set_active_profile()- Switch power profile
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§
- Power
Profiles Service - Entry point for power-profiles-daemon integration. See crate-level docs.
- Power
Profiles Service Builder - Builder for configuring and creating a PowerProfilesService instance.
Enums§
- Error
- Power profiles service errors