bat
bat copied to clipboard
Support for GNOME/GTK `color-scheme` detection to allow automatic theme swapping
Adding support to detect org.gnome.desktop.interface color-scheme 'prefer-dark' and org.gnome.desktop.interface color-scheme 'prefer-dark' would allow automatic theme switching like what is currently available on MacOS. This type of detection is common and used by a lot of GUI apps.
If the maintainer (s) are interested in this feature, I would be happy to implement it.
Cheers
We're currently using https://crates.io/crates/terminal-colorsaurus to detect whether the terminal is light or dark. Maybe it would make sense to contribute this detection there?
@keith-hall Thanks for the quick response. I've just asked terminal-colorsaurus but I imagine its out of scope of that crate.
Reason I'm requesting this is that the current system doesn't seem to be working for me on Ghostty.
regarding Ghostty, this discussion is relevant: https://github.com/sharkdp/bat/discussions/3165
if it doesn't make sense to add this feature to terminal-colorsaurus, and you can find a way to do it in bat, probably it's fine. I have a vague recollection that GTK have deprecated something wrt themes, but I don't remember what now... Hopefully not this org.gnome.desktop.interface color-scheme setting 😅
regarding Ghostty, this discussion is relevant: #3165
Unfortunately, I couldn't get it working with those suggestions. I've got my own hacky fix with sed, which I use for other programs, so it's not the end of the world.
Reason I'm requesting this is that the current system doesn't seem to be working for me on Ghostty.
Automatic dark/light detection seems to work fine for me with Ghostty (I have tested both on macOS and on Linux).
Note that you won't get automatic switching if you have the BAT_THEME environment variable (or the --theme option) set. You'll have to use --theme-light / --theme-dark (the environment variables equivalents for those options currently don't work).