mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Fix up colour sliders
- Fixup colour sliders for UI - Correctly drop tokio runtime
This commit is contained in:
@@ -22,8 +22,6 @@ use rog_control_center::{
|
||||
get_ipc_file, on_tmp_dir_exists, print_versions, MainWindow, QUIT_APP, SHOWING_GUI, SHOW_GUI,
|
||||
};
|
||||
use tokio::runtime::Runtime;
|
||||
// use winit::monitor::VideoMode;
|
||||
// use winit::window::{Fullscreen, WindowLevel};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
@@ -73,11 +71,6 @@ async fn main() -> Result<()> {
|
||||
.format_timestamp(None)
|
||||
.init();
|
||||
|
||||
// start tokio
|
||||
let rt = Runtime::new().expect("Unable to create Runtime");
|
||||
// Enter the runtime so that `tokio::spawn` is available immediately.
|
||||
let _enter = rt.enter();
|
||||
|
||||
let supported_properties = match proxy.supported_properties() {
|
||||
Ok(s) => s,
|
||||
Err(_e) => {
|
||||
@@ -117,7 +110,13 @@ async fn main() -> Result<()> {
|
||||
let enable_tray_icon = config.enable_tray_icon;
|
||||
let startup_in_background = config.startup_in_background;
|
||||
let config = Arc::new(Mutex::new(config));
|
||||
start_notifications(config.clone())?;
|
||||
|
||||
// start tokio
|
||||
let rt = Runtime::new().expect("Unable to create Runtime");
|
||||
// Enter the runtime so that `tokio::spawn` is available immediately.
|
||||
let _enter = rt.enter();
|
||||
start_notifications(config.clone(), &rt)?;
|
||||
|
||||
if enable_tray_icon {
|
||||
init_tray(supported_properties, config.clone());
|
||||
}
|
||||
@@ -208,6 +207,7 @@ async fn main() -> Result<()> {
|
||||
});
|
||||
|
||||
slint::run_event_loop_until_quit().unwrap();
|
||||
rt.shutdown_background();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user