diff options
author | Daniel Eklöf <daniel@ekloef.se> | 2019-06-01 21:05:09 +0200 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-06-05 11:00:10 -0400 |
commit | 190546fd315a24c04006fb1b177069933f4350da (patch) | |
tree | db0910b4931625d259f14b22a56b54095a8466bd /sway/commands | |
parent | 799f5a2cd5ffa83d73816489aa8683564bc226f7 (diff) |
add seat sub command 'xcursor_theme'
New 'seat <name> xcursor_theme <theme> [<size>]' command that
configures the default xcursor theme.
The default seat's xcursor theme is also propagated to XWayland, and
exported through the XCURSOR_THEME and XCURSOR_SIZE environment
variables. This is done every time the default seat's configuration is
changed.
Diffstat (limited to 'sway/commands')
-rw-r--r-- | sway/commands/seat.c | 1 | ||||
-rw-r--r-- | sway/commands/seat/xcursor_theme.c | 33 |
2 files changed, 34 insertions, 0 deletions
diff --git a/sway/commands/seat.c b/sway/commands/seat.c index aa36ba95..a827bf74 100644 --- a/sway/commands/seat.c +++ b/sway/commands/seat.c @@ -13,6 +13,7 @@ static struct cmd_handler seat_handlers[] = { { "fallback", seat_cmd_fallback }, { "hide_cursor", seat_cmd_hide_cursor }, { "pointer_constraint", seat_cmd_pointer_constraint }, + { "xcursor_theme", seat_cmd_xcursor_theme }, }; struct cmd_results *cmd_seat(int argc, char **argv) { diff --git a/sway/commands/seat/xcursor_theme.c b/sway/commands/seat/xcursor_theme.c new file mode 100644 index 00000000..202f35b9 --- /dev/null +++ b/sway/commands/seat/xcursor_theme.c @@ -0,0 +1,33 @@ +#define _POSIX_C_SOURCE 200809L +#include <string.h> +#include "sway/commands.h" +#include "sway/config.h" + +struct cmd_results *seat_cmd_xcursor_theme(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "xcursor_theme", EXPECTED_AT_LEAST, 1)) || + (error = checkarg(argc, "xcursor_theme", EXPECTED_AT_MOST, 2))) { + return error; + } + if (!config->handler_context.seat_config) { + return cmd_results_new(CMD_FAILURE, "No seat defined"); + } + + const char *theme_name = argv[0]; + unsigned size = 24; + + if (argc == 2) { + char *end; + size = strtoul(argv[1], &end, 10); + if (*end) { + return cmd_results_new( + CMD_INVALID, "Expected a positive integer size"); + } + } + + free(config->handler_context.seat_config->xcursor_theme.name); + config->handler_context.seat_config->xcursor_theme.name = strdup(theme_name); + config->handler_context.seat_config->xcursor_theme.size = size; + + return cmd_results_new(CMD_SUCCESS, NULL); +} |