Class: Fusuma::Plugin::Executors::WmctrlExecutor::Workspace

Inherits:
Object
  • Object
show all
Defined in:
lib/fusuma/plugin/executors/wmctrl_executor.rb

Overview

Manage workspace

Class Method Summary collapse

Class Method Details

.current_workspace_numInteger

get workspace number

Returns:

  • (Integer)


70
71
72
73
# File 'lib/fusuma/plugin/executors/wmctrl_executor.rb', line 70

def current_workspace_num
  text = `wmctrl -d`.split("\n").grep(/\*/).first
  text.chars.first.to_i
end

.move_command(direction:) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/fusuma/plugin/executors/wmctrl_executor.rb', line 75

def move_command(direction:)
  workspace_num = case direction
                  when 'next'
                    current_workspace_num + 1
                  when 'prev'
                    current_workspace_num - 1
                  else
                    warn "#{direction} is invalid key"
                    exit 1
                  end
  "wmctrl -s #{workspace_num}"
end