From 1e695a84e9e8c424c308867931fcdb9b40ba382d Mon Sep 17 00:00:00 2001 From: Furkan Sahin Date: Sat, 30 Jul 2016 18:50:13 -0500 Subject: implement solid color rendering for swaybg --- common/util.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'common/util.c') diff --git a/common/util.c b/common/util.c index 31a75a9b..86120769 100644 --- a/common/util.c +++ b/common/util.c @@ -97,3 +97,16 @@ pid_t get_parent_pid(pid_t child) { return -1; } + +uint32_t parse_color(const char *color) { + int len = strlen(color); + if (color[0] != '#' || (len != 7 && len != 9)) { + sway_log(L_DEBUG, "Invalid color %s, defaulting to color 0xFFFFFFFF", color); + return 0xFFFFFFFF; + } + uint32_t res = (uint32_t)strtol(color + 1, NULL, 16); + if (strlen(color) == 7) { + res = (res << 8) | 0xFF; + } + return res; +} -- cgit v1.2.3