Class: Mani
- Inherits:
-
Object
- Object
- Mani
- Defined in:
- lib/mani.rb,
lib/mani/x.rb,
lib/mani/window.rb,
lib/mani/version.rb,
lib/mani/tokenizer.rb
Overview
The base class.
Defined Under Namespace
Classes: Tokenizer, Version, Window, X
Instance Method Summary collapse
-
#initialize(options = {}, &block) ⇒ Mani
constructor
Initializes the windowing system, as well as the window manager options.
-
#window(name, options = {}, &block) ⇒ Object
Creates a new window object, or defers execution of the supplied block to an existing window object.
-
#workspace(space, &block) ⇒ Object
Switches to the specified workspace.
Constructor Details
#initialize(options = {}, &block) ⇒ Mani
Initializes the windowing system, as well as the window manager options.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/mani.rb', line 15 def initialize( = {}, &block) window_manager = .delete :window_manager case window_manager when :xmonad require 'mani/x' @windowing_system = Mani::X.new @window_manager_options = { switch_to_workspace: ->(space) { "super+#{space}" } }.merge else fail 'Unrecognized :window_manager.' end @windows = {} instance_eval(&block) end |
Instance Method Details
#window(name, options = {}, &block) ⇒ Object
Creates a new window object, or defers execution of the supplied block to an existing window object.
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/mani.rb', line 44 def window(name, = {}, &block) @windows[name] = Window.new @windowing_system unless @windows[name] program = .delete :launch if program @windows[name].launch program, , &block else @windows[name].instance_eval(&block) end end |
#workspace(space, &block) ⇒ Object
Switches to the specified workspace.
59 60 61 62 63 64 |
# File 'lib/mani.rb', line 59 def workspace(space, &block) sequence = @window_manager_options[:switch_to_workspace].call space @windowing_system.type_keysequence sequence instance_eval(&block) if block end |