I want to make a VSCode extension that would sync the native titlebar color with the current color scheme. However, I see no documentation on doing that from code. I know that some editors like Kate and KWrite have such an option (which all use KF components), but I’m curious whether there is a way to ‘send’ a message to the window frame to change the color from another app.
To do that you would have to create custom plasma color scheme with the header colors that match your application, then apply a window rule to that application and set “Titlebar color scheme” to force your custom color scheme.
Depending of how much limited is vscode extension api in terms of files/commands access it may be better to implement this as a separate program with the benefit of being able to use for any other program. And guess what? It has been done before Žiga Leskovec / Tkp · GitLab
Only X11 support for now but pretty sure it should be possible to support wayland too.
Awesome! That sounds like something I was looking for.
I know about window rules, and I have been manually editing color schemes and applying them until now. Are window rules the way Kate and Kwrite do it too internally?
This is one of those cases where GNOME’s client side decorations have an advantage - apps can decide how they are drawn and achieve consistency on how they are displayed, without this weird discrepancy between titlebar and actual window content. Sure this is less of problem for Qt apps since they use KDE’s color schemes but not all apps are integrated with it and have their own styling.
Still it’s possible to do it better for server side decorations, for example by introducing some kind of API (e.g. Wayland protocol) so that apps could set the color of titlebar themselves. Current solution with color schemes is unwieldy and unintuitive (for every app you need a separate whole ass color scheme) and requires user interaction. You can do that in Windows 11 with one function call BTW.
If it’s just one call in Win11, that was quite an upgrade. Win7-10’s methods of customizing the non-client frame (without disabling it completely) were bonkers.
This got me thinking. Could we maybe create a protocol for combining the titlebar elements with client window, similar to Windows’ old methods? Basically like this:
App tells WM to embed titlebar with a certain amount of free space → WM confirms, while telling the app how much space is taken from each side of the window by buttons → App reorders elements to dodge the buttons + WM draws the buttons over the window instead of above it
This would be quite a work, questionable function, but quite a big step for UI consistency. Shouldn’t be hard to just overlay a window with buttons, and could likely work with GTK.
There’s a protocol proposal in Wayland to do exactly this, so it’s definitely possible.