mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Add small env fixes for Ally
Signed-off-by: Luke Jones <luke@ljones.dev>
This commit is contained in:
@@ -35,10 +35,21 @@ async fn main() -> Result<()> {
|
|||||||
// If we're running under gamescope we have to set WAYLAND_DISPLAY for winit to
|
// If we're running under gamescope we have to set WAYLAND_DISPLAY for winit to
|
||||||
// use
|
// use
|
||||||
if let Ok(gamescope) = env::var("GAMESCOPE_WAYLAND_DISPLAY") {
|
if let Ok(gamescope) = env::var("GAMESCOPE_WAYLAND_DISPLAY") {
|
||||||
|
dbg!(1);
|
||||||
if !gamescope.is_empty() {
|
if !gamescope.is_empty() {
|
||||||
|
dbg!(2);
|
||||||
env::set_var("WAYLAND_DISPLAY", gamescope);
|
env::set_var("WAYLAND_DISPLAY", gamescope);
|
||||||
}
|
}
|
||||||
|
// gamescope-0
|
||||||
|
else if let Ok(wayland) = env::var("WAYLAND_DISPLAY") {
|
||||||
|
dbg!(3);
|
||||||
|
if wayland.is_empty() {
|
||||||
|
dbg!(4);
|
||||||
|
env::set_var("WAYLAND_DISPLAY", "gamescope-0");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
dbg!("SHITR");
|
||||||
|
|
||||||
// Try to open a proxy and check for app state first
|
// Try to open a proxy and check for app state first
|
||||||
{
|
{
|
||||||
@@ -92,7 +103,7 @@ async fn main() -> Result<()> {
|
|||||||
let board_name = dmi.board_name;
|
let board_name = dmi.board_name;
|
||||||
let prod_family = dmi.product_family;
|
let prod_family = dmi.product_family;
|
||||||
info!("Running on {board_name}, product: {prod_family}");
|
info!("Running on {board_name}, product: {prod_family}");
|
||||||
let is_rog_ally = prod_family == "RC71L" || prod_family == "RC72L";
|
let is_rog_ally = board_name == "RC71L" || board_name == "RC72L" || prod_family == "ROG Ally";
|
||||||
|
|
||||||
let args: Vec<String> = args().skip(1).collect();
|
let args: Vec<String> = args().skip(1).collect();
|
||||||
|
|
||||||
@@ -163,73 +174,101 @@ async fn main() -> Result<()> {
|
|||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let mut state = AppState::StartingUp;
|
let mut state = AppState::StartingUp;
|
||||||
loop {
|
loop {
|
||||||
// save as a var, don't hold the lock the entire time or deadlocks happen
|
if is_rog_ally {
|
||||||
if let Ok(app_state) = app_state.lock() {
|
let config_copy_2 = config.clone();
|
||||||
state = *app_state;
|
let newui = setup_window(config.clone());
|
||||||
}
|
newui.window().on_close_requested(move || {
|
||||||
|
exit(0);
|
||||||
|
});
|
||||||
|
|
||||||
// This sleep is required to give the event loop time to react
|
let ui_copy = newui.as_weak();
|
||||||
sleep(Duration::from_millis(300));
|
newui
|
||||||
if state == AppState::MainWindowShouldOpen {
|
.window()
|
||||||
if let Ok(mut app_state) = app_state.lock() {
|
.set_rendering_notifier(move |s, _| {
|
||||||
*app_state = AppState::MainWindowOpen;
|
if let slint::RenderingState::BeforeRendering = s {
|
||||||
}
|
let config = config_copy_2.clone();
|
||||||
|
ui_copy
|
||||||
let config_copy = config.clone();
|
.upgrade_in_event_loop(move |w| {
|
||||||
let app_state_copy = app_state.clone();
|
let fullscreen =
|
||||||
slint::invoke_from_event_loop(move || {
|
config.lock().is_ok_and(|c| c.start_fullscreen);
|
||||||
UI.with(|ui| {
|
if fullscreen && !w.window().is_fullscreen() {
|
||||||
let app_state_copy = app_state_copy.clone();
|
w.window().set_fullscreen(fullscreen);
|
||||||
let mut ui = ui.borrow_mut();
|
|
||||||
if let Some(ui) = ui.as_mut() {
|
|
||||||
ui.window().show().unwrap();
|
|
||||||
ui.window().on_close_requested(move || {
|
|
||||||
if let Ok(mut app_state) = app_state_copy.lock() {
|
|
||||||
*app_state = AppState::MainWindowClosed;
|
|
||||||
}
|
|
||||||
slint::CloseRequestResponse::HideWindow
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
let config_copy_2 = config_copy.clone();
|
|
||||||
let newui = setup_window(config_copy);
|
|
||||||
newui.window().on_close_requested(move || {
|
|
||||||
if let Ok(mut app_state) = app_state_copy.lock() {
|
|
||||||
*app_state = AppState::MainWindowClosed;
|
|
||||||
}
|
|
||||||
slint::CloseRequestResponse::HideWindow
|
|
||||||
});
|
|
||||||
|
|
||||||
let ui_copy = newui.as_weak();
|
|
||||||
newui
|
|
||||||
.window()
|
|
||||||
.set_rendering_notifier(move |s, _| {
|
|
||||||
if let slint::RenderingState::RenderingSetup = s {
|
|
||||||
let config = config_copy_2.clone();
|
|
||||||
ui_copy
|
|
||||||
.upgrade_in_event_loop(move |w| {
|
|
||||||
let fullscreen =
|
|
||||||
config.lock().is_ok_and(|c| c.start_fullscreen);
|
|
||||||
if fullscreen && !w.window().is_fullscreen() {
|
|
||||||
w.window().set_fullscreen(fullscreen);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
ui.replace(newui);
|
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
})
|
.ok();
|
||||||
.unwrap();
|
} else {
|
||||||
} else if state == AppState::QuitApp {
|
// save as a var, don't hold the lock the entire time or deadlocks happen
|
||||||
slint::quit_event_loop().unwrap();
|
if let Ok(app_state) = app_state.lock() {
|
||||||
exit(0);
|
state = *app_state;
|
||||||
} else if state != AppState::MainWindowOpen {
|
}
|
||||||
if let Ok(config) = config.lock() {
|
|
||||||
if !config.run_in_background {
|
// This sleep is required to give the event loop time to react
|
||||||
slint::quit_event_loop().unwrap();
|
sleep(Duration::from_millis(300));
|
||||||
exit(0);
|
if state == AppState::MainWindowShouldOpen {
|
||||||
|
if let Ok(mut app_state) = app_state.lock() {
|
||||||
|
*app_state = AppState::MainWindowOpen;
|
||||||
|
}
|
||||||
|
|
||||||
|
let config_copy = config.clone();
|
||||||
|
let app_state_copy = app_state.clone();
|
||||||
|
slint::invoke_from_event_loop(move || {
|
||||||
|
UI.with(|ui| {
|
||||||
|
let app_state_copy = app_state_copy.clone();
|
||||||
|
let mut ui = ui.borrow_mut();
|
||||||
|
if let Some(ui) = ui.as_mut() {
|
||||||
|
ui.window().show().unwrap();
|
||||||
|
ui.window().on_close_requested(move || {
|
||||||
|
if let Ok(mut app_state) = app_state_copy.lock() {
|
||||||
|
*app_state = AppState::MainWindowClosed;
|
||||||
|
}
|
||||||
|
slint::CloseRequestResponse::HideWindow
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
let config_copy_2 = config_copy.clone();
|
||||||
|
let newui = setup_window(config_copy);
|
||||||
|
newui.window().on_close_requested(move || {
|
||||||
|
if let Ok(mut app_state) = app_state_copy.lock() {
|
||||||
|
*app_state = AppState::MainWindowClosed;
|
||||||
|
}
|
||||||
|
slint::CloseRequestResponse::HideWindow
|
||||||
|
});
|
||||||
|
|
||||||
|
let ui_copy = newui.as_weak();
|
||||||
|
newui
|
||||||
|
.window()
|
||||||
|
.set_rendering_notifier(move |s, _| {
|
||||||
|
if let slint::RenderingState::RenderingSetup = s {
|
||||||
|
let config = config_copy_2.clone();
|
||||||
|
ui_copy
|
||||||
|
.upgrade_in_event_loop(move |w| {
|
||||||
|
let fullscreen = config
|
||||||
|
.lock()
|
||||||
|
.is_ok_and(|c| c.start_fullscreen);
|
||||||
|
if fullscreen && !w.window().is_fullscreen() {
|
||||||
|
w.window().set_fullscreen(fullscreen);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
ui.replace(newui);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
} else if state == AppState::QuitApp {
|
||||||
|
slint::quit_event_loop().unwrap();
|
||||||
|
exit(0);
|
||||||
|
} else if state != AppState::MainWindowOpen {
|
||||||
|
if let Ok(config) = config.lock() {
|
||||||
|
if !config.run_in_background {
|
||||||
|
slint::quit_event_loop().unwrap();
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user