diff --git a/Cargo.lock b/Cargo.lock index 5da3e8f..5462cf9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3445,7 +3445,7 @@ dependencies = [ [[package]] name = "solar-screen-brightness" -version = "2.3.0" +version = "2.3.1" dependencies = [ "anyhow", "brightness", diff --git a/Cargo.toml b/Cargo.toml index 8cdcf7f..a8cc5b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solar-screen-brightness" -version = "2.3.0" +version = "2.3.1" authors = ["Jacob Halsey "] edition = "2021" build = "build.rs" diff --git a/src/config.rs b/src/config.rs index 5d42472..586eb35 100644 --- a/src/config.rs +++ b/src/config.rs @@ -78,10 +78,7 @@ pub struct BrightnessValues { impl SsbConfig { pub fn load(path_override: Option) -> anyhow::Result> { - let path = match path_override { - None => get_default_config_path(), - Some(p) => p, - }; + let path = path_override.unwrap_or_else(get_default_config_path); if !path.exists() { return Ok(None); } @@ -100,7 +97,8 @@ impl SsbConfig { pub fn save(&self) -> anyhow::Result<()> { let path = get_default_config_path(); let serialised = serde_json::to_string_pretty(&self).unwrap(); - let mut temp_file = NamedTempFile::new()?; + let parent = path.parent().expect("config path must have parent"); + let mut temp_file = NamedTempFile::new_in(parent)?; temp_file.write_all(serialised.as_bytes())?; temp_file.flush()?; temp_file.persist(&path)?; diff --git a/src/unique/windows.rs b/src/unique/windows.rs index f4c3ddf..04be163 100644 --- a/src/unique/windows.rs +++ b/src/unique/windows.rs @@ -4,6 +4,7 @@ use windows::Win32::UI::WindowsAndMessaging::{SendMessageW, HWND_BROADCAST}; const APP_ID: &str = "solar-screen-brightness"; +#[allow(dead_code)] pub struct SsbUniqueInstance(UniqueInstance); impl SsbUniqueInstance {