diff --git a/src/config_libconfig.c b/src/config_libconfig.c
index 43011bc..16e965f 100644
--- a/src/config_libconfig.c
+++ b/src/config_libconfig.c
@@ -21,21 +21,6 @@
#pragma GCC diagnostic error "-Wunused-parameter"
-/**
- * Hex color to rgb
- */
-struct color hex_to_rgb(const char *hex) {
- struct color rgb;
- // Ignore the # in front of the string
- const char *sane_hex = hex + 1;
- int hex_color = (int)strtol(sane_hex, NULL, 16);
- rgb.red = (float)(hex_color >> 16) / 256;
- rgb.green = (float)((hex_color & 0x00ff00) >> 8) / 256;
- rgb.blue = (float)(hex_color & 0x0000ff) / 256;
-
- return rgb;
-}
-
/**
* Wrapper of libconfig's config_lookup_int.
*
diff --git a/src/options.c b/src/options.c
index 436b82d..eb9e29a 100644
--- a/src/options.c
+++ b/src/options.c
@@ -96,6 +96,9 @@ static void usage(const char *argv0, int ret) {
"--write-pid-path path\n"
" Write process ID to a file.\n"
"\n"
+ "--shadow-color color\n"
+ " Color of shadow, as a hex RGB string (defaults to #000000)\n"
+ "\n"
"--shadow-red value\n"
" Red color value of shadow (0.0 - 1.0, defaults to 0).\n"
"\n"
@@ -435,6 +438,7 @@ static const struct option longopts[] = {
{"blur-method", required_argument, NULL, 328},
{"blur-size", required_argument, NULL, 329},
{"blur-deviation", required_argument, NULL, 330},
+ {"shadow-color", required_argument, NULL, 331},
{"experimental-backends", no_argument, NULL, 733},
{"monitor-repaint", no_argument, NULL, 800},
{"diagnostics", no_argument, NULL, 801},
@@ -604,6 +608,14 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable,
case 256:
// --config
break;
+ case 331:;
+ // --shadow-color
+ struct color rgb;
+ rgb = hex_to_rgb(optarg);
+ opt->shadow_red = rgb.red;
+ opt->shadow_green = rgb.green;
+ opt->shadow_blue = rgb.blue;
+ break;
case 257:
// --shadow-red
opt->shadow_red = atof(optarg);
diff --git a/src/utils.h b/src/utils.h
index 31bf274..683c7a3 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -15,6 +15,7 @@
#include
#include "compiler.h"
+#include "types.h"
#define ARR_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
@@ -165,6 +166,21 @@ static inline double attr_const normalize_d(double d) {
return normalize_d_range(d, 0.0, 1.0);
}
+/**
+ * Convert a hex RGB string to RGB
+ */
+static inline struct color hex_to_rgb(const char *hex) {
+ struct color rgb;
+ // Ignore the # in front of the string
+ const char *sane_hex = hex + 1;
+ int hex_color = (int)strtol(sane_hex, NULL, 16);
+ rgb.red = (float)(hex_color >> 16) / 256;
+ rgb.green = (float)((hex_color & 0x00ff00) >> 8) / 256;
+ rgb.blue = (float)(hex_color & 0x0000ff) / 256;
+
+ return rgb;
+}
+
attr_noret void
report_allocation_failure(const char *func, const char *file, unsigned int line);