Base work on graphics api
This commit is contained in:
parent
b8d17f2b2f
commit
f4b895d61d
4 changed files with 45 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
//! # DBus interface proxy for: `com.system76.PowerDaemon`
|
//! # DBus interface proxy for: `com.system76.PowerDaemon`
|
||||||
//!
|
//!
|
||||||
//! This code was generated by `zbus-xmlgen` `2.0.1` from DBus introspection data.
|
//! This code was generated by `zbus-xmlgen` `2.0.1` from DBus introspection data.
|
||||||
|
|
|
||||||
42
applets/cosmic-applet-graphics/src/graphics.rs
Normal file
42
applets/cosmic-applet-graphics/src/graphics.rs
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
use crate::dbus::PowerDaemonProxy;
|
||||||
|
use zbus::Result;
|
||||||
|
|
||||||
|
pub enum Graphics {
|
||||||
|
Integrated,
|
||||||
|
Hybrid,
|
||||||
|
External,
|
||||||
|
Compute,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_current_graphics(daemon: &PowerDaemonProxy<'_>) -> Result<Graphics> {
|
||||||
|
let graphics = daemon.get_graphics().await?;
|
||||||
|
match graphics.as_str() {
|
||||||
|
"integrated" => Ok(Graphics::Integrated),
|
||||||
|
"hybrid" => Ok(Graphics::Hybrid),
|
||||||
|
"external" => Ok(Graphics::External),
|
||||||
|
"compute" => Ok(Graphics::Compute),
|
||||||
|
_ => panic!("Unknown graphics profile: {}", graphics),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_default_graphics(daemon: &PowerDaemonProxy<'_>) -> Result<Graphics> {
|
||||||
|
let graphics = daemon.get_default_graphics().await?;
|
||||||
|
match graphics.as_str() {
|
||||||
|
"integrated" => Ok(Graphics::Integrated),
|
||||||
|
"hybrid" => Ok(Graphics::Hybrid),
|
||||||
|
"external" => Ok(Graphics::External),
|
||||||
|
"compute" => Ok(Graphics::Compute),
|
||||||
|
_ => panic!("Unknown graphics profile: {}", graphics),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn set_graphics(daemon: &PowerDaemonProxy<'_>, graphics: Graphics) -> Result<()> {
|
||||||
|
let graphics_str = match graphics {
|
||||||
|
Graphics::Integrated => "integrated",
|
||||||
|
Graphics::Hybrid => "hybrid",
|
||||||
|
Graphics::External => "external",
|
||||||
|
Graphics::Compute => "compute",
|
||||||
|
};
|
||||||
|
daemon.set_graphics(graphics_str).await
|
||||||
|
}
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
extern crate relm4_macros;
|
extern crate relm4_macros;
|
||||||
|
|
||||||
pub mod dbus;
|
pub mod dbus;
|
||||||
|
pub mod graphics;
|
||||||
pub mod profile;
|
pub mod profile;
|
||||||
|
|
||||||
use gtk4::{gio::ApplicationFlags, prelude::*, Orientation};
|
use gtk4::{gio::ApplicationFlags, prelude::*, Orientation};
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
use crate::dbus::PowerDaemonProxy;
|
use crate::dbus::PowerDaemonProxy;
|
||||||
use zbus::Result;
|
use zbus::Result;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue