diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-02-22 02:26:19 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-22 02:26:19 -0500 |
commit | 7f58ea5ec23ffded76a147a243aede34405e417b (patch) | |
tree | 5b8222416cf425c2c2dee123a13dd774fd2a368c /common/util.c | |
parent | Merge pull request #1080 from SirCmpwn/ipc-security (diff) | |
parent | Merge branch 'master' into swaylock_colors (diff) | |
download | sway-7f58ea5ec23ffded76a147a243aede34405e417b.tar.gz sway-7f58ea5ec23ffded76a147a243aede34405e417b.tar.zst sway-7f58ea5ec23ffded76a147a243aede34405e417b.zip |
Feature for #1078: Configurable swaylock colors
Diffstat (limited to 'common/util.c')
-rw-r--r-- | common/util.c | 10 |
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) { | |||
102 | } | 102 | } |
103 | 103 | ||
104 | uint32_t parse_color(const char *color) { | 104 | uint32_t parse_color(const char *color) { |
105 | if (color[0] == '#') { | ||
106 | ++color; | ||
107 | } | ||
108 | |||
105 | int len = strlen(color); | 109 | int len = strlen(color); |
106 | if (color[0] != '#' || (len != 7 && len != 9)) { | 110 | if (len != 6 && len != 8) { |
107 | sway_log(L_DEBUG, "Invalid color %s, defaulting to color 0xFFFFFFFF", color); | 111 | sway_log(L_DEBUG, "Invalid color %s, defaulting to color 0xFFFFFFFF", color); |
108 | return 0xFFFFFFFF; | 112 | return 0xFFFFFFFF; |
109 | } | 113 | } |
110 | uint32_t res = (uint32_t)strtoul(color + 1, NULL, 16); | 114 | uint32_t res = (uint32_t)strtoul(color, NULL, 16); |
111 | if (strlen(color) == 7) { | 115 | if (strlen(color) == 6) { |
112 | res = (res << 8) | 0xFF; | 116 | res = (res << 8) | 0xFF; |
113 | } | 117 | } |
114 | return res; | 118 | return res; |