Skip to content

Commit

Permalink
Show only one "Quit" option dep. on .service and remove cli opt
Browse files Browse the repository at this point in the history
When xochitl.service is active upon booting,
the quit option will only be "Quit to Xochitl".
Otherwise it will only be "Quit".

This will improve compatibility with launchers,
stop needing a cli argument (got removed) and
prevent users from messing stuff up when using
the wrong "Quit ..." option.
  • Loading branch information
LinusCDE committed Dec 25, 2020
1 parent 7f6a87a commit aa8c319
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 135 deletions.
112 changes: 0 additions & 112 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ fxhash = "0.2.1"
rand_core = "0.5.1"
rand_xoshiro = "0.4.0"
mmap = "0.1.1"
clap = "3.0.0-beta.1"

[dependencies.getopts]
version = "0.2.21"
Expand Down
2 changes: 1 addition & 1 deletion contrib/plato.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ cd "$WORKDIR" || exit 1
export PRODUCT=remarkable
export LD_LIBRARY_PATH=./libs

./plato $@ --spare-xochitl
./plato
25 changes: 5 additions & 20 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use std::sync::mpsc::{self, Receiver, Sender};
use std::collections::{BTreeMap, VecDeque};
use std::time::{Duration, Instant};
use anyhow::{Error, Context as ResultExt, format_err};
use clap::{Clap, crate_version, crate_authors};
use fxhash::FxHashMap;
use chrono::Local;
use globset::Glob;
Expand Down Expand Up @@ -63,18 +62,6 @@ const AUTO_SUSPEND_REFRESH_INTERVAL: Duration = Duration::from_secs(60);
const SUSPEND_WAIT_DELAY: Duration = Duration::from_secs(15);
const PREPARE_SUSPEND_WAIT_DELAY: Duration = Duration::from_secs(3);

#[derive(Clap)]
#[clap(version = crate_version!(), author = crate_authors!())]
struct Opts {
#[clap(long, short, about = "Don't stop xochitl service when a xochitl process is found.")]
spare_xochitl: bool,
}

lazy_static! {
static ref CLI_OPTS: Opts = Opts::parse();
}


pub struct Context {
pub fb: Box<dyn Framebuffer>,
pub rtc: Option<Rtc>,
Expand Down Expand Up @@ -462,13 +449,11 @@ pub fn run() -> Result<(), Error> {
schedule_task(TaskId::CheckBattery, Event::CheckBattery,
BATTERY_REFRESH_INTERVAL, &tx, &mut tasks);

if ! CLI_OPTS.spare_xochitl {
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.")
}
if let Ok(status) = Command::new("systemctl").arg("is-active").arg("xochitl.service").stdout(std::process::Stdio::null()).status() {
if status.code().unwrap() == 0 {
Command::new("systemctl").arg("stop").arg("xochitl").status().ok();
context.killed_xochitl = true;
println!("xochitl.service was active and stopped. You may only exit by starting Xochitl again.")
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/view/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,9 @@ pub fn toggle_main_menu(view: &mut dyn View, rect: Rectangle, enable: Option<boo
entries.push(EntryKind::SubMenu("System".to_string(), system_entries));
if ! context.killed_xochitl {
entries.push(EntryKind::Command("Quit".to_string(), EntryId::Quit));
}else {
entries.push(EntryKind::Command("Quit to Xochitl".to_string(), EntryId::QuitToXochitl));
}
entries.push(EntryKind::Command("Quit to Xochitl".to_string(), EntryId::QuitToXochitl));
}


Expand Down

0 comments on commit aa8c319

Please sign in to comment.