From 34e2c70abcbc9ba496ab32f1f742dd7bae0ce0fe Mon Sep 17 00:00:00 2001 From: Calvin Lee Date: Tue, 21 Feb 2017 12:49:22 -0700 Subject: Feature for #1078: Configurable swaylock colors Colors are configured through the command line so that swaylock conforms to the i3lock fork 'github.com/chrjguill/i3lock-color'. Differences from it are that one letter options '-r' and '-s' are not implimentend because '-s' is already used by '--scaling' in swaylock. This commit also fixed whitespace in 'include/swaylock/swaylock.h' and changed `parse_color` in 'common/util.h' so that it can accept colors that do not start with a hash. This was done to keep compatability with the i3lock fork. --- common/util.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'common/util.c') diff --git a/common/util.c b/common/util.c index f2302676..73704afd 100644 --- a/common/util.c +++ b/common/util.c @@ -102,13 +102,17 @@ pid_t get_parent_pid(pid_t child) { } uint32_t parse_color(const char *color) { + if (color[0] == '#') { + ++color; + } + int len = strlen(color); - if (color[0] != '#' || (len != 7 && len != 9)) { + if (len != 6 && len != 8) { sway_log(L_DEBUG, "Invalid color %s, defaulting to color 0xFFFFFFFF", color); return 0xFFFFFFFF; } - uint32_t res = (uint32_t)strtoul(color + 1, NULL, 16); - if (strlen(color) == 7) { + uint32_t res = (uint32_t)strtoul(color, NULL, 16); + if (strlen(color) == 6) { res = (res << 8) | 0xFF; } return res; -- cgit v1.2.3