diff --git a/features/actions/execute.feature b/features/actions/execute.feature new file mode 100644 index 0000000..f7e54a6 --- /dev/null +++ b/features/actions/execute.feature @@ -0,0 +1,9 @@ +Feature: `execute' action keyword + + Scenario: executes the given command in a shell with current standard output + Given uhwm is running with this run control file: + """ + key(:f) { execute 'echo etucexe_tset | rev' } + """ + When I press the alt+f keys + Then the output must contain "test_execute" diff --git a/lib/uh/wm/actions_handler.rb b/lib/uh/wm/actions_handler.rb index 904a33e..bd3916d 100644 --- a/lib/uh/wm/actions_handler.rb +++ b/lib/uh/wm/actions_handler.rb @@ -12,6 +12,21 @@ module Uh def quit @events.emit :quit end + + def execute command + @env.log "Execute: #{command}" + pid = fork do + fork do + Process.setsid + begin + exec command + rescue Errno::ENOENT => e + @env.log_error "ExecuteError: #{e}" + end + end + end + Process.waitpid pid + end end end end