@@ -3,7 +3,7 @@ use colored::Colorize;
33use ctrlc;
44use expression:: backends:: get_backend;
55use expression:: config:: { get_group_config, Config , GroupSelectionStrategy } ;
6- use expression:: utils:: { calc, logger, wallpaper} ;
6+ use expression:: utils:: { calc, cmd , logger, wallpaper} ;
77use log2:: { debug, error, info, warn} ;
88use std:: process;
99use std:: sync:: atomic:: { AtomicBool , Ordering } ;
@@ -39,6 +39,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
3939 let config_special_entries = config. special_entries ;
4040 let config_special_enabled = config. general . enable_special ;
4141 let mut config_group_selection = config. general . group_selection_strategy ;
42+ let exec_cmd = config. general . execute_on_change ;
4243
4344 let mut selected_item = Vec :: new ( ) ;
4445
@@ -232,13 +233,18 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
232233 ) ;
233234 }
234235
235- // REFRESH
236+ // REFRESH LOOP
236237 match refresh_strategy {
237- RefreshStrategy :: Sleep => {
238- calc:: sleep ( wait_seconds) ;
239- }
240- RefreshStrategy :: Log2Sleep => {
241- calc:: refresh_tlog2 ( interval, now, wait_seconds) ;
238+ RefreshStrategy :: Sleep => calc:: sleep ( wait_seconds) ,
239+ RefreshStrategy :: Log2Sleep => calc:: refresh_tlog2 ( interval, now, wait_seconds) ,
240+ }
241+
242+ // EXECUTE SCRIPT
243+ if exec_cmd. is_some ( ) {
244+ let result = cmd:: execute ( exec_cmd. as_ref ( ) . unwrap ( ) ) ;
245+ match result {
246+ Ok ( _) => { }
247+ Err ( err) => error ! ( "Error executing command: {}" , err) ,
242248 }
243249 }
244250 }
0 commit comments