Skip to content

Commit

Permalink
Added a warning for the first time the GTK frontend is launched, info…
Browse files Browse the repository at this point in the history
…rming the user that some settings might be changed. #14
  • Loading branch information
TheAlexDev23 committed Sep 17, 2024
1 parent c606678 commit 760efb8
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions crates/frontend-gtk/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -52,6 +54,8 @@ struct Args {
}

fn main() {
initial_warning();

let args = Args::parse();

log::set_logger(&LOGGER).expect("Could not set logger");
Expand All @@ -64,6 +68,28 @@ fn main() {
.run_async::<App>(());
}

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 <b>will update and reaply</b> 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();
Expand Down

0 comments on commit 760efb8

Please sign in to comment.