restart listener when config changes
This commit is contained in:
@ -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(())
|
||||
|
Reference in New Issue
Block a user