Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add support for ARGB hex strings #578

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

chrishoage
Copy link

Polybar only supports #ARGB for transparency. I previously used the workaround in #132 (comment), however this is not a particularly clean solution.

With this change I can simply import

~/.cache/wal/colors-polybar.ini and have the #ARGB pre-defined with no need to pass in the color via an environment variable

Copy link
Author

@chrishoage chrishoage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find any tests for the Color class, otherwise I would have updated those.

Comment on lines +42 to +45
def hex_argb(self):
"""Convert an alpha hex color to argb hex."""
return "#%02X%s" % (int(int(self.alpha_num) * 255 / 100),
self.hex_color[1:])
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure about this name. Happy to tweak it to your liking.

@chrishoage
Copy link
Author

If this is not acceptable another alternative I would be open to is {background.alpha_hex} similar to {background.alpha_dec}

pywal/pywal/util.py

Lines 46 to 49 in 4997a49

@property
def alpha_dec(self):
"""Export the alpha value as a decimal number in [0, 1]."""
return int(self.alpha_num) / 100

That way I could achieve the same thing in my colors-polybar.ini using built-ins

[colors]
background=#{background.alpha_hex}{background.strip}

In fact, I think I will implement this in addition to what I have.

Please let me know if you would like me to remove hex_argb

@eylles eylles mentioned this pull request Mar 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant