Fix up colour sliders

- Fixup colour sliders for UI
- Correctly drop tokio runtime
This commit is contained in:
Luke D. Jones
2024-05-08 22:28:22 +12:00
parent 1b023d0f5f
commit a18692ef1e
9 changed files with 134 additions and 143 deletions

View File

@@ -18,6 +18,8 @@ use serde::{Deserialize, Serialize};
use supergfxctl::actions::UserActionRequired as GfxUserAction;
use supergfxctl::pci_device::{GfxMode, GfxPower};
use supergfxctl::zbus_proxy::DaemonProxy as SuperProxy;
use tokio::runtime::Runtime;
use tokio::task::JoinHandle;
use tokio::time::sleep;
use zbus::export::futures_util::StreamExt;
@@ -44,10 +46,13 @@ impl Default for EnabledNotifications {
}
}
pub fn start_notifications(config: Arc<Mutex<Config>>) -> Result<()> {
pub fn start_notifications(
config: Arc<Mutex<Config>>,
rt: &Runtime,
) -> Result<Vec<JoinHandle<()>>> {
// Setup the AC/BAT commands that will run on power status change
let config_copy = config.clone();
tokio::task::spawn_blocking(move || {
let blocking = rt.spawn_blocking(move || {
let power = AsusPower::new()
.map_err(|e| {
error!("AsusPower: {e}");
@@ -217,7 +222,7 @@ pub fn start_notifications(config: Arc<Mutex<Config>>) -> Result<()> {
};
});
Ok(())
Ok(vec![blocking])
}
fn convert_gfx_mode(gfx: GfxMode) -> GpuMode {