Playing with D-Bus
Nov. 16th, 2011 07:46 pmWaiting on something else to complete, I spent an interesting, if ultimately fruitless, hour investigating whether I could use D-Bus to control the way
Essentially, I want to be able use a menu option to either: (a) open a new konsole window and ssh session to a remote host if no sessions are currently open; or (b) open a new tab in a window associated with a preexisting ssh to a remote host if a session is already open. I'd hoped to do this by writing a script to interface with D-Bus to obtain the PIDs associated with each open konsole window, determine whether the PID refers to a secure shell connection to a remote host, and if it does and the remote host matches the current target, create a new tab in that window using the appropriate profile to run secure shell.
Sadly, I quickly discovered that it wasn't going to be as straightforward as I'd hoped. Firstly it seems that it's hard (not possible?) to make a particular window the target of the
Still, it's not a complete loss. More digging might reveal a method for selecting particular windows (or moving tabs to them), while the
As ever, more research is needed in this area...
konsole opens new sessions with specific profiles in a way that fits with my normal workflow.Essentially, I want to be able use a menu option to either: (a) open a new konsole window and ssh session to a remote host if no sessions are currently open; or (b) open a new tab in a window associated with a preexisting ssh to a remote host if a session is already open. I'd hoped to do this by writing a script to interface with D-Bus to obtain the PIDs associated with each open konsole window, determine whether the PID refers to a secure shell connection to a remote host, and if it does and the remote host matches the current target, create a new tab in that window using the appropriate profile to run secure shell.
Sadly, I quickly discovered that it wasn't going to be as straightforward as I'd hoped. Firstly it seems that it's hard (not possible?) to make a particular window the target of the
newSession() D-Bus call. Secondly there seems to be a bug in qdbus which prevents newSession() from accepting arguments, making it impossible to open a specific profile.Still, it's not a complete loss. More digging might reveal a method for selecting particular windows (or moving tabs to them), while the
qdbus problem might simply be a bug in the argument handling that can be worked around with the judicious use of quotes or it might be that qdbus could be replaced with a dbus-send command.As ever, more research is needed in this area...