diff --git a/wayvr/src/gui/README.md b/wayvr/src/gui/README.md index 463e2cf..9c3bb44 100644 --- a/wayvr/src/gui/README.md +++ b/wayvr/src/gui/README.md @@ -80,22 +80,40 @@ This button action executes a shell script using the `sh` shell. + +``` + +```xml + + + +``` + +The two can be combined; parameter-form arguments will be appended after shorthand-form arguments: +```xml + + + ``` Available argument value types (case insensitive): - Bool: `true` or `false` - Nil: `nil` - Inf: `inf` -- Int: `-1i32`, `1i32`, etc -- Long: `-1i64`, `1i64`, etc -- Float: `1f32`, `1.0f32`, etc -- Double: `1f64`, `1.0f64`, etc +- Int: suffix `i32` (`-1i32`, `1i32`, etc) +- Long: suffix `i64` (`-1i64`, `1i64`, etc) +- Float: suffix `f32` (`1f32`, `1.0f32`, etc) +- Double: suffix `f64` (`1f64`, `1.0f64`, etc) +- String: any other value + - Shorthand form will treat Strings with spaces as multiple arguments. Use parameter form if you need spaces. ##### `::SendKey ` diff --git a/wayvr/src/gui/panel/button.rs b/wayvr/src/gui/panel/button.rs index 67a7819..2453a58 100644 --- a/wayvr/src/gui/panel/button.rs +++ b/wayvr/src/gui/panel/button.rs @@ -692,15 +692,28 @@ pub(super) fn setup_custom_button( }; let mut osc_args = vec![]; + + // collect arguments specified in the initial string for arg in args { - let Ok(osc_arg) = parse_osc_value(arg) - .inspect_err(|e| log::warn!("Could not parse OSC value '{arg}': {e:?}")) - else { - let msg = format!("expected OscValue, found \"{arg}\""); + if let Ok(osc_arg) = parse_osc_value(arg).inspect_err(|e| { + let msg = format!("Could not parse OSC value \"{arg}\": {e:?}"); log_cmd_invalid_arg(parser_state, TAG, name, command, &msg); return; - }; + }) { + osc_args.push(osc_arg); + } + } + + // collect arguments from _arg attributes. + let mut arg_index = 0; + while let Some(arg) = attribs.get_value(&format!("_arg{arg_index}")) + && let Ok(osc_arg) = parse_osc_value(arg).inspect_err(|e| { + let msg = format!("Could not parse OSC value \"{arg}\": {e:?}"); + log_cmd_invalid_arg(parser_state, TAG, name, command, &msg); + }) + { osc_args.push(osc_arg); + arg_index += 1; } Box::new(move |_common, data, app, _| { diff --git a/wayvr/src/subsystem/osc.rs b/wayvr/src/subsystem/osc.rs index c73fe87..0a1f26b 100644 --- a/wayvr/src/subsystem/osc.rs +++ b/wayvr/src/subsystem/osc.rs @@ -243,7 +243,7 @@ pub fn parse_osc_value(s: &str) -> anyhow::Result { } } - anyhow::bail!("Unknown OSC type literal: {s}") + Ok(OscType::String(s.to_string())) } } }