class Mani::X

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

Public Class Methods

new() click to toggle source

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

# File lib/mani/x.rb, line 7
def initialize
  @xdo = XDo.new
end

Public Instance Methods

focus_window(pid) click to toggle source

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

@param [Fixnum] pid The pid

# File lib/mani/x.rb, line 14
def focus_window(pid)
  @xdo.find_windows(pid: pid, visible: true).first.focus
end
type_combination(combination) click to toggle source

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

@param [String] combination The combination

# 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) click to toggle source

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

@param [String] sequence The sequence

# File lib/mani/x.rb, line 37
def type_keysequence(sequence)
  @xdo.keyboard.type_keysequence sequence
end
type_string(string) click to toggle source

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

@param [String] string The string

# File lib/mani/x.rb, line 44
def type_string(string)
  @xdo.keyboard.type_string string
end