colors: Fix xclock colors.

This commit is contained in:
Dylan Araps 2017-07-08 22:28:45 +10:00
parent 36feca8477
commit 06a5301fa4
3 changed files with 20 additions and 8 deletions

View File

@ -56,8 +56,8 @@ rofi.color-active: {background}, {foreground}, {background}, {color10}, {backgro
rofi.color-urgent: {background}, {color9}, {background}, {color9}, {foreground}
! Xclock colors.
XClock*majorColor: {color15}
XClock*minorColor: {color15}
XClock*hourColor: {color15}
XClock*minuteColor: {color15}
XClock*secondColor: {color15}
XClock*majorColor: rgba:{color15.xrgba}
XClock*minorColor: rgba:{color15.xrgba}
XClock*hourColor: rgba:{color15.xrgba}
XClock*minuteColor: rgba:{color15.xrgba}
XClock*secondColor: rgba:{color15.xrgba}

View File

@ -7,7 +7,6 @@ import pathlib
import subprocess
# pylint: disable=too-few-public-methods
class Color:
"""Color formats."""
def __init__(self, hex_color):
@ -21,6 +20,11 @@ class Color:
"""Convert a hex color to rgb."""
return hex_to_rgb(self.hex_color)
@property
def xrgba(self):
"""Convert a hex color to xrdb rgba."""
return hex_to_xrgba(self.hex_color)
def set_grey(colors):
"""Set a grey color based on the brightness
@ -76,6 +80,12 @@ def hex_to_rgb(color):
return f"{red},{green},{blue}"
def hex_to_xrgba(color):
"""Convert a hex color to xrdb rgba."""
col = color.lower()
return f"{col[1]}{col[2]}/{col[3]}{col[4]}/{col[5]}{col[6]}/ff"
def disown(*cmd):
"""Call a system command in the background,
disown it and hide it's output."""

View File

@ -69,8 +69,10 @@ class TestUtil(unittest.TestCase):
result = util.hex_to_rgb("#98AEC2")
self.assertEqual(result, "152,174,194")
# Figure out how to test this.
# def test_disown(self):
def test_hex_to_xrgba(self):
"""> Convert #98AEC2 to XRGBA."""
result = util.hex_to_xrgba("#98AEC2")
self.assertEqual(result, "98/ae/c2/ff")
if __name__ == "__main__":