Class: Mani::X

Inherits:
Object
  • Object
show all
Defined in:
lib/mani/x.rb

Overview

This class contains methods to interface with the X Window System.

Instance Method Summary collapse

Constructor Details

#initializeX

Initializes XDo to handle the heavy lifting of interfacing with X.



7
8
9
# File 'lib/mani/x.rb', line 7

def initialize
  @xdo = XDo.new
end

Instance Method Details

#focus_window(pid) ⇒ Object

Finds the visible window with the supplied pid and focuses it.

Parameters:

  • pid (Fixnum)

    The pid



14
15
16
# File 'lib/mani/x.rb', line 14

def focus_window(pid)
  @xdo.find_windows(pid: pid, visible: true).first.focus
end

#type_combination(combination) ⇒ Object

Types the supplied combination. Note that any text between ‘and ‘}’ delimiters is treated as a sequence. All other text is treated literally.

Parameters:

  • combination (String)

    The combination



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mani/x.rb', line 22

def type_combination(combination)
  tokens = Mani::Tokenizer.get_tokens combination
  tokens.each do |token|
    case token.first
    when :static
      type_string token.last
    when :sequence
      type_keysequence token.last
    end
  end
end

#type_keysequence(sequence) ⇒ Object

Types the supplied sequence (e.g., ‘ctrl+v’, ‘F6’, ‘alt+2’).

Parameters:

  • sequence (String)

    The sequence



37
38
39
# File 'lib/mani/x.rb', line 37

def type_keysequence(sequence)
  @xdo.keyboard.type_keysequence sequence
end

#type_string(string) ⇒ Object

Types the supplied string. Note that the string is treated literally.

Parameters:

  • string (String)

    The string



44
45
46
# File 'lib/mani/x.rb', line 44

def type_string(string)
  @xdo.keyboard.type_string string
end