diff options
author | Erik Reider <[email protected]> | 2022-12-07 06:10:11 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2022-12-07 00:10:11 -0500 |
commit | 988fb247107c469bb98ce3088ad189fa12db7cdd (patch) | |
tree | 67eafa3aef85ccb450adb3a46ed313c4ae32db6d /sway/commands/dim_inactive_colors.c | |
parent | e82e4de37f5c6fe184da62f228329a37517ccd55 (diff) |
[Feature] Dim inactive windows (#66)
Diffstat (limited to 'sway/commands/dim_inactive_colors.c')
-rw-r--r-- | sway/commands/dim_inactive_colors.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/sway/commands/dim_inactive_colors.c b/sway/commands/dim_inactive_colors.c new file mode 100644 index 00000000..db8cc299 --- /dev/null +++ b/sway/commands/dim_inactive_colors.c @@ -0,0 +1,40 @@ +#include "log.h" +#include "sway/commands.h" +#include "sway/config.h" +#include "sway/output.h" +#include "sway/tree/container.h" +#include "util.h" + +static struct cmd_results *handle_command(int argc, char **argv, char *cmd_name, + float config_option[4]) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, cmd_name, EXPECTED_AT_LEAST, 1))) { + return error; + } + + uint32_t color; + if (!parse_color(argv[0], &color)) { + return cmd_results_new(CMD_INVALID, "Invalid %s color %s", + cmd_name, argv[0]); + } + color_to_rgba(config_option, color); + + if (config->active) { + for (int i = 0; i < root->outputs->length; ++i) { + struct sway_output *output = root->outputs->items[i]; + output_damage_whole(output); + } + } + + return cmd_results_new(CMD_SUCCESS, NULL); +} + +struct cmd_results *cmd_dim_inactive_colors_unfocused(int argc, char **argv) { + return handle_command(argc, argv, "dim_inactive_colors.unfocused", + config->dim_inactive_colors.unfocused); +} + +struct cmd_results *cmd_dim_inactive_colors_urgent(int argc, char **argv) { + return handle_command(argc, argv, "dim_inactive_colors.urgent", + config->dim_inactive_colors.urgent); +} |