diff options
Diffstat (limited to 'common/util.c')
-rw-r--r-- | common/util.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/common/util.c b/common/util.c index e8a88772..467aa4b5 100644 --- a/common/util.c +++ b/common/util.c @@ -123,6 +123,22 @@ uint32_t parse_color(const char *color) { return res; } +bool parse_boolean(const char *boolean, bool current) { + if (strcasecmp(boolean, "1") == 0 + || strcasecmp(boolean, "yes") == 0 + || strcasecmp(boolean, "on") == 0 + || strcasecmp(boolean, "true") == 0 + || strcasecmp(boolean, "enable") == 0 + || strcasecmp(boolean, "enabled") == 0 + || strcasecmp(boolean, "active") == 0) { + return true; + } else if (strcasecmp(boolean, "toggle") == 0) { + return !current; + } + // All other values are false to match i3 + return false; +} + char* resolve_path(const char* path) { struct stat sb; ssize_t r; |