@@ -443,11 +443,13 @@ def run_in_new_terminal(command, terminal=None, args=None, kill_at_exit=True, pr
443
443
log .debug ("Launching a new terminal: %r" % argv )
444
444
445
445
stdin = stdout = stderr = open (os .devnull , 'r+b' )
446
- if terminal == 'tmux' :
446
+ if terminal == 'tmux' or terminal == 'kitty' :
447
447
stdout = subprocess .PIPE
448
448
449
449
p = subprocess .Popen (argv , stdin = stdin , stdout = stdout , stderr = stderr , preexec_fn = preexec_fn )
450
450
451
+ kittyid = None
452
+
451
453
if terminal == 'tmux' :
452
454
out , _ = p .communicate ()
453
455
try :
@@ -460,6 +462,16 @@ def run_in_new_terminal(command, terminal=None, args=None, kill_at_exit=True, pr
460
462
with subprocess .Popen ((qdbus , konsole_dbus_service , '/Sessions/{}' .format (last_konsole_session ),
461
463
'org.kde.konsole.Session.processId' ), stdout = subprocess .PIPE ) as proc :
462
464
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 )
463
475
else :
464
476
pid = p .pid
465
477
@@ -468,6 +480,8 @@ def kill():
468
480
try :
469
481
if terminal == 'qdbus' :
470
482
os .kill (pid , signal .SIGHUP )
483
+ elif terminal == 'kitty' :
484
+ subprocess .Popen (["kitten" , "@" , "close-window" , "--match" , "id:{}" .format (kittyid )])
471
485
else :
472
486
os .kill (pid , signal .SIGTERM )
473
487
except OSError :
0 commit comments