mawww / kakoune

mawww's experiment for a better code editor
http://kakoune.org
The Unlicense
9.85k stars 710 forks source link

[REQUEST] Dark mode support #4981

Closed Ashvith10 closed 8 months ago

Ashvith10 commented 11 months ago

Feature

Add support for dark mode. I can think of three possible circumstances:

Usecase

Explained above with three different circumstances

Screwtapello commented 11 months ago

Kakoune's default colorscheme is dark mode, and you can change it any time you want with the colorscheme command. What would you expect "supporting dark mode" to look like? A command? A hook? A register?

FlyingWombat commented 11 months ago

Kakoune's default colorscheme is just your terminal's colors. If you are using a light-themed terminal, kakoune will use the same light colors.

If you want something different, you can set the colorscheme to anything you like in your kakrc.

Ashvith10 commented 11 months ago

@FlyingWombat what I meant is that I want to be able to choose a custom theme, like gruvbox-light and gruvbox-dark without having to rely on the :colorscheme <color> command. So basically, watching the dark mode value from xdg-desktop-portal.

FlyingWombat commented 11 months ago

Oh, so you want to pick between different custom colorschemes depending on an external variable. OK.

You could use a shell expansion in your kakrc, something like:

colorscheme %sh{
  DARKMODE= ... # get xdg dark mode value
  if [ "$DARKMODE" = "true" ]; then
    printf gruvbox-dark
  else
    printf gruvbox-light
  fi
}

If I understand your feature request correctly, you want something like this to be put in kakoune's stdlib and for it to be the default behavior. One barrier to doing that, is that not all colorschemes have both dark and light variants.

Ashvith10 commented 11 months ago

@FlyingWombat Not an external variable, but more like a hook for xdg-desktop-portal. Perhaps checking out this Vim plugin would make sense: vim-lumen. I think that this plugin has a constraint that themes always have to provide both the light and dark schemes.

But on second thought, since Kakoune is an editor that ties itself around the coreutils, it makes a lot of sense to rely only on the default theme, and rather override it from the app itself to get that consistent color between multiplexer, shell and the editor itself.

FlyingWombat commented 11 months ago

For the first option, someone more experienced with kakoune's code than me will have to weigh in. AFAIK, kakoune doesn't have any real IPC for external processes. A xdg-desktop-portal hook sounds it may require that.

As is, I know you can send commands to a given session using the -p flag, like so:

for session in $(kak -l); do
  echo 'colorscheme gruvbox-light' | kak -p $session
done

You could maybe write an external script with this snippet to hook into xdg-desktop-portal.

Ashvith10 commented 11 months ago

@FlyingWombat that makes a lot of sense. For now, I'm making use of the terminal scheme, and adding modifications over it, as it provides an overall consistency with the theme of the shell.