feat: Support CLI arguments for bypassing global hotkeys on Wayland
This commit is contained in:
parent
755542f423
commit
8a6a576193
2 changed files with 36 additions and 1 deletions
21
scratch/ui_cli.patch
Normal file
21
scratch/ui_cli.patch
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
--- src/bin/vrec-ui.rs
|
||||
+++ src/bin/vrec-ui.rs
|
||||
@@ -16,6 +16,19 @@
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
+ let args: Vec<String> = 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...");
|
||||
|
|
@ -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<dyn std::error::Error>> {
|
||||
fn send_command(cmd: Command) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
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<dyn std::error::Error>> {
|
|||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
let args: Vec<String> = 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());
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue