@@ -45,6 +45,7 @@ use yuck::{
4545pub enum DaemonCommand {
4646 NoOp ,
4747 UpdateVars ( Vec < ( VarName , DynVal ) > ) ,
48+ PollVars ( Vec < VarName > ) ,
4849 ReloadConfigAndCss ( DaemonResponseSender ) ,
4950 OpenInspector ,
5051 OpenMany {
@@ -167,6 +168,11 @@ impl<B: DisplayBackend> App<B> {
167168 self . update_global_variable ( var_name, new_value) ;
168169 }
169170 }
171+ DaemonCommand :: PollVars ( names) => {
172+ for var_name in names {
173+ self . force_poll_variable ( var_name) ;
174+ }
175+ }
170176 DaemonCommand :: ReloadConfigAndCss ( sender) => {
171177 let mut errors = Vec :: new ( ) ;
172178
@@ -336,6 +342,23 @@ impl<B: DisplayBackend> App<B> {
336342 }
337343 }
338344
345+ fn force_poll_variable ( & mut self , name : VarName ) {
346+ match self . eww_config . get_script_var ( & name) {
347+ Err ( err) => error_handling_ctx:: print_error ( err) ,
348+ Ok ( var) => {
349+ if let ScriptVarDefinition :: Poll ( poll_var) = var {
350+ log:: debug!( "force-polling var {}" , & name) ;
351+ match script_var_handler:: run_poll_once ( & poll_var) {
352+ Err ( err) => error_handling_ctx:: print_error ( err) ,
353+ Ok ( value) => self . update_global_variable ( name, value) ,
354+ }
355+ } else {
356+ error_handling_ctx:: print_error ( anyhow ! ( "Script var '{}' is not polling" , name) )
357+ }
358+ }
359+ }
360+ }
361+
339362 /// Close a window and do all the required cleanups in the scope_graph and script_var_handler
340363 fn close_window ( & mut self , instance_id : & str ) -> Result < ( ) > {
341364 if let Some ( old_abort_send) = self . window_close_timer_abort_senders . remove ( instance_id) {
0 commit comments