diff options
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/sway/commands.c b/sway/commands.c index d2b53783..733fb293 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -1851,7 +1851,8 @@ static struct cmd_handler bar_handlers[] = { | |||
1851 | * return error object, or NULL if color is valid. | 1851 | * return error object, or NULL if color is valid. |
1852 | */ | 1852 | */ |
1853 | static struct cmd_results *add_color(const char *name, char *buffer, const char *color) { | 1853 | static struct cmd_results *add_color(const char *name, char *buffer, const char *color) { |
1854 | if (strlen(color) != 7) { | 1854 | int len = strlen(color); |
1855 | if (len != 7 && len != 9 ) { | ||
1855 | return cmd_results_new(CMD_INVALID, name, "Invalid color definition %s", color); | 1856 | return cmd_results_new(CMD_INVALID, name, "Invalid color definition %s", color); |
1856 | } | 1857 | } |
1857 | 1858 | ||
@@ -1860,15 +1861,20 @@ static struct cmd_results *add_color(const char *name, char *buffer, const char | |||
1860 | } | 1861 | } |
1861 | 1862 | ||
1862 | int i; | 1863 | int i; |
1863 | for (i = 1; i < 7; ++i) { | 1864 | for (i = 1; i < len; ++i) { |
1864 | if (!isxdigit(color[i])) { | 1865 | if (!isxdigit(color[i])) { |
1865 | return cmd_results_new(CMD_INVALID, name, "Invalid color definition %s", color); | 1866 | return cmd_results_new(CMD_INVALID, name, "Invalid color definition %s", color); |
1866 | } | 1867 | } |
1867 | } | 1868 | } |
1868 | 1869 | ||
1869 | // copy color to buffer | 1870 | // copy color to buffer |
1870 | strncpy(buffer, color, 7); | 1871 | strncpy(buffer, color, len); |
1871 | sway_log(L_DEBUG, "Setting %s color %s for bar: %s", name, color, config->current_bar->id); | 1872 | // add default alpha channel if color was defined without it |
1873 | if (len == 7) { | ||
1874 | buffer[7] = 'f'; | ||
1875 | buffer[8] = 'f'; | ||
1876 | } | ||
1877 | sway_log(L_DEBUG, "Setting %s color %s for bar: %s", name, buffer, config->current_bar->id); | ||
1872 | 1878 | ||
1873 | return NULL; | 1879 | return NULL; |
1874 | } | 1880 | } |