Add profile configuration functions
This commit is contained in:
parent
e03225384b
commit
b8d17f2b2f
2 changed files with 28 additions and 0 deletions
|
|
@ -4,6 +4,8 @@
|
||||||
extern crate relm4_macros;
|
extern crate relm4_macros;
|
||||||
|
|
||||||
pub mod dbus;
|
pub mod dbus;
|
||||||
|
pub mod profile;
|
||||||
|
|
||||||
use gtk4::{gio::ApplicationFlags, prelude::*, Orientation};
|
use gtk4::{gio::ApplicationFlags, prelude::*, Orientation};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use tokio::runtime::Runtime;
|
use tokio::runtime::Runtime;
|
||||||
|
|
|
||||||
26
applets/cosmic-applet-graphics/src/profile.rs
Normal file
26
applets/cosmic-applet-graphics/src/profile.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
use crate::dbus::PowerDaemonProxy;
|
||||||
|
use zbus::Result;
|
||||||
|
|
||||||
|
pub enum Profile {
|
||||||
|
Performance,
|
||||||
|
Balanced,
|
||||||
|
Battery,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_current_profile(daemon: &PowerDaemonProxy<'_>) -> Result<Profile> {
|
||||||
|
let profile = daemon.get_profile().await?;
|
||||||
|
match profile.as_str() {
|
||||||
|
"Performance" => Ok(Profile::Performance),
|
||||||
|
"Balanced" => Ok(Profile::Balanced),
|
||||||
|
"Battery" => Ok(Profile::Battery),
|
||||||
|
_ => panic!("Unknown profile: {}", profile),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn set_profile(daemon: &PowerDaemonProxy<'_>, profile: Profile) -> zbus::Result<()> {
|
||||||
|
match profile {
|
||||||
|
Profile::Performance => daemon.performance().await,
|
||||||
|
Profile::Balanced => daemon.balanced().await,
|
||||||
|
Profile::Battery => daemon.battery().await,
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue