greshake / i3status-rust

Very resourcefriendly and feature-rich replacement for i3status, written in pure Rust
GNU General Public License v3.0
2.88k stars 475 forks source link

Override colors per block #580

Closed woutervb closed 3 years ago

woutervb commented 4 years ago

It would be great if colors could be specified on a per block basis, or at least have the option to override them for a specific block.

Not sure if that is already possible, documentation does not seem to indicate this

ammgws commented 4 years ago

Do you mean the colours applied when the block enters different states (info, critical, warning, good,)?

IIRC they're hardcoded in each block but might be possible to allow them to be overridden.

woutervb commented 4 years ago

What I mean is that for example the music block uses the 'info' color as background. And for this block I would like to use a different color. While I am happy of the other blocks to use the global color definition for info

ammgws commented 4 years ago

For now I could make the music block one configurable as indeed it's hardcoded in. Though the configuration would only allow choices between info, good, warning or critical otherwise it looks like a complete overhaul of the widgets and stuff is needed for that. Would that be acceptable in the interim?

What other blocks are like the music block in that regard?

ammgws commented 4 years ago

@woutervb Would the above suffice for now?

woutervb commented 4 years ago

To be honest, that would not solve my issue. I did had a brief look at the code and was wondering if it could be an option to specify the color, but I have not yet looked at the rendering part. Judging your earlier comment I guess that is where the problem lies.

ammgws commented 4 years ago

If something colour_override was added here:

https://github.com/greshake/i3status-rust/blob/4049a6a5a91bee026e1cf175476a0f7217b6e2ab/src/widgets/button.rs#L17-L35

and this line changed to set the colours from colour_override if they're set: https://github.com/greshake/i3status-rust/blob/4049a6a5a91bee026e1cf175476a0f7217b6e2ab/src/widgets/button.rs#L77

Then can add the colour_override to each block's config and it should be done, and without breaking existing configs either.

woutervb commented 4 years ago

I did scan the code again, and was wondering if it was an idea to extend the 'states' with some custom one's like 'custom1, custom2' and then simply get the colors from the theme, with a fallback to the colors assigned to info, error etc (just have the same number of custom as currently we have as states).

Then if there comes an option to override the 'state' this can become customx and this way have alternative colors.

That would work for my usecase, but seems more generic than hacking a single block.

If this idea seems viable, I can give it an attempt to implement in the coming day's

ammgws commented 4 years ago

Not sure if I follow 100%, but it seems like it would be easier to allow each block to override the standard state colours instead.

Previous discussion: https://github.com/greshake/i3status-rust/issues/72

ammgws commented 3 years ago

@woutervb (also cc. people who gave thumbs up in this thread: @elliotf, @pierg75, @idiot-toaster, @bluec0re, @alteriks, @deepak-kapoor, @andersfylling, @gytis-ivaskevicius, @RandomErrorMessage and @GladOSkar since you may be interested)

Could you please try #947? It should hopefully cover this issue.