zellij-org / zellij

A terminal workspace with batteries included
https://zellij.dev
MIT License
19.39k stars 610 forks source link

Theme change detection during runtime #2249

Open souserge opened 1 year ago

souserge commented 1 year ago

Basic information

zellij --version: 0.35.1 uname -av or ver(Windows): Linux fedora 6.1.14-200.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Feb 26 00:13:26 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Further information I switch my GNOME system theme between light and dark on a daily basis to avoid eye strain. With that, I'd like other tools to follow system settings. I set up my terminal (Alacritty) to switch themes automatically using color-scheme-monitor developed by Martin Kühl. The tool simply edits the config file of a specified program when system settings change. When I tried the same hack with Zellij, it didn't immediately react to changes in config like Alacritty does. It would be nice to have this in Zellij as well. Detaching from a session doesn't seem to react to config changes either, so the only I found so far is starting a new session.

If the config cannot be reloaded automatically, is there a way to force a config reload using a CLI command?

I guess this issue is related to https://github.com/zellij-org/zellij/pull/1242 and the "Have UI reflect config changes" item on the roadmap.

JannesMeyer commented 1 year ago

It would be nice if zellij could automatically apply config changes. I also love that feature in Alacritty!

jurica commented 1 year ago

I would also love to see this!

0rphee commented 1 year ago

Yes! this would be great! Maybe this could also be solved sending a signal to the process, like helix does:

Helix docs

Additionally, you can reload the configuration file by sending the USR1 signal to the Helix process on Unix operating systems, such as by using the command pkill -USR1 hx.

souserge commented 1 year ago

@0rphee Wow, I use Helix and that's exactly what I was looking for for my color scheme switch setup, thanks for sharing!

0rphee commented 1 year ago

@souserge glad it could help you! i also have some scripts for changing the alactritty theme and wezterm theme in case you need help for either! :)

jurica commented 1 year ago

For me a good enough workaround would be if I could detach from a session, change the theme in config.kdl and attach back again using the new theme. Unfortunately this doesn't work. Although initially the new theme is used, as soon as the mode is changed the original theme is loaded again.

So I was looking into the issue and tried to understand the code for quite some time and must say that I was having quite a hard time. It's my first time working with rust. Nevertheless I tried to come up with an improvement and managed to implement a fix that works for me. Hopefully it will be useful for somebody else as well. For sure this is not the final solution but honestly I'm a bit overwhelmed by the project and not capable of providing a better solution (yet). In addition my impression is that currently it doesn't make too much sense putting a lot of effort into this issue as #2297 most likely will have a big influence on the final solution. So perhaps it's a good intermediate step.

masonmcelvain commented 5 months ago

Sorry for resurrecting this thread, but it seems to be the closest open issue with respect to reloading the configuration file.

I notice that the roadmap indicates that the UI should now reflect config changes. It doesn't link to anything so hard to say when/where it was implemented.

image

In practice I do not see the UI reflect config changes in active sessions (version 0.39.2). I also do not see anything in the docs about reloading the configuration file. Maybe I'm missing something, because the roadmap says this is implemented.

My workaround is to delete sessions and recreate them after config changes, which is no fun.

Shywim commented 4 months ago

I think this item on the roadmap refers to this issue https://github.com/zellij-org/zellij/pull/1242 which is "show configured binding on the UI instead of default ones" :/