From 5ab463cde56d016b77e9f12eb8760223260a9423 Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Fri, 17 Apr 2015 20:20:18 +0000 Subject: [PATCH] Allow worker configuration with run control file --- features/run_control/worker.feature | 9 +++++++++ lib/uh/wm/run_control.rb | 4 ++++ spec/uh/wm/run_control_spec.rb | 12 ++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 features/run_control/worker.feature diff --git a/features/run_control/worker.feature b/features/run_control/worker.feature new file mode 100644 index 0000000..a586c5a --- /dev/null +++ b/features/run_control/worker.feature @@ -0,0 +1,9 @@ +Feature: `worker' run control keyword + + Scenario: configures the modifier key + Given a run control file with: + """ + worker :mux + """ + And I start uhwm + Then the output must match /work.+event.+mux/i diff --git a/lib/uh/wm/run_control.rb b/lib/uh/wm/run_control.rb index 2d511be..b3fc618 100644 --- a/lib/uh/wm/run_control.rb +++ b/lib/uh/wm/run_control.rb @@ -32,6 +32,10 @@ module Uh @env.keybinds[translate_keysym keysym] = block end + def worker type, **options + @env.worker = [type, options] + end + private diff --git a/spec/uh/wm/run_control_spec.rb b/spec/uh/wm/run_control_spec.rb index 7684b8e..1afca27 100644 --- a/spec/uh/wm/run_control_spec.rb +++ b/spec/uh/wm/run_control_spec.rb @@ -80,6 +80,18 @@ module Uh expect(env.keybinds.keys).to include %i[f shift] end end + + describe '#worker' do + it 'sets the worker type in the env' do + rc.worker :some_worker + expect(env.worker[0]).to eq :some_worker + end + + it 'sets the worker options in the env' do + rc.worker :some_worker, some: :option + expect(env.worker[1]).to eq({ some: :option }) + end + end end end end