qterminal icon indicating copy to clipboard operation
qterminal copied to clipboard

[QUESTION] Is it possible to create a few instances of qterm with some tabs in each?

Open Axisar opened this issue 3 years ago • 1 comments

Hello there. Is it possible to create a few instances of qterm with some tabs in each instance with executed command in each with changing location before execute using bash script of bash oneliner like: qterminal -tab0 -w /somelocation -e somecommand -tab1 -w /somelocation1 -e somecommand1 and etc?

Axisar avatar Apr 07 '21 19:04 Axisar

It is possible, but quite difficult. DBus APIs are needed. Here is an example in Python:

import subprocess

from pydbus import SessionBus
from gi.repository.GLib import Variant

proc = subprocess.Popen(['qterminal'])
dest = 'org.lxqt.QTerminal-' + str(proc.pid)

subprocess.check_call(['gdbus', 'wait', '--session', dest])

bus = SessionBus()
process = bus.get(dest, '/')['org.lxqt.QTerminal.Process']
current_window = process.getWindows()[0]

window = bus.get(dest, current_window)['org.lxqt.QTerminal.Window']
current_tab = window.getTabs()[0]
window.newTab({'shell': Variant('s', '/usr/bin/python')})
window.newTab({'shell': Variant('s', '/bin/bash')})
tab = bus.get(dest, current_tab)['org.lxqt.QTerminal.Tab']
tab.closeTab()

proc.wait()

To make things worse, there are currently no documents about DBus APIs. One needs to read src/org.lxqt.QTerminal.*.xml files to see what APIs are available - and maybe even C++ sources to understand actual functionality of those APIs. Many things can be improved, so I keep this issue open as a reminder.

yan12125 avatar May 02 '21 16:05 yan12125