From 0e3079a6f8511d914a37f1193cb1a2900f26da0a Mon Sep 17 00:00:00 2001 From: uttarayan21 Date: Sat, 16 Aug 2025 20:11:20 +0530 Subject: [PATCH] fix: Added fix for nix build --- src/lib.rs | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e587de5..65d83b8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -211,26 +211,24 @@ pub async fn execute_dpms_command( } } - // Parse the command for hyprland dispatch - let dispatch_type = match action { - "on" => { - if let Some(monitor_name) = monitor { - DispatchType::Custom("dpms", &format!("on {}", monitor_name)) - } else { - DispatchType::Custom("dpms", "on") - } + // Execute the command via hyprland dispatch + match (action, monitor) { + ("on", Some(monitor_name)) => { + let command_str = format!("on {}", monitor_name); + Dispatch::call(DispatchType::Custom("dpms", &command_str))?; } - "off" => { - if let Some(monitor_name) = monitor { - DispatchType::Custom("dpms", &format!("off {}", monitor_name)) - } else { - DispatchType::Custom("dpms", "off") - } + ("on", None) => { + Dispatch::call(DispatchType::Custom("dpms", "on"))?; + } + ("off", Some(monitor_name)) => { + let command_str = format!("off {}", monitor_name); + Dispatch::call(DispatchType::Custom("dpms", &command_str))?; + } + ("off", None) => { + Dispatch::call(DispatchType::Custom("dpms", "off"))?; } _ => return Err("Invalid action".into()), }; - - Dispatch::call(dispatch_type)?; Ok(()) }