i3status-rust icon indicating copy to clipboard operation
i3status-rust copied to clipboard

How to disable alternating tint for a specific block?

Open ammgws opened this issue 3 years ago • 5 comments

@GladOSkar Was this even possible in the first implementation you submitted in https://github.com/greshake/i3status-rust/pull/927?

Basically just want to disable tints between two adjacent blocks so that they visually appear as one, but the tint applies anyway even with the below config:

[[block]]
block = "bluetooth"
[block.theme_overrides]
alternating_tint_bg = "#000000"
alternating_tint_fg = "#000000"

[[block]]
block = "battery"
[block.theme_overrides]
alternating_tint_bg = "#000000"
alternating_tint_fg = "#000000"

ammgws avatar Jun 24 '22 10:06 ammgws

I don't think block theme overrides were a thing back then and if they were i didn't test them, so no idea. But reading the code right now yes, it looks like the tint is applied globally and not by the block's render functions individually, so there's no way to override it.

Honestly i also don't see an easy way to do it, since each block doesn't know where in the order it is and can't decide its tint for itself, especially since it can't know if other blocks before/after it are currently displaying or not. The only way to do it might be for the block to set a flag on itself that the protocol renderer can then use to decide whether to tint it or not

GladOSkar avatar Jun 25 '22 14:06 GladOSkar

We just need to use the block's theme config (from the block's shared_config) instead of the global one (config.theme.alternating_tint_bg):

https://github.com/greshake/i3status-rust/blob/9809c7206f7baa98f13fde0bf883ad7349dd26e4/src/protocol.rs#L28-L31

It seems possible if we change blocks_render_cache to store the block config together with I3BarBlock in a tuple or something. @MaxVerevkin Does that sound reasonable?

ammgws avatar Jun 29 '22 04:06 ammgws

so that they visually appear as one

Perhaps we can provide a simple way to join multiple blocks into one? Something like:

[[block]]
block = "a"

[[block]]
block = "group"
[[block.component]]
block = "bluetooth"
[[block.component]]
block = "battery"

[[block]]
block = "b"

We just need to use the block's theme config (from the block's shared_config) instead of the global one (config.theme.alternating_tint_bg):

In addition to this, the alternating pattern must be shifted for two blocks to appear as one. Consider this example:

tint enabled: YYYNNY
tint applied: YNYNNN

MaxVerevkin avatar Jun 29 '22 05:06 MaxVerevkin

Yeah actually overriding it manually per block messes up the whole sequence, plus blocks can hide as well so can't hardcode it in the config. Your suggestion sounds good to me (from a config point of view anyway)

ammgws avatar Jun 29 '22 08:06 ammgws

Perhaps we can provide a simple way to join multiple blocks into one?

Or even simpler:

[[block]]
# ...
join_with_next = true

[[block]]
# ...

MaxVerevkin avatar Aug 14 '22 07:08 MaxVerevkin