Class: Terminitor::KonsoleCore

Inherits:
AbstractCore show all
Defined in:
lib/terminitor/cores/konsole_core.rb

Overview

KDE Konsole Core for Terminitor This Core manages all the interaction with Konsole’s dbus interface

Instance Attribute Summary

Attributes inherited from AbstractCore

#termfile, #terminal, #windows, #working_dir

Instance Method Summary collapse

Methods inherited from AbstractCore

#active_window, #load_termfile, #process!, #run_in_window, #set_delayed_options, #setup!

Constructor Details

#initialize(path) ⇒ KonsoleCore

Returns a new instance of KonsoleCore.



5
6
7
8
9
10
# File 'lib/terminitor/cores/konsole_core.rb', line 5

def initialize(path)
  super
  bus = DBus::SessionBus.instance
  @konsole_service = bus.service("org.kde.konsole")
  @konsole = get_konsole
end

Instance Method Details

#execute_command(cmd, options = {}) ⇒ Object

Executes the Command execute_command ‘cd /path/to’, {}



14
15
16
17
18
# File 'lib/terminitor/cores/konsole_core.rb', line 14

def execute_command(cmd, options = {})
  # add carriange return if missing, otherwise the command won't be executed
  cmd += "\n" if (cmd =~ /\n\Z/).nil?
  options[:in].sendText(cmd)
end

#open_tab(options = nil) ⇒ Object

Opens a new tab and returns itself.



21
22
23
24
25
26
# File 'lib/terminitor/cores/konsole_core.rb', line 21

def open_tab(options = nil)
  session_number = @konsole.newSession
  session_object = @konsole_service.object("/Sessions/#{session_number}")
  session_object.introspect
  session_object["org.kde.konsole.Session"]
end

#open_window(options = nil) ⇒ Object

Opens a new window and returns the tab object.



29
30
31
32
33
34
# File 'lib/terminitor/cores/konsole_core.rb', line 29

def open_window(options = nil)
  session_number = @konsole.currentSession
  session_object = @konsole_service.object("/Sessions/#{session_number}")
  session_object.introspect
  session_object["org.kde.konsole.Session"]
end