diff --git a/crates/frontend-gtk/src/main.rs b/crates/frontend-gtk/src/main.rs index dbda238..e1406d6 100644 --- a/crates/frontend-gtk/src/main.rs +++ b/crates/frontend-gtk/src/main.rs @@ -4,6 +4,8 @@ pub mod communications; pub mod components; pub mod helpers; +use std::fs; + use clap::{command, Parser}; use clap_verbosity_flag::{InfoLevel, Verbosity}; use colored::Colorize; @@ -52,6 +54,8 @@ struct Args { } fn main() { + initial_warning(); + let args = Args::parse(); log::set_logger(&LOGGER).expect("Could not set logger"); @@ -64,6 +68,28 @@ fn main() { .run_async::(()); } +fn initial_warning() { + let warning_lock_dir = std::env::home_dir().unwrap().join(".local/share/power-options-gtk"); + fs::create_dir_all(&warning_lock_dir).expect("Could not create app directory"); + let warning_lock_path = warning_lock_dir.join("user-consent.lock"); + + if fs::metadata(&warning_lock_path).is_err() { + let agreed = std::process::Command::new("yad").args([ + "--selectable-labels", + "--title", + "Warning: the GTK frontend might change your settings", + "--text", + "While power-options supports the ability to disable some options, the GTK frontend doesn't.\nThe GTK frontend likely will update and reaply your profiles to make sure that the values for all options are set (unless those features are unsupported).\nDo you want to continue?" + ]).spawn().expect("Could not spawn popup").wait().expect("Could not wait from popup").success(); + + if !agreed { + std::process::exit(-1); + } else { + fs::write(warning_lock_path, "").expect("Could not user agreement lock file"); + } + } +} + fn set_panic_dialog() { std::panic::set_hook(Box::new(|info| { let secondary_message = info.to_string();