bbidulock / icewm

A window manager designed for speed, usability, and consistency
Other
571 stars 97 forks source link

Workspace applet in taskbar: Allow setting colour of inactive preview icons #715

Closed fladd closed 6 months ago

fladd commented 1 year ago

It would be nice to be able to set the colour of the workspace icons in the the inactive workspace directly. Currently, it seems that they are automatically set to be a darker version of "ColorNormalWorkspaceButton". The problem is that for a dark theme, in order to have the workspace preview icons light grey one has to set this to "white", which results in a white border around the entire inactive workspace when also using PagerBorders=1, which is not desirable.

See also here:

image
gijsbers commented 1 year ago

Is there a way to do this automatically? Since so many dark themes don't have your proposed option set. What color qualifies as dark? If its intensity is below 50%, 40% or 30%? In that case icewm could use its brighter color automatically.

fladd commented 1 year ago

I think it is fine to attempt doing this automatically, but there should also be a manual way to overwrite that.

For detecting a switch from light to dark, it's a pretty involved problem (since it relies on perception and monitor hardware), but I have had pretty good results with something like this:

def is_dark(color):
    rgb = list(int(color[i:i+2], 16) for i in (0, 2, 4))
    ys = (rgb[0] / 255.0) ** 2.2 * 0.2126 + \
         (rgb[1] / 255.0) ** 2.2 * 0.7152 + \
         (rgb[2] / 255.0) ** 2.2 * 0.0722
    if ys ** 0.678 < 0.5:
        True
    else:
        False

(Source: https://gist.github.com/Myndex/e1025706436736166561d339fd667493)

gijsbers commented 1 year ago

Thanks!

PagerShowBorders=1 uses ColorWorkspaceNormalButtonText for inactive workspace borders, while the icon background uses ColorWorkspaceNormalButton.

fladd commented 1 year ago

For me it always seems to use ColorNormalWorkspaceButton, even with PagerShowBorders=1... ColorNormalWorkspaceButtonText has no effect on the inactive workspace border.

gijsbers commented 1 year ago

Which theme resembles this situation?

fladd commented 1 year ago

BlueDay (from Antix) for instance.

gijsbers commented 8 months ago

I wanted to optimize the is_dark code for speed: Apparently ys < 0.5 ** 1.475 == 0.360. Approximately ys = 3 * rgb ** 2.2 * 1/3. Hence ys = rgb * rgb < 0.360 ** (2/2.2) == 0.3948. Which avoids four times raising to the power of.

gijsbers commented 8 months ago

This detects if the workspace button color is dark and brightens it. I tested this with the BlueDay-Large theme from AntiX.