Dynamic background color
Is there a way to define the waybar's background color to match the opened app's color?
Of course this has a ton of caveats (like what happens if there are multiple windows, etc) but, in the simplest form, I'm looking for a way to set the color programmatically (even if I had to define the colors manually). For example, with a long-running process.
I've seen there are some GTK variables that can be used but they are related to the GTK theme instead of the screen's contents (unless I'm mistaken).
Here are some examples of what I mean.
This is how my bar looks like without windows open:
The background color is set to match the one in my terminal so that when the terminal is open, it looks like this:
However, if I open Spotify (for example), the color does not adjust dynamically:
The most brutal way I can think of to achieving that is - hope you're sitting on a chair:
- launch the application using a wrapper script (f.e. in your window manager keybindings)
- application is Spotify so you know its bg color is
#000000 - you
cat#000000 intostyle.cssin the propertywindow#waybar -
killall -SIGUSR2 waybar(reloads Waybar config)
(only half-joking)
Hang on, this might not be that crazy!
I mean, like you said, it is a very crude way but waybar has a mechanism to reload the CSS automatically when it changes. In addition to this, I can tap onto the Hyprland socket to know what workspace I am on and what screens are in there... I might actually try it!
Only concern is the CPU usage but, by my estimates, it should not have that big of an impact actually!
Thank a lot for the half-joke that I'm taking half-seriously.
While working on a patch for sway/window, I have used this css for testing:
window#waybar.Firefox-esr {
background: #ff0000;
}
window#waybar.foot {
background: #0000ff;
}
this sets waybar's background color based on app_id based css classes. AFAIU hyprland/window supports the same. The limitation is that the window modules only apply the app_id class for a single tiled window in the workspace. I mean, it could be quite a bit of work writing down all the colors, depending on how many apps you want to do this for, but is that not sort of what you want?