terminator_dbus
¤
Terminator D-Bus package.
Python library to interact with Terminator through D-Bus.
Classes:
-
LayoutTree–Inspect one window's layout without making further D-Bus calls.
-
TerminalExtension–Call the bundled plugin and decode its layout queries into Python objects.
-
Terminator–Provide Python methods for Terminator's complete D-Bus interface.
-
TerminatorError–Report a terminal creation failure returned by Terminator.
Functions:
-
get_bus_name–Return the D-Bus service and interface name for a display.
-
get_parser–Return the CLI argument parser.
-
install_plugin–Install the bundled plugin in Terminator's plugin directory.
-
main–Run the main program.
Attributes:
-
BUS_BASE(Final) –Base name of Terminator's D-Bus service and interface.
-
BUS_PATH(Final) –Object path of Terminator's D-Bus service.
-
EXTENSION_INTERFACE–D-Bus interface exported by the bundled Terminator plugin.
-
EXTENSION_PATH–Object path exported by the bundled Terminator plugin.
BUS_BASE
module-attribute
¤
BUS_BASE: Final = 'net.tenshu.Terminator2'
Base name of Terminator's D-Bus service and interface.
BUS_PATH
module-attribute
¤
BUS_PATH: Final = '/net/tenshu/Terminator2'
Object path of Terminator's D-Bus service.
EXTENSION_INTERFACE
module-attribute
¤
EXTENSION_INTERFACE = 'net.tenshu.Terminator2.Extension'
D-Bus interface exported by the bundled Terminator plugin.
EXTENSION_PATH
module-attribute
¤
EXTENSION_PATH = '/net/tenshu/Terminator2/Extension'
Object path exported by the bundled Terminator plugin.
LayoutTree
¤
Inspect one window's layout without making further D-Bus calls.
Snapshots remain unchanged when the live layout changes. Fetch a new tree after a mutation to see the current parents, children, ratios, and focus. Terminal node IDs are their UUIDs. Other node IDs are opaque strings.
Parameters:
Methods:
-
get_ancestors–Return parents from the nearest split or tab through the window.
-
get_children–Return children in tab order, left/right order, or above/below order.
-
get_neighbors–Return all terminals sharing the requested edge in the same tab.
-
get_node–Return a node record; raise
KeyErrorif the ID is absent. -
get_parent–Return a node's parent, or
Nonefor the window root. -
get_sibling–Return the other branch of a split, or
Noneoutside a split.
Attributes:
-
focused_uuid(str | None) –UUID of the focused terminal in this window, if any.
-
nodes(dict[str, dict[str, Any]]) –Node IDs mapped to their layout records.
-
root(str) –ID of the window node.
Source code in src/terminator_dbus/_internal/tree.py
51 52 53 54 | |
focused_uuid
instance-attribute
¤
UUID of the focused terminal in this window, if any.
nodes
instance-attribute
¤
Node IDs mapped to their layout records.
get_ancestors
¤
Return parents from the nearest split or tab through the window.
Source code in src/terminator_dbus/_internal/tree.py
69 70 71 72 73 74 75 76 | |
get_children
¤
Return children in tab order, left/right order, or above/below order.
Source code in src/terminator_dbus/_internal/tree.py
65 66 67 | |
get_neighbors
¤
Return all terminals sharing the requested edge in the same tab.
Directions are right, left, above, and below. Results follow
display order along the shared edge. There is no wrapping at tab edges.
Rectangles use normalized tab coordinates and ignore separator widths.
Raises:
-
KeyError–The UUID is absent from the snapshot.
-
ValueError–The node is not a terminal, or the direction is invalid.
Source code in src/terminator_dbus/_internal/tree.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
get_node
¤
Return a node record; raise KeyError if the ID is absent.
Source code in src/terminator_dbus/_internal/tree.py
56 57 58 | |
get_parent
¤
Return a node's parent, or None for the window root.
Source code in src/terminator_dbus/_internal/tree.py
60 61 62 63 | |
get_sibling
¤
Return the other branch of a split, or None outside a split.
Source code in src/terminator_dbus/_internal/tree.py
78 79 80 81 82 83 | |
TerminalExtension
¤
TerminalExtension(client: Terminator)
Call the bundled plugin and decode its layout queries into Python objects.
Access this client through Terminator.extension. Remote operations act on
the live layout. Methods on a returned LayoutTree use its local snapshot.
Parameters:
-
(client¤Terminator) –Terminator client whose connection the extension will reuse.
Methods:
-
focus–Select a terminal's tab and focus its window and shell.
-
get_ancestors–Inspect current ancestors from the nearest parent through the window.
-
get_children–Inspect current children in display order.
-
get_neighbors–Inspect all terminals sharing the requested edge in the current tab.
-
get_node–Inspect a node in the current layout.
-
get_parent–Inspect the current parent, or return
Nonefor a window root. -
get_sibling–Inspect the other branch of the current parent split, if any.
-
get_tree–Return a local layout snapshot for the window containing this node.
-
move_node–Move a terminal or subtree beside another node without restarting shells.
-
new_tab–Create a tab with optional
commandanddirectorysettings. -
rotate_subtree–Rotate a split
clockwiseorcounterclockwise, preserving node IDs. -
set_split_ratio–Set the first branch's share of space, strictly between zero and one.
-
split–Create a terminal
right,left,above, orbelowthe source. -
split_node–Add a terminal beside an existing terminal or entire split subtree.
-
swap_children–Exchange both branches while keeping the split's divider ratio.
Source code in src/terminator_dbus/_internal/extension.py
77 78 | |
focus
¤
focus(uuid: str) -> None
Select a terminal's tab and focus its window and shell.
Source code in src/terminator_dbus/_internal/extension.py
157 158 159 | |
get_ancestors
¤
Inspect current ancestors from the nearest parent through the window.
Source code in src/terminator_dbus/_internal/extension.py
108 109 110 | |
get_children
¤
Inspect current children in display order.
Source code in src/terminator_dbus/_internal/extension.py
104 105 106 | |
get_neighbors
¤
Inspect all terminals sharing the requested edge in the current tab.
Source code in src/terminator_dbus/_internal/extension.py
116 117 118 | |
get_node
¤
Inspect a node in the current layout.
Source code in src/terminator_dbus/_internal/extension.py
96 97 98 | |
get_parent
¤
Inspect the current parent, or return None for a window root.
Source code in src/terminator_dbus/_internal/extension.py
100 101 102 | |
get_sibling
¤
Inspect the other branch of the current parent split, if any.
Source code in src/terminator_dbus/_internal/extension.py
112 113 114 | |
get_tree
¤
get_tree(uuid: str) -> LayoutTree
Return a local layout snapshot for the window containing this node.
Source code in src/terminator_dbus/_internal/extension.py
92 93 94 | |
move_node
¤
Move a terminal or subtree beside another node without restarting shells.
Nodes may belong to different tabs or windows. The returned ID denotes the new split enclosing the target and moved node. Empty source splits, tabs, and windows are removed. Moving into one's own subtree is invalid.
Source code in src/terminator_dbus/_internal/extension.py
148 149 150 151 152 153 154 155 | |
new_tab
¤
Create a tab with optional command and directory settings.
Source code in src/terminator_dbus/_internal/extension.py
120 121 122 | |
rotate_subtree
¤
Rotate a split clockwise or counterclockwise, preserving node IDs.
Source code in src/terminator_dbus/_internal/extension.py
144 145 146 | |
set_split_ratio
¤
Set the first branch's share of space, strictly between zero and one.
Source code in src/terminator_dbus/_internal/extension.py
128 129 130 | |
split
¤
Create a terminal right, left, above, or below the source.
Source code in src/terminator_dbus/_internal/extension.py
124 125 126 | |
split_node
¤
Add a terminal beside an existing terminal or entire split subtree.
Omitted launch options inherit from the subtree's first terminal in display order, subject to Terminator's profile inheritance setting.
Source code in src/terminator_dbus/_internal/extension.py
136 137 138 139 140 141 142 | |
swap_children
¤
swap_children(node_id: str) -> None
Exchange both branches while keeping the split's divider ratio.
Source code in src/terminator_dbus/_internal/extension.py
132 133 134 | |
Terminator
¤
Terminator(
*,
bus: BusConnection | None = None,
display: str | None = None,
bus_name: str | None = None,
)
Provide Python methods for Terminator's complete D-Bus interface.
The client keeps one session-bus connection and reuses proxies. Built-in
methods send known signatures directly, so they do not need introspection.
Plugin interfaces can be discovered and called through dynamic proxies
or the generic call method.
Parameters:
-
(bus¤BusConnection | None, default:None) –An existing D-Bus connection. A session-bus connection is created when this argument is not set.
-
(display¤str | None, default:None) –GDK display name used to calculate Terminator's D-Bus name. Overrides
TERMINATOR_DBUS_NAMEwhen specified. -
(bus_name¤str | None, default:None) –Exact D-Bus service name. Overrides
TERMINATOR_DBUS_NAMEwhen specified. When both connection settings are unset, a non-emptyTERMINATOR_DBUS_NAMEselects the service before the current desktop display.
Raises:
-
ValueError–Both
displayandbus_namewere specified. -
DBusException–The session bus or Terminator service is not available.
Methods:
-
bg_img–Set the background image of one terminal.
-
bg_img_all–Set the background image of all terminals.
-
call–Call an arbitrary method on Terminator or a plugin's D-Bus interface.
-
discover_interfaces–Discover exported D-Bus interfaces and create their dynamic proxies.
-
get_focused_terminal–Return the focused terminal UUID, if a terminal has focus.
-
get_interface–Create a dynamic proxy for an interface exported by Terminator or a plugin.
-
get_tab–Return the parent tab identifier of a terminal.
-
get_tab_title–Return the parent tab title of a terminal, if it has one.
-
get_terminals–Return the UUID of every terminal.
-
get_window–Return the parent window UUID of a terminal.
-
get_window_title–Return the parent window title of a terminal.
-
hsplit–Split a terminal horizontally and return the new terminal UUID.
-
new_tab–Create a tab beside a terminal and return the new terminal UUID.
-
new_tab_cmdline–Create a tab from serialized Terminator command-line options.
-
new_window–Create a window and return its first terminal UUID.
-
new_window_cmdline–Create a window from serialized Terminator command-line options.
-
reload_configuration–Reload the configuration of all terminals.
-
set_tab_title–Set a terminal's parent tab title.
-
switch_profile–Switch one terminal to a profile.
-
switch_profile_all–Switch all terminals to a profile.
-
toggle_visibility_cmdline–Toggle the visibility of every Terminator window.
-
unhide_cmdline–Show every hidden Terminator window.
-
vsplit–Split a terminal vertically and return the new terminal UUID.
Attributes:
-
bus_name(str) –Return the D-Bus service and interface name used by this client.
-
extension(TerminalExtension) –Return a typed client for the bundled terminal and layout extension.
Source code in src/terminator_dbus/_internal/client.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
extension
property
¤
extension: TerminalExtension
Return a typed client for the bundled terminal and layout extension.
bg_img
¤
Set the background image of one terminal.
Parameters:
-
(uuid¤str) –Target terminal UUID.
-
(options¤Mapping[str, str]) –Mapping with the image path in the
filekey.
Source code in src/terminator_dbus/_internal/client.py
365 366 367 368 369 370 371 372 | |
bg_img_all
¤
Set the background image of all terminals.
Parameters:
Source code in src/terminator_dbus/_internal/client.py
357 358 359 360 361 362 363 | |
call
¤
call(
method_name: str,
*args: object,
interface: str | None = None,
object_path: str = BUS_PATH,
signature: str | None = None,
) -> Any
Call an arbitrary method on Terminator or a plugin's D-Bus interface.
Parameters:
-
(method_name¤str) –D-Bus method to call.
-
(*args¤object, default:()) –Positional arguments sent to the method.
-
(interface¤str | None, default:None) –D-Bus interface name. Defaults to Terminator's built-in interface.
-
(object_path¤str, default:BUS_PATH) –D-Bus object path exported by the selected Terminator service.
-
(signature¤str | None, default:None) –Input signature. When unset, the proxy uses introspection to find the signature. An empty string declares a method with no inputs.
Returns:
-
Any–The original D-Bus result. Plugin results are not converted or
-
Any–checked for error strings.
Raises:
-
DBusException–The object, interface, or method is unavailable, or the remote method raises an exception.
-
TerminatorError–A built-in terminal creation method returned an
ERROR:response.
Source code in src/terminator_dbus/_internal/client.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
discover_interfaces
¤
discover_interfaces(
object_path: str = "/", *, recursive: bool = True
) -> dict[str, dict[str, Interface]]
Discover exported D-Bus interfaces and create their dynamic proxies.
Discovery reports interfaces exported by the running Terminator process. It does not list installed or disabled Python plugins. Standard D-Bus and built-in Terminator interfaces are included.
Parameters:
-
(object_path¤str, default:'/') –Object path where discovery starts. The root path finds plugin objects anywhere in the selected service.
-
(recursive¤bool, default:True) –Follow child objects described by introspection.
Returns:
-
dict[str, dict[str, Interface]]–Object paths mapped to interface names and their dynamic proxies.
-
dict[str, dict[str, Interface]]–Nodes with no interfaces are omitted.
Raises:
-
DBusException–An object cannot be introspected, or the Terminator service is unavailable.
-
ParseError–An object returns invalid XML.
Source code in src/terminator_dbus/_internal/client.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | |
get_focused_terminal
¤
get_focused_terminal() -> str | None
Return the focused terminal UUID, if a terminal has focus.
Source code in src/terminator_dbus/_internal/client.py
410 411 412 | |
get_interface
¤
get_interface(
interface: str,
*,
object_path: str = BUS_PATH,
introspect: bool = True,
) -> Interface
Create a dynamic proxy for an interface exported by Terminator or a plugin.
Methods are available as attributes on the returned interface. For
example, a plugin that exports new_tab can be called with
plugin.new_tab(uuid, command). These calls return raw D-Bus results.
Parameters:
-
(interface¤str) –D-Bus interface name.
-
(object_path¤str, default:BUS_PATH) –D-Bus object path exported by the selected Terminator service.
-
(introspect¤bool, default:True) –Use introspection to find method signatures. Disable this when every call supplies its own signature.
Returns:
-
Interface–A
dbus.Interfaceusing the client's existing bus connection. -
Interface–Proxies for the same path and introspection setting are reused.
Raises:
-
DBusException–The Terminator service is unavailable.
Source code in src/terminator_dbus/_internal/client.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
get_tab
¤
Return the parent tab identifier of a terminal.
Terminator does not assign UUIDs to tabs. It currently returns an empty string for a terminal in a notebook and no value otherwise.
Parameters:
Source code in src/terminator_dbus/_internal/client.py
430 431 432 433 434 435 436 437 438 439 | |
get_tab_title
¤
Return the parent tab title of a terminal, if it has one.
Parameters:
Source code in src/terminator_dbus/_internal/client.py
441 442 443 444 445 446 447 | |
get_terminals
¤
Return the UUID of every terminal.
Source code in src/terminator_dbus/_internal/client.py
406 407 408 | |
get_window
¤
Return the parent window UUID of a terminal.
Parameters:
Source code in src/terminator_dbus/_internal/client.py
414 415 416 417 418 419 420 | |
get_window_title
¤
Return the parent window title of a terminal.
Parameters:
Source code in src/terminator_dbus/_internal/client.py
422 423 424 425 426 427 428 | |
hsplit
¤
Split a terminal horizontally and return the new terminal UUID.
Parameters:
-
(uuid¤str) –Target terminal UUID.
-
(options¤Mapping[str, str] | None, default:None) –Optional
executecommand andtitlefor the new terminal.
Returns:
-
str–The new terminal UUID.
Raises:
-
TerminatorError–Terminator returned an
ERROR:response.
Source code in src/terminator_dbus/_internal/client.py
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | |
new_tab
¤
Create a tab beside a terminal and return the new terminal UUID.
Parameters:
Returns:
-
str–The new terminal UUID.
Raises:
-
TerminatorError–Terminator returned an
ERROR:response.
Source code in src/terminator_dbus/_internal/client.py
339 340 341 342 343 344 345 346 347 348 349 350 351 | |
new_tab_cmdline
¤
Create a tab from serialized Terminator command-line options.
Parameters:
-
(options¤Mapping[str, str]) –Complete option mapping produced by Terminator's command line parser. Keys and values must be strings.
Source code in src/terminator_dbus/_internal/client.py
304 305 306 307 308 309 310 311 | |
new_window
¤
new_window() -> str
Create a window and return its first terminal UUID.
Raises:
-
TerminatorError–Terminator returned an
ERROR:response.
Source code in src/terminator_dbus/_internal/client.py
331 332 333 334 335 336 337 | |
new_window_cmdline
¤
Create a window from serialized Terminator command-line options.
Parameters:
-
(options¤Mapping[str, str]) –Complete option mapping produced by Terminator's command line parser. Keys and values must be strings.
Source code in src/terminator_dbus/_internal/client.py
295 296 297 298 299 300 301 302 | |
reload_configuration
¤
reload_configuration() -> None
Reload the configuration of all terminals.
Source code in src/terminator_dbus/_internal/client.py
353 354 355 | |
set_tab_title
¤
Set a terminal's parent tab title.
Parameters:
-
(uuid¤str) –Target terminal UUID.
-
(options¤Mapping[str, str]) –Mapping with the new title in the
tab-titlekey.
Source code in src/terminator_dbus/_internal/client.py
449 450 451 452 453 454 455 456 | |
switch_profile
¤
Switch one terminal to a profile.
Parameters:
-
(uuid¤str) –Target terminal UUID.
-
(options¤Mapping[str, str]) –Mapping with the profile name in the
profilekey.
Source code in src/terminator_dbus/_internal/client.py
458 459 460 461 462 463 464 465 | |
switch_profile_all
¤
Switch all terminals to a profile.
Parameters:
Source code in src/terminator_dbus/_internal/client.py
467 468 469 470 471 472 473 | |
toggle_visibility_cmdline
¤
Toggle the visibility of every Terminator window.
Parameters:
-
(options¤Mapping[str, str]) –Serialized command-line options. Terminator currently ignores the values.
Source code in src/terminator_dbus/_internal/client.py
313 314 315 316 317 318 319 320 | |
unhide_cmdline
¤
Show every hidden Terminator window.
Parameters:
-
(options¤Mapping[str, str]) –Serialized command-line options. Terminator currently ignores the values.
Source code in src/terminator_dbus/_internal/client.py
322 323 324 325 326 327 328 329 | |
vsplit
¤
Split a terminal vertically and return the new terminal UUID.
Parameters:
-
(uuid¤str) –Target terminal UUID.
-
(options¤Mapping[str, str] | None, default:None) –Optional
executecommand andtitlefor the new terminal.
Returns:
-
str–The new terminal UUID.
Raises:
-
TerminatorError–Terminator returned an
ERROR:response.
Source code in src/terminator_dbus/_internal/client.py
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | |
TerminatorError
¤
Bases: DBusException
Report a terminal creation failure returned by Terminator.
This exception is also caught by handlers for dbus.DBusException.
Parameters:
-
(method¤str) –D-Bus method that failed.
-
(message¤str) –Original response from Terminator, including the
ERROR:prefix.
Attributes:
-
message(str) –Original response from Terminator, including the
ERROR:prefix. -
method(str) –D-Bus method that failed.
Source code in src/terminator_dbus/_internal/client.py
109 110 111 112 113 | |
get_bus_name
¤
Return the D-Bus service and interface name for a display.
Terminator appends the MD5 digest of its GDK display name to
net.tenshu.Terminator2. It removes the screen suffix before it creates
the digest. For example, :0 and :0.0 use the same D-Bus name.
Parameters:
-
(display¤str | None, default:None) –GDK display name. When unset,
TERMINATOR_DBUS_NAMEis used if non-empty, followed by the current desktop display.
Returns:
-
str–The environment's service name, the display-specific name, or the
-
str–base name when no display is known.
Source code in src/terminator_dbus/_internal/client.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
get_parser
¤
get_parser() -> ArgumentParser
Return the CLI argument parser.
Returns:
-
ArgumentParser–An argparse parser.
Source code in src/terminator_dbus/_internal/cli.py
49 50 51 52 53 54 55 56 57 58 59 60 61 | |
install_plugin
¤
Install the bundled plugin in Terminator's plugin directory.
Enable TerminatorDBusExtension in Terminator's preferences after installation.
The installed file is independent of the Python environment that installs it.
Repeated calls update the installed plugin to the bundled version.
Parameters:
-
(directory¤str | Path | None, default:None) –Plugin directory. Defaults to
$XDG_CONFIG_HOME/terminator/plugins, or~/.config/terminator/pluginswhen the variable is absent or empty.
Returns:
-
Path–The installed plugin path.
Raises:
-
OSError–If the plugin directory or file cannot be written.
Source code in src/terminator_dbus/_internal/extension.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
main
¤
Run the main program.
This function is executed when you type terminator-dbus or python -m terminator_dbus.
Parameters:
Returns:
-
int–An exit code.
Source code in src/terminator_dbus/_internal/cli.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |