summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2017-07-08 22:28:45 +1000
committerDylan Araps <dylan.araps@gmail.com>2017-07-08 22:28:45 +1000
commit06a5301fa4f0de823be0e7998900c977b509d0d4 (patch)
tree6f168107150f66c4c1719d6821bb78a2927c55ab
parent36feca84775b98d17c662cb1b3198b8e1dd6b23f (diff)
colors: Fix xclock colors.
-rw-r--r--pywal/templates/colors.Xresources10
-rw-r--r--pywal/util.py12
-rwxr-xr-xtests/test_util.py6
3 files changed, 20 insertions, 8 deletions
diff --git a/pywal/templates/colors.Xresources b/pywal/templates/colors.Xresources
index 65a9f2d..67fc5e4 100644
--- a/pywal/templates/colors.Xresources
+++ b/pywal/templates/colors.Xresources
@@ -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}
diff --git a/pywal/util.py b/pywal/util.py
index aa2a26e..2796d8e 100644
--- a/pywal/util.py
+++ b/pywal/util.py
@@ -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."""
diff --git a/tests/test_util.py b/tests/test_util.py
index 67ec3f7..9cb908a 100755
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -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__":