Skip to content

Commit

Permalink
work without DISPLAY and fix some error logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Crisci committed Feb 16, 2019
1 parent 4a2d2ba commit 58b01f1
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mod writer;
include!(concat!(env!("OUT_DIR"), "/data.rs"));

fn exit_error(msg: &str) {
writeln!(&mut std::io::stderr(), "{}", msg);
writeln!(&mut std::io::stderr(), "{}", msg).unwrap();
process::exit(1);
}

Expand Down Expand Up @@ -82,7 +82,7 @@ fn validate_config_or_exit(path: &String) {
&mut std::io::stderr(),
"Could not validate config.\nUse `i3 -C -c {}` to see validation errors.",
path
);
).unwrap();
process::exit(1);
}
}
Expand Down Expand Up @@ -298,7 +298,7 @@ fn main() {
"saving config at {} to {}",
&config,
&tmp_input
);
).unwrap();
fs::copy(&config, &tmp_input).unwrap();
// 3. copy the new config to the config location
fs::copy(&tmp_output, output).unwrap();
Expand All @@ -323,10 +323,11 @@ fn main() {
&mut std::io::stderr(),
"Could not reload config with swaymsg: {}",
err
);
).unwrap();
process::exit(1);
}
}
} else if env::var_os("DISPLAY").is_some() {
} else {
let cmd = Command::new("i3-msg")
.arg("reload")
.stdout(Stdio::null())
Expand All @@ -342,14 +343,10 @@ fn main() {
&mut std::io::stderr(),
"Could not reload config with i3-msg: {}",
err
);
).unwrap();
process::exit(1);
}
}
} else {
writeln!(
&mut std::io::stderr(),
"Could not reload config: no display environment variable set."
);
}
}
}

0 comments on commit 58b01f1

Please sign in to comment.