Skip to content

Commit

Permalink
support starting a kitty window with the 'kitten' command
Browse files Browse the repository at this point in the history
  • Loading branch information
k4lizen committed Jan 17, 2025
1 parent 29fb02f commit 70b4515
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ The table below shows which release corresponds to each branch, and what date th
| [2.2.0](#220) | | Jan 5, 2015

## 5.0.0 (`dev`)
- [#2522][2522] Support starting a kitty debugging window with the 'kitten' command

[2522]: https://github.com/Gallopsled/pwntools/pull/2522

## 4.15.0 (`beta`)
- [#2508][2508] Ignore a warning when compiling with asm on nix
Expand Down
8 changes: 3 additions & 5 deletions pwnlib/util/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,11 @@ def run_in_new_terminal(command, terminal=None, args=None, kill_at_exit=True, pr
log.debug("Launching a new terminal: %r" % argv)

stdin = stdout = stderr = open(os.devnull, 'r+b')
if terminal == 'tmux' or terminal == 'kitty':
if terminal == 'tmux' or terminal in ('kitty', 'kitten'):
stdout = subprocess.PIPE

p = subprocess.Popen(argv, stdin=stdin, stdout=stdout, stderr=stderr, preexec_fn=preexec_fn)

kittyid = None

if terminal == 'tmux':
out, _ = p.communicate()
try:
Expand All @@ -469,7 +467,7 @@ def run_in_new_terminal(command, terminal=None, args=None, kill_at_exit=True, pr
with subprocess.Popen((qdbus, konsole_dbus_service, '/Sessions/{}'.format(last_konsole_session),
'org.kde.konsole.Session.processId'), stdout=subprocess.PIPE) as proc:
pid = int(proc.communicate()[0].decode())
elif terminal == 'kitty':
elif terminal in ('kitty', 'kitten'):
pid = p.pid

out, _ = p.communicate()
Expand Down Expand Up @@ -503,7 +501,7 @@ def kill():
try:
if terminal == 'qdbus':
os.kill(pid, signal.SIGHUP)
elif terminal == 'kitty':
elif terminal in ('kitty', 'kitten'):
subprocess.Popen(["kitten", "@", "close-window", "--match", "id:{}".format(kittyid)], stderr=stderr)
else:
os.kill(pid, signal.SIGTERM)
Expand Down

0 comments on commit 70b4515

Please sign in to comment.