Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reload config file without restart #1292

Closed
Luflosi opened this issue Jan 7, 2019 · 25 comments
Closed

Reload config file without restart #1292

Luflosi opened this issue Jan 7, 2019 · 25 comments

Comments

@Luflosi
Copy link
Contributor

Luflosi commented Jan 7, 2019

What do you think of the possibility of reloading the config file without restarting kitty? While this may be a little difficult for some options, like those which are compiled into the shader code at startup, it should be fairly simple for some options that are just copied to some internal variable. I'm not asking to make most options reloadable, I'd just like to start with a couple easy ones.
What do you think about this idea? If you're ok with this, I could make a pull request but I don't know where to start, maybe you can give me a couple tips.
I've read #343, #635 and #684 but I am not quite satisfied with your answer that it's too much work, maybe you change your mind if someone else (me) is willing to implement it.

@kovidgoyal
Copy link
Owner

Having reloading for some options but not others is not worth it in my opinion, since that is just confusing. No one will be able to keep track of which options change and which do not. And implementing it for all options is waaay too much work. If you are willing to implement it for all options, then go ahead, I wont refuse the patch, but less than that is not a good idea, IMO.

If you want to implement it, you will basically need to carefully track each option to see how/where it is used and have the reload code change it accordingly. This is basically a lot of boring book-keeping.

@Luflosi
Copy link
Contributor Author

Luflosi commented Jan 8, 2019

Both iTerm2 and Alacritty support most config options or settings in case of iTerm2 to be changed without a restart but they don't support that with all of them. Why do you think that it's so confusing? As long as it is well documented, which ones require a restart and which ones don't, it should be ok IMHO.

@kovidgoyal
Copy link
Owner

Because there is no way for an end user to know to expect whether config
option a will reload or not -- that is entirely dependent on the
implementation details. Which means that if the user is trying to
experiment with reloading the config file it will create another layer
of confusion.

And not to mention that the config options that most people really want
to change regularly, colors and such, are already dynamically changeable.

@devth
Copy link

devth commented Jan 13, 2019

+1 I think the entire world wants reloadable config.

@TheConfuZzledDude
Copy link

I think at least having a command to reload keyboard mappings from a config file would be enough, since that wouldn't confuse anyone, but would still be useful for the majority of times you'd want to reload the config for.

@kbtz
Copy link

kbtz commented Feb 21, 2019

What if the reload handles only options that have simple side effects, such as margin and padding?
For example, Kitty looks great on i3 with a little padding but that gets in the way when using a "fullscreen" program such as vim. It would be great to have a way of removing that padding on the fly before I launch vim.

@kovidgoyal Would it be possible/ideal to achieve this through a kitten? Should I research into that?

Thanks!

@kovidgoyal
Copy link
Owner

You can implement it in a kitten or using the remote control facility as
described here: https://sw.kovidgoyal.net/kitty/remote-control.html

@jpmvferreira
Copy link

Not sure if i should be asking here, given that the current status is close, but how is the progress going on this feature? Is there a workaround for similar results (such as, having your window manager close and open kitty at the same time such that it looked as if it were reloaded) while this feature is still being developed?

@Luflosi
Copy link
Contributor Author

Luflosi commented Aug 28, 2019

Nothing changed regarding the progress of this feature.
Closing and reopening kitty would unfortunately not work well because the state of whatever was in the terminal before closing it can't be restored after opening it again, except with a terminal multiplexer like tmux. But that's not a very elegant/convenient solution.

@jpmvferreira
Copy link

Ah right, well hopefully such feature is implemented in the future, as it can be very handy, in my case to switch color schemes on the fly.

Thanks!

@kovidgoyal
Copy link
Owner

This feature is not being developed. You can control various aspects of
kitty at runtime using the remote control protocol.
https://sw.kovidgoyal.net/kitty/remote-control.html

@Luflosi
Copy link
Contributor Author

Luflosi commented Aug 28, 2019

Yeah, colors can be changed using the remote control protocol. See https://github.com/dexpota/kitty-themes#previews for an example.

@JeanMertz
Copy link

I can see how it would be difficult to support auto-reloading of all configuration options, and I also understand that "some work, others don't" isn't great, but I do think that "keyboard mappings auto-reload, nothing else" is perfectly explainable.

I'm not making a judgement on the complexity to make this work out of the box, or even the priority of such a feature compared to others on the list (or the desire for any contributor to actually implement it, for that matter), but I did want to add my vote for such a feature, as it greatly improves the workflow while tweaking your Kitty settings.

@i-tub
Copy link

i-tub commented Feb 5, 2020

I came up with a hack to reload the config with a tiny kitten. DISCLAIMER: I bet that this doesn't work for all config settings, and for all I know it might crash your kitty if you change the "wrong" setting. However, it works for changing keyboard mappings, which was what I cared about. Use at your own risk.

from kitty import cli, constants, fast_data_types

def main(args):
    pass

def handle_result(kargs, answer, target_window_id, boss):
    args, rest = cli.parse_args([])
    opts = cli.create_opts(args)
    boss.keymap = opts.keymap.copy()
    fast_data_types.set_options(opts, constants.is_wayland(), args.debug_rendering,
                                args.debug_font_fallback)

handle_result.no_ui = True

Also note that it passes an empty list to parse_args(), so any arguments you used when you originally started kitty are effectively thrown out. That works for me since I start kitty with no arguments, but YMMV. I suppose there's a way of re-using the original arguments but that's left as an exercise to the reader.

To use it, save it to ~/.config/kitty/reload.py and add some mapping to your kitty.conf, for example:

map kitty_mod+0 kitten reload.py

@metalelf0
Copy link

+1 to this. I'd love to be able to have a set of "reloadable" options, like e.g. font face, padding/margin, and such, without needing a full kitty restart. My work flow is to start kitty, open 2-3 tabs with at least a couple splits each (servers, compilers, and stuff), and then every time I want to change a kitty setting I need to kill all processes and restart everything. Do you think it would be viable to use kittens to reload individual options (like, e.g., kitty @ reload-font-face ~/.config/kitty.conf)? I tried working on reloading font face, but I'm kinda stuck.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Feb 15, 2020

In general no. Options are used in both python and C and while kittens
can change the former, they cannot change the latter, without a dedicated API exposed to python from the C code.

@kovidgoyal
Copy link
Owner

FYI, in current master there is now a remote control command to adjust margins and padding per window.

@subnut
Copy link

subnut commented Jul 16, 2020

umm... @kovidgoyal , I tried as @i-tub suggested.......
but, it isn't working
AttributeError: 'CLIOptions' object has no attribute 'debug_gl'

EDIT: Nevermind, I found another, cleaner way to do what I wanted.

@ThatOneCalculator
Copy link

umm... @kovidgoyal , I tried as @i-tub suggested.......
but, it isn't working
AttributeError: 'CLIOptions' object has no attribute 'debug_gl'

EDIT: Nevermind, I found another, cleaner way to do what I wanted.

Could you share that cleaner way?

@subnut
Copy link

subnut commented Jan 4, 2021

@ThatOneCalculator I just wanted to change the colors, not reload the whole config file.
There's already a method to do that, just read the docs once.....

It should be in the Remote control section of the docs
I used kitty @ set-colors -a -c <path-to-config-file>

@anttikissa
Copy link

I just discovered kitty, and my use case for this would be to be able to edit something in the config file and then immediately see the results (and having them persisted as well for future use).

My workaround for this (using macOS) is to configure macos_quit_when_last_window_closed to yes, and then run this in another terminal:

while true; do kitty vim .config/kitty/kitty.conf; done

Combined with vim set up so that it will open the file in the position I left it (see :help restore-cursor), this was more than sufficient for my purposes.

@Alveel
Copy link

Alveel commented May 26, 2021

This can be accomplished without having to first enable remote control, using the kitty shell window:

  • ^+Shift+Escape
  • set-colors -a -c ~/.config/kitty/kitty.conf
  • exit

However, unfortunately, it doesn't work for new panels you open in the same session, only existing.

@kovidgoyal kovidgoyal reopened this Jun 7, 2021
@jlorusso-bc
Copy link

Never knew how much I liked this feature (in Alacritty) until I had to do without it.

@Luflosi
Copy link
Contributor Author

Luflosi commented Jun 10, 2021

It should work in master and in the next version, see the commit that closed this issue.

@sathishmanohar
Copy link

In latest releases Ctrl+Shfit+F5 reloads the config as per the commit mentioned above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests