diff --git a/crates/eww/src/config/script_var.rs b/crates/eww/src/config/script_var.rs index 46db670..da44b43 100644 --- a/crates/eww/src/config/script_var.rs +++ b/crates/eww/src/config/script_var.rs @@ -30,7 +30,7 @@ pub fn initial_value(var: &ScriptVarDefinition) -> Result { run_command(command).map_err(|e| anyhow!(create_script_var_failed_warn(*span, var.name(), &e.to_string()))) } }, - ScriptVarDefinition::Listen(_) => Ok(DynVal::from_string(String::new())), + ScriptVarDefinition::Listen(var) => Ok(var.initial_value.clone()), } } diff --git a/crates/eww/src/script_var_handler.rs b/crates/eww/src/script_var_handler.rs index 8fc2202..2ebfc31 100644 --- a/crates/eww/src/script_var_handler.rs +++ b/crates/eww/src/script_var_handler.rs @@ -196,13 +196,13 @@ impl ListenVarHandler { } async fn start(&mut self, var: ListenScriptVar) { - log::debug!("starting poll var {}", &var.name); + log::debug!("starting listen-var {}", &var.name); let cancellation_token = CancellationToken::new(); self.listen_process_handles.insert(var.name.clone(), cancellation_token.clone()); let evt_send = self.evt_send.clone(); tokio::spawn(async move { - crate::try_logging_errors!(format!("Executing tail var command {}", &var.command) => { + crate::try_logging_errors!(format!("Executing listen var-command {}", &var.command) => { let mut handle = tokio::process::Command::new("sh") .args(&["-c", &var.command]) .stdout(std::process::Stdio::piped()) diff --git a/crates/eww/src/widgets/widget_definitions.rs b/crates/eww/src/widgets/widget_definitions.rs index b67bd04..dd3d9b4 100644 --- a/crates/eww/src/widgets/widget_definitions.rs +++ b/crates/eww/src/widgets/widget_definitions.rs @@ -83,6 +83,10 @@ pub(super) fn resolve_widget_attrs(bargs: &mut BuilderArgs, gtk_widget: >k::Wi prop(valign: as_string) { gtk_widget.set_valign(parse_align(&valign)?) }, // @prop halign - how to align this horizontally. possible values: $alignment prop(halign: as_string) { gtk_widget.set_halign(parse_align(&halign)?) }, + // @prop vexpand - should this container expand vertically. Default: false. + prop(vexpand: as_bool = false) { gtk_widget.set_vexpand(vexpand) }, + // @prop hexpand - should this widget expand horizontally. Default: false. + prop(hexpand: as_bool = false) { gtk_widget.set_hexpand(hexpand) }, // @prop width - width of this element. note that this can not restrict the size if the contents stretch it prop(width: as_f64) { gtk_widget.set_size_request(width as i32, gtk_widget.get_allocated_height()) }, // @prop height - height of this element. note that this can not restrict the size if the contents stretch it @@ -158,13 +162,8 @@ pub(super) fn resolve_widget_attrs(bargs: &mut BuilderArgs, gtk_widget: >k::Wi } /// @widget !container -pub(super) fn resolve_container_attrs(bargs: &mut BuilderArgs, gtk_widget: >k::Container) { - resolve_block!(bargs, gtk_widget, { - // @prop vexpand - should this container expand vertically - prop(vexpand: as_bool = false) { gtk_widget.set_vexpand(vexpand) }, - // @prop hexpand - should this container expand horizontally - prop(hexpand: as_bool = false) { gtk_widget.set_hexpand(hexpand) }, - }); +pub(super) fn resolve_container_attrs(_bargs: &mut BuilderArgs, _gtk_widget: >k::Container) { + // resolve_block!(bargs, gtk_widget, {}); } /// @widget !range diff --git a/crates/yuck/src/config/script_var_definition.rs b/crates/yuck/src/config/script_var_definition.rs index bc48e51..79b4fb8 100644 --- a/crates/yuck/src/config/script_var_definition.rs +++ b/crates/yuck/src/config/script_var_definition.rs @@ -85,6 +85,7 @@ impl FromAstElementContent for PollScriptVar { pub struct ListenScriptVar { pub name: VarName, pub command: String, + pub initial_value: DynVal, pub command_span: Span, pub name_span: Span, } @@ -94,10 +95,12 @@ impl FromAstElementContent for ListenScriptVar { fn from_tail>(span: Span, mut iter: AstIterator) -> AstResult { let result: AstResult<_> = try { let (name_span, name) = iter.expect_symbol()?; + let mut attrs = iter.expect_key_values()?; + let initial_value = attrs.primitive_optional("initial")?.unwrap_or_else(|| DynVal::from_string(String::new())); let (command_span, script) = iter.expect_literal()?; iter.expect_done()?; - Self { name_span, name: VarName(name), command: script.to_string(), command_span } + Self { name_span, name: VarName(name), command: script.to_string(), initial_value, command_span } }; - result.note(r#"Expected format: `(deflisten name "tail -f /tmp/example")`"#) + result.note(r#"Expected format: `(deflisten name :initial "0" "tail -f /tmp/example")`"#) } } diff --git a/crates/yuck/src/parser/lexer.rs b/crates/yuck/src/parser/lexer.rs index edfe6e5..8068c7f 100644 --- a/crates/yuck/src/parser/lexer.rs +++ b/crates/yuck/src/parser/lexer.rs @@ -107,7 +107,6 @@ impl Lexer { toks.push((lo, tok, hi)); } Some(Err(err)) => { - dbg!(&simplexpr_lexer); if simplexpr_lexer.continues_with('}') { let start = toks.first().map(|x| x.0).unwrap_or(end); self.pos = end + 1;