sway-patched-tray-menu/sway/commands/primary_selection.c
Aidan Dang c32a507303 Add primary_selection config option
See: https://github.com/swaywm/sway/issues/4511

Adds a bool config option `primary_selection`, which explicitly
enables/disables the primary selection clipboard. Defaults to enabled.

This is implemented as a launch-only option which enables or disables the creation of the
`zwp_primary_selection_device_manager_v1` global.

Co-authored-by: Tilde Rose <t1lde@protonmail.com>
2022-12-05 14:09:29 +01:00

23 lines
656 B
C

#include <string.h>
#include <strings.h>
#include "sway/config.h"
#include "sway/commands.h"
#include "util.h"
struct cmd_results *cmd_primary_selection(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "primary_selection", EXPECTED_EQUAL_TO, 1))) {
return error;
}
bool primary_selection = parse_boolean(argv[0], true);
if (config->reloading && config->primary_selection != primary_selection) {
return cmd_results_new(CMD_FAILURE,
"primary_selection can only be enabled/disabled at launch");
}
config->primary_selection = parse_boolean(argv[0], true);
return cmd_results_new(CMD_SUCCESS, NULL);
}