restart listener when config changes

This commit is contained in:
jfmonty2 committed 2023-04-28 14:33:04 -07:00
1 parent 33a5600a30
commit 70d71ce14e
6 files changed
+171 -74

No files matched your search

+7 -6
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(())