From 3d5496d4abb4086cc6f7bc74dcdfcdd6336320ed Mon Sep 17 00:00:00 2001 From: oiupoyt Date: Sun, 6 Sep 2026 07:02:17 +0530 Subject: [PATCH] Enable Win32_Security feature for CreateMutexW and clean up Windows warnings --- Cargo.toml | 1 + src/bin/scythe-daemon.rs | 2 +- src/bin/scythe-ui.rs | 26 ++++++++++++-------------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 66589b9..5054d21 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,6 +46,7 @@ windows = { version = "0.58.0", features = [ "Win32_Graphics_Dxgi", "Win32_Graphics_Dxgi_Common", "Win32_Graphics_Gdi", + "Win32_Security", "Win32_System_Com", "Win32_UI_WindowsAndMessaging", "Win32_System_Threading", diff --git a/src/bin/scythe-daemon.rs b/src/bin/scythe-daemon.rs index 79d13b4..7bf72ab 100644 --- a/src/bin/scythe-daemon.rs +++ b/src/bin/scythe-daemon.rs @@ -122,7 +122,7 @@ async fn main() -> Result<(), Box> { println!("Daemon listening on TCP IPC: 127.0.0.1:42069"); l } - Err(e) => { + Err(_e) => { if scythe::ipc::query_status().is_ok() { println!("Another instance of scythe-daemon is already running. Exiting cleanly."); return Ok(()); diff --git a/src/bin/scythe-ui.rs b/src/bin/scythe-ui.rs index d0abdad..69ad961 100644 --- a/src/bin/scythe-ui.rs +++ b/src/bin/scythe-ui.rs @@ -144,21 +144,19 @@ fn check_and_toggle_overlay() -> bool { } if let Ok(content) = std::fs::read_to_string(&pid_path) { + #[cfg(unix)] if let Ok(pid) = content.trim().parse::() { - #[cfg(unix)] - { - let exists = unsafe { libc::kill(pid, 0) == 0 }; - if exists && pid != std::process::id() as i32 { - let proc_cmd = format!("/proc/{}/cmdline", pid); - let is_scythe = std::fs::read_to_string(&proc_cmd) - .map(|cmd| cmd.contains("scythe") || cmd.contains("vrec")) - .unwrap_or(false); - if is_scythe { - // Overlay already open: toggle it closed instantly! - unsafe { libc::kill(pid, libc::SIGTERM) }; - let _ = std::fs::remove_file(&pid_path); - return true; - } + let exists = unsafe { libc::kill(pid, 0) == 0 }; + if exists && pid != std::process::id() as i32 { + let proc_cmd = format!("/proc/{}/cmdline", pid); + let is_scythe = std::fs::read_to_string(&proc_cmd) + .map(|cmd| cmd.contains("scythe") || cmd.contains("vrec")) + .unwrap_or(false); + if is_scythe { + // Overlay already open: toggle it closed instantly! + unsafe { libc::kill(pid, libc::SIGTERM) }; + let _ = std::fs::remove_file(&pid_path); + return true; } } }