|
|
@ -1,5 +1,6 @@ |
|
|
|
use chrono::prelude::*;
|
|
|
|
use chrono::Duration;
|
|
|
|
use std::io::Error;
|
|
|
|
use std::io::{stdout, Result, StdoutLock, Write};
|
|
|
|
use std::process::{Command, Output};
|
|
|
|
use std::thread::sleep;
|
|
|
@ -10,10 +11,28 @@ fn main() { |
|
|
|
run().unwrap();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Check if kdialog exists. If not, print message and return Err()
|
|
|
|
fn check_deps() -> Result<()> {
|
|
|
|
let cmd = Command::new("sh").arg("-c").arg("kdialog").status()?;
|
|
|
|
if !cmd.success() {
|
|
|
|
println!("Could not find command 'kdialog'. Please install first, then start again");
|
|
|
|
return Err(Error::new(
|
|
|
|
std::io::ErrorKind::Other,
|
|
|
|
"Could not find kdialog",
|
|
|
|
));
|
|
|
|
}
|
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Runs the application
|
|
|
|
///
|
|
|
|
/// Default time settings are 25 minutes for a working block and 5 minutes for a break.
|
|
|
|
fn run() -> Result<()> {
|
|
|
|
if check_deps().is_err() {
|
|
|
|
// terminate gracefully
|
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
|
|
|
|
let work_duration = Duration::seconds(if cfg!(debug_assertions) { 75 } else { 25 * 60 });
|
|
|
|
let break_duration = Duration::seconds(if cfg!(debug_assertions) { 5 } else { 5 * 60 });
|
|
|
|
|
|
|
|