aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/primary_selection.c
blob: 9e2689c215fbcd56794447a86c160ec2c3094f04 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#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);

	// config->primary_selection is reset to the previous value on reload in
	// load_main_config()
	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 = primary_selection;

	return cmd_results_new(CMD_SUCCESS, NULL);
}