feat: add daemonize to fork off
parent
b53689584a
commit
0727b3e053
|
@ -345,6 +345,15 @@ dependencies = [
|
||||||
"typenum",
|
"typenum",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "daemonize"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ab8bfdaacb3c887a54d41bdf48d3af8873b3f5566469f8ba21b92057509f116e"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "derivative"
|
name = "derivative"
|
||||||
version = "2.2.0"
|
version = "2.2.0"
|
||||||
|
@ -1123,6 +1132,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
|
"daemonize",
|
||||||
"humantime",
|
"humantime",
|
||||||
"notify-rust",
|
"notify-rust",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
|
@ -8,6 +8,7 @@ edition = "2021"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.71"
|
anyhow = "1.0.71"
|
||||||
clap = { version = "4.3.4", features = ["derive"] }
|
clap = { version = "4.3.4", features = ["derive"] }
|
||||||
|
daemonize = "0.5.0"
|
||||||
humantime = "2.1.0"
|
humantime = "2.1.0"
|
||||||
notify-rust = "4.8.0"
|
notify-rust = "4.8.0"
|
||||||
serde = { version = "1.0.164", features = ["derive"] }
|
serde = { version = "1.0.164", features = ["derive"] }
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
mod cli;
|
mod cli;
|
||||||
mod daemon;
|
mod daemon;
|
||||||
|
mod notification;
|
||||||
mod pomodoro;
|
mod pomodoro;
|
||||||
mod timer;
|
mod timer;
|
||||||
mod notification;
|
|
||||||
|
|
||||||
use crate::cli::{send_command, Cli, Command as CliCommand};
|
use crate::cli::{send_command, Cli, Command as CliCommand};
|
||||||
use crate::daemon::{Command as DaemonCommand, Daemon};
|
use crate::daemon::{Command as DaemonCommand, Daemon};
|
||||||
|
@ -12,7 +12,10 @@ use cli::PomodoroCommand;
|
||||||
fn main() -> Result<(), anyhow::Error> {
|
fn main() -> Result<(), anyhow::Error> {
|
||||||
let args = Cli::parse();
|
let args = Cli::parse();
|
||||||
let daemon_command = match args.command {
|
let daemon_command = match args.command {
|
||||||
CliCommand::Daemon { no_notify } => return Daemon::new(args.socket, no_notify)?.run(),
|
CliCommand::Daemon { no_notify } => {
|
||||||
|
daemonize::Daemonize::new().start()?;
|
||||||
|
return Daemon::new(args.socket, no_notify)?.run();
|
||||||
|
}
|
||||||
CliCommand::Add { name, duration } => {
|
CliCommand::Add { name, duration } => {
|
||||||
DaemonCommand::Add(name.into_boxed_str(), duration.into())
|
DaemonCommand::Add(name.into_boxed_str(), duration.into())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue