JonnyHaystack / i3-resurrect

Simple solution to saving and restoring i3 workspaces
GNU General Public License v3.0
378 stars 19 forks source link

support restoring current directory for kitty terminal #96

Closed aarobc closed 3 years ago

aarobc commented 3 years ago

Is your feature request related to a problem? Please describe. Documentation indicates that gnome-terminal and alacrittyare supported, however there is no mention of support for kitty

Describe the solution you'd like adding the ability to provide "Kitty" as a valid value under terminals in the config file, and

Describe alternatives you've considered Manually scanning all the kitty windows and modifying the launch with --location, but that is very labor intensive.

Additional context kitty is becoming a very popular terminal, support would be greatly welcomed.

JonnyHaystack commented 3 years ago

Have you tried using kitty and had trouble with it? Those are just examples. You can put any window class in there and it just tells i3-resurrect to get the working directory from the window's first subprocess (which should be the shell) instead of the window's root process.

aarobc commented 3 years ago

Okay, with that understanding I was able to determine what was going on.

I made a little helper script to aid it my investigation:

#!/bin/bash
pid=`pgrep -P $(xprop _NET_WM_PID | cut -d' ' -f3)`
pwdx $pid

In the kitty config i had configured map ctrl+shift+n new_os_window_with_cwd, however as a consequence, the "new" terminal wasn't a new instance, but just a sub-process under the same instance of kitty. Any terminals I started up with the keyboard shortcut were attached to the parent instance, so i3-resurrect was only able to restore the first.

According to their documentation it's an optimization, but I was able to work around it with this kitty config: map ctrl+shift+n launch --cwd=current --type=background kitty --detach

Now each kitty terminal is its own instance.

JonnyHaystack commented 3 years ago

Might add this to the troubleshooting section of the README, thanks. I actually have a similar problem with Alacritty's Ctrl+Shift+T shortcut which does the same thing. The saved program cmdline has the arg for setting the working directory, but the cwd in the json is that of the original process that it was spawned from, which ends up overriding the one set by the command line argument