diff --git a/.gitignore b/.gitignore index a853f47..fd726ce 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk + +#CLion stuff +**/.idea/ \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index f9b20af..b3365f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,10 +17,11 @@ colored = "2.0.0" rpassword = "6.0.1" git-version = "0.3.5" # ughh just for git hash const_format = "0.2.22" # ughh just for git hash -libnotify = "1.0.3" +notify-rust = "4" uuid = { version = "0.8.2", features = ["v4"] } clap = { version = "3.1.6", features = ["derive"] } -rusqlite = { version="0.27.0", features=["chrono", "backup"] } +rusqlite = { version="0.27.0", features=["bundled-sqlcipher", "chrono", "backup"] } +dirs = "4.0.0" # cross-platform paths ureq = { version="2.4.0", features=["json"] } [profile.release] diff --git a/src/main.rs b/src/main.rs index ad18438..187eb9c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,6 +11,7 @@ use regex::Regex; use storage::{open_sqlite_storage, Memo, MemoStorage, AuthStorage, StateStorage, SQLiteStorage}; use utils::{find_by_regex, parse_human_duration, HumanDisplay}; use remote::RemoteSync; +use notify_rust::Notification; const GIT_VERSION: &str = git_version!(); const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -65,14 +66,16 @@ enum Commands { fn main() { let args = Cli::parse(); - let home_path = std::env!("HOME").to_string(); - let mut db_path: String = home_path + "/.local/share/memo-cli.db"; + //let home_path = std::env!("HOME").to_string(); //this is linux-only + let mut db_path: std::path::PathBuf = dirs::home_dir().unwrap(); + db_path.push(".local/share/memo-cli.db"); //+ "/.local/share/memo-cli.db"; + //WARNING: this is only for testing, it has no proper error handling and will panic is HOME is invalid or None if let Some(db) = args.path { - db_path = db; + db_path = std::path::PathBuf::from(db); } - let storage = open_sqlite_storage(&db_path, true).unwrap(); + let storage = open_sqlite_storage(db_path.to_str().unwrap(), true).unwrap(); if args.sync { if storage.get_key().is_err() { @@ -170,14 +173,11 @@ fn main() { builder.push('\n'); } if args.notify { - libnotify::init("memo-cli").unwrap(); - let n = libnotify::Notification::new( - format!("memo-cli | {}", timing).as_str(), - Some(builder.as_str()), - None, - ); - n.show().unwrap(); - libnotify::uninit(); + Notification::new() + .summary(format!("memo-cli | {}", timing).as_str()) + .body(builder.as_str()) + //.icon("") //soon... + .show(); } else { println!("{} | {}", "memo-cli".bold(), timing); print!("{}", builder);