restart listener when config changes

This commit is contained in:
2023-04-28 14:33:04 -07:00
parent 33a5600a30
commit 70d71ce14e
6 changed files with 171 additions and 74 deletions

View File

@ -66,7 +66,7 @@ impl AppConfig {
}
pub fn set_auto_launch(enable: bool) -> Result<(), SetupError> {
pub fn set_auto_launch(is_configured: bool) -> Result<(), SetupError> {
let path_buf = std::env::current_exe()
.map_err(|e| auto_launch::Error::Io(e))?;
let path = path_buf
@ -75,13 +75,14 @@ pub fn set_auto_launch(enable: bool) -> Result<(), SetupError> {
let auto = AutoLaunchBuilder::new()
.set_app_name("Creddy")
.set_app_path(&path)
.build()?;
.build().expect("Failed to build");
if enable {
auto.enable()?;
let is_enabled = auto.is_enabled()?;
if is_configured && !is_enabled {
auto.enable().expect("Failed to enable");
}
else {
auto.disable()?;
else if !is_configured && is_enabled {
auto.disable().expect("Failed to disable");
}
Ok(())