From 8a6a5761935bfd29f3e3e6cb0bcd136754fc9bb8 Mon Sep 17 00:00:00 2001 From: oiupoyt Date: Tue, 1 Sep 2026 22:37:51 +0530 Subject: [PATCH] feat: Support CLI arguments for bypassing global hotkeys on Wayland --- scratch/ui_cli.patch | 21 +++++++++++++++++++++ src/bin/vrec-ui.rs | 16 +++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 scratch/ui_cli.patch diff --git a/scratch/ui_cli.patch b/scratch/ui_cli.patch new file mode 100644 index 0000000..7a37820 --- /dev/null +++ b/scratch/ui_cli.patch @@ -0,0 +1,21 @@ +--- src/bin/vrec-ui.rs ++++ src/bin/vrec-ui.rs +@@ -16,6 +16,19 @@ + } + + fn main() -> Result<(), Box> { ++ let args: Vec = env::args().collect(); ++ if args.len() > 1 { ++ match args[1].as_str() { ++ "--save" => { ++ return send_command(Command::SaveReplay).map_err(|e| e.into()); ++ } ++ "--menu" => { ++ vrec::overlay::show_saved_overlay(); ++ return Ok(()); ++ } ++ _ => {} ++ } ++ } ++ + println!("Starting vrec UI/Hotkey process..."); diff --git a/src/bin/vrec-ui.rs b/src/bin/vrec-ui.rs index b9f6972..361b4f1 100644 --- a/src/bin/vrec-ui.rs +++ b/src/bin/vrec-ui.rs @@ -4,7 +4,7 @@ use std::io::Write; use std::env; use global_hotkey::{GlobalHotKeyManager, hotkey::{HotKey, Modifiers, Code}, GlobalHotKeyEvent}; -fn send_command(cmd: Command) -> Result<(), Box> { +fn send_command(cmd: Command) -> Result<(), Box> { let socket_path = format!("{}/vrec.sock", env::var("XDG_RUNTIME_DIR").unwrap_or_else(|_| "/tmp".to_string())); let mut stream = UnixStream::connect(&socket_path)?; let payload = serde_json::to_vec(&cmd)?; @@ -15,6 +15,20 @@ fn send_command(cmd: Command) -> Result<(), Box> { } fn main() -> Result<(), Box> { + let args: Vec = env::args().collect(); + if args.len() > 1 { + match args[1].as_str() { + "--save" => { + return send_command(Command::SaveReplay).map_err(|e| e.into()); + } + "--menu" => { + vrec::overlay::show_saved_overlay(); + return Ok(()); + } + _ => {} + } + } + println!("Starting vrec UI/Hotkey process..."); let session_type = env::var("XDG_SESSION_TYPE").unwrap_or_else(|_| "x11".to_string());