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

light/dark theme based on system? #4915

Closed
hanoii opened this issue Apr 2, 2022 · 10 comments
Closed

light/dark theme based on system? #4915

hanoii opened this issue Apr 2, 2022 · 10 comments

Comments

@hanoii
Copy link

hanoii commented Apr 2, 2022

Is your feature request related to a problem? Please describe.
I normally use a dark setting systemwide, but also sometimes I am outdoors and prefer a light theme for most and I would like a light one on kitty.

Describe the solution you'd like
I'd like a setting to set a default theme, a light theme and and or a dark theme. You could have a setting to enable this but I assume it's redundant, if you only select a default theme, there would be no change, if there's a light/dark theme configured, it will favour that over the default depending on the system setting.

@kovidgoyal
Copy link
Owner

Not something I care enough to implement. It's trivially easy to
implement this yourself by using the themes kitten. Simply have your
system run a script when the theme changes and in that script call the
themes kitten to change the theme in all kitty instances.

@hanoii
Copy link
Author

hanoii commented Apr 4, 2022

How didn't I think of that?!

Looking around it seems https://github.com/bouk/dark-mode-notify for osx is a kickstart I'll be trying out, if anyone stumbles upon something different/better let me know.

EDIT:

#!/bin/bash

if [[ "$DARKMODE" -eq 1 ]]; then
	kitty +kitten themes --reload-in=all Snazzy 
fi

if [[ "$DARKMODE" -eq 0 ]]; then
	kitty +kitten themes --reload-in=all Material
fi

does it :)

@Joxtacy
Copy link

Joxtacy commented Jul 31, 2022

@hanoii Did you manage to figure out a solution?
How often/when do you run your script to check the $DARKMODE variable?

The slightly annoying thing with this approach is all the separate moving parts to it.

@hanoii
Copy link
Author

hanoii commented Aug 1, 2022

@Joxtacy yes, it was sorted out by what explained in the other post. I don't have to poll anything, that small program linked #4915 (comment) runs the script whenever the setting changes. It's just one tiny think on top of the thousands I manage :)

@rkshthrmsh
Copy link

rkshthrmsh commented Mar 13, 2023

Hi @hanoii, I was able to build and test dark-mode-notify with Kitty from command line, but for some reason I'm unable to get the Background Agent launchctl load -w to automatically listen, launch, and execute the command on system mode change. Any help is appreciated.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>ke.bou.dark-mode-notify</string>
    <key>KeepAlive</key>
    <true/>
	<key>StandardErrorPath</key>
    <string>/tmp/dark-mode-notify-stderr.log</string>
    <key>StandardOutPath</key>
    <string>/tmp/dark-mode-notify-stdout.log</string>
    <key>ProgramArguments</key>
    <array>
       <string>/usr/local/bin/dark-mode-notify</string>
       <string>/Users/user/.config/kitty/system_based_theme.zsh</string>
    </array>
</dict>
</plist>

EDIT:
I had to modify the bash script from hanoii above to provide full path to kitty's binary. Like so:

#!/bin/zsh

if [[ "$DARKMODE" -eq 0 ]]; then
	/Applications/kitty.app/Contents/MacOS/kitty +kitten themes --reload-in=all Rosé Pine Dawn 
fi

if [[ "$DARKMODE" -eq 1 ]]; then
	/Applications/kitty.app/Contents/MacOS/kitty +kitten themes --reload-in=all Rosé Pine Moon
fi

Figured it out thanks to the error logs (which I was not using previously)

@gaheldev
Copy link

gaheldev commented Jul 25, 2023

For people using Gnome, I made a script that does it: https://github.com/gaheldev/kitty-gnome-lightdark-mode-switcher
Probably easy to adapt to KDE too. It feels very hacky but works for me so far.

@jannis-baum
Copy link

I case anyone is interested: I made a script that lets you generate your own color-schemes (for Kitty, Vim, and other programs) that allow you to reload the colors entirely dynamically, i.e. the entire scrollback is adjusted and you never have to worry about reloading anything but kitty!

The repo also includes instructions for how to make Kitty automatically change the theme in sync with the macOS system dark/light mode.

See Chameleon.

@h-jia
Copy link

h-jia commented Nov 2, 2023

Toggle Theme.zip
I made an alfred workflow to do this. It changes your system themes and kitty's at the same time.

@iclanzan
Copy link

Curiously Kitty is already tracking changes to the system theme but all it does is print the string "system color theme changed: dark/light".

@kovidgoyal
Copy link
Owner

Nothing curious about it, the tracking is used to change the window decoration colors on GNOME Wayland.

And see kovidgoyal/kitty-fosshack2024#3

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

No branches or pull requests

9 participants