@@ -443,11 +443,13 @@ def run_in_new_terminal(command, terminal=None, args=None, kill_at_exit=True, pr
443443 log .debug ("Launching a new terminal: %r" % argv )
444444
445445 stdin = stdout = stderr = open (os .devnull , 'r+b' )
446- if terminal == 'tmux' :
446+ if terminal == 'tmux' or terminal == 'kitty' :
447447 stdout = subprocess .PIPE
448448
449449 p = subprocess .Popen (argv , stdin = stdin , stdout = stdout , stderr = stderr , preexec_fn = preexec_fn )
450450
451+ kittyid = None
452+
451453 if terminal == 'tmux' :
452454 out , _ = p .communicate ()
453455 try :
@@ -460,6 +462,16 @@ def run_in_new_terminal(command, terminal=None, args=None, kill_at_exit=True, pr
460462 with subprocess .Popen ((qdbus , konsole_dbus_service , '/Sessions/{}' .format (last_konsole_session ),
461463 'org.kde.konsole.Session.processId' ), stdout = subprocess .PIPE ) as proc :
462464 pid = int (proc .communicate ()[0 ].decode ())
465+ elif terminal == 'kitty' :
466+ pid = p .pid
467+
468+ out , _ = p .communicate ()
469+ try :
470+ kittyid = int (out )
471+ except ValueError :
472+ kittyid = None
473+ if kittyid is None :
474+ log .error ("Could not parse kitty window ID from output (%r)" , out )
463475 else :
464476 pid = p .pid
465477
@@ -468,6 +480,8 @@ def kill():
468480 try :
469481 if terminal == 'qdbus' :
470482 os .kill (pid , signal .SIGHUP )
483+ elif terminal == 'kitty' :
484+ subprocess .Popen (["kitten" , "@" , "close-window" , "--match" , "id:{}" .format (kittyid )])
471485 else :
472486 os .kill (pid , signal .SIGTERM )
473487 except OSError :
0 commit comments