Support --no-daemon flag to prevent daemonizing
This commit is contained in:
parent
738e6eeb7b
commit
8885d295bb
1 changed files with 17 additions and 11 deletions
28
src/lib.rs
28
src/lib.rs
|
|
@ -82,25 +82,19 @@ pub fn desktop() -> Result<(), Box<dyn std::error::Error>> {
|
|||
/// Runs application with these settings
|
||||
#[rustfmt::skip]
|
||||
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
#[cfg(all(unix, not(target_os = "redox")))]
|
||||
match fork::daemon(true, true) {
|
||||
Ok(fork::Fork::Child) => (),
|
||||
Ok(fork::Fork::Parent(_child_pid)) => process::exit(0),
|
||||
Err(err) => {
|
||||
eprintln!("failed to daemonize: {:?}", err);
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")).init();
|
||||
|
||||
localize::localize();
|
||||
|
||||
let (config_handler, config) = Config::load();
|
||||
|
||||
let mut daemonize = true;
|
||||
let mut locations = Vec::new();
|
||||
for arg in env::args().skip(1) {
|
||||
let location = if &arg == "--trash" {
|
||||
let location = if &arg == "--no-daemon" {
|
||||
daemonize = false;
|
||||
continue;
|
||||
} else if &arg == "--trash" {
|
||||
Location::Trash
|
||||
} else {
|
||||
match fs::canonicalize(&arg) {
|
||||
|
|
@ -114,6 +108,18 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
locations.push(location);
|
||||
}
|
||||
|
||||
if daemonize {
|
||||
#[cfg(all(unix, not(target_os = "redox")))]
|
||||
match fork::daemon(true, true) {
|
||||
Ok(fork::Fork::Child) => (),
|
||||
Ok(fork::Fork::Parent(_child_pid)) => process::exit(0),
|
||||
Err(err) => {
|
||||
eprintln!("failed to daemonize: {:?}", err);
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut settings = Settings::default();
|
||||
settings = settings.theme(config.app_theme.theme());
|
||||
settings = settings.size_limits(Limits::NONE.min_width(360.0).min_height(180.0));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue