aboutsummaryrefslogtreecommitdiff
path: root/common/util.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-02-22 02:26:19 -0500
committerGitHub <noreply@github.com>2017-02-22 02:26:19 -0500
commit7f58ea5ec23ffded76a147a243aede34405e417b (patch)
tree5b8222416cf425c2c2dee123a13dd774fd2a368c /common/util.c
parentf68d2fb33c433d13def0921db561eb23d400683c (diff)
parent692768230385d7d63938d7a40e9253c0f028d1cb (diff)
Merge pull request #1081 from 4e554c4c/swaylock_colors
Feature for #1078: Configurable swaylock colors
Diffstat (limited to 'common/util.c')
-rw-r--r--common/util.c10
1 files changed, 7 insertions, 3 deletions
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;