diff --git a/src/app.rs b/src/app.rs index 19062702..1ad75d5f 100644 --- a/src/app.rs +++ b/src/app.rs @@ -80,6 +80,7 @@ pub struct Context { pub covered: bool, pub shared: bool, pub online: bool, + pub killed_xochitl: bool, } impl Context { @@ -94,7 +95,7 @@ impl Context { keyboard_layouts: BTreeMap::new(), input_history: FxHashMap::default(), battery, frontlight, lightsensor, notification_index: 0, kb_rect: Rectangle::default(), rng, plugged: false, covered: false, - shared: false, online: false } + shared: false, online: false, killed_xochitl: false } } pub fn batch_import(&mut self) { @@ -335,6 +336,7 @@ fn set_wifi(enable: bool, context: &mut Context) { enum ExitStatus { Quit, + QuitToXochitl, Reboot, PowerOff, } @@ -435,6 +437,14 @@ pub fn run() -> Result<(), Error> { schedule_task(TaskId::CheckBattery, Event::CheckBattery, BATTERY_REFRESH_INTERVAL, &tx, &mut tasks); + if let Ok(status) = Command::new("pidof").arg("xochitl").status() { + if status.code().unwrap() == 0 { + Command::new("systemctl").arg("stop").arg("xochitl").status().ok(); + context.killed_xochitl = true; + println!("Xochitl was found and killed. You may only exit by starting Xochitl again.") + } + } + while let Ok(evt) = rx.recv() { match evt { Event::Device(de) => { @@ -1047,6 +1057,10 @@ pub fn run() -> Result<(), Error> { Event::Select(EntryId::Quit) => { break; }, + Event::Select(EntryId::QuitToXochitl) => { + exit_status = ExitStatus::QuitToXochitl; + break; + }, Event::Select(EntryId::RebootInNickel) => { fs::remove_file("bootlock").map_err(|e| { eprintln!("Couldn't remove the bootlock file: {}", e); @@ -1101,6 +1115,10 @@ pub fn run() -> Result<(), Error> { Command::new("sync").status().ok(); Command::new("poweroff").arg("-f").status().ok(); }, + ExitStatus::QuitToXochitl => { + Command::new("sync").status().ok(); + Command::new("systemctl").arg("start").arg("xochitl").status().ok(); + }, _ => (), } diff --git a/src/view/common.rs b/src/view/common.rs index d581f0a1..bcd97865 100644 --- a/src/view/common.rs +++ b/src/view/common.rs @@ -136,7 +136,10 @@ pub fn toggle_main_menu(view: &mut dyn View, rect: Rectangle, enable: Option