aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <RedSoxFan@users.noreply.github.com>2018-10-08 15:18:49 -0400
committerLibravatar GitHub <noreply@github.com>2018-10-08 15:18:49 -0400
commit3f328b62768d7801f0544b31ab8f9dde3014fd1d (patch)
tree3572a9e1bff58710c22638d85ce1206af3999d94
parentRemove duplicate code (diff)
parentMerge pull request #2799 from ianyfan/commands (diff)
downloadsway-3f328b62768d7801f0544b31ab8f9dde3014fd1d.tar.gz
sway-3f328b62768d7801f0544b31ab8f9dde3014fd1d.tar.zst
sway-3f328b62768d7801f0544b31ab8f9dde3014fd1d.zip
Merge branch 'master' into popup-during-fullscreen
-rw-r--r--sway/commands/bar/status_command.c2
-rw-r--r--sway/commands/opacity.c4
-rw-r--r--sway/commands/swaybg_command.c15
-rw-r--r--sway/commands/swaynag_command.c15
-rw-r--r--sway/commands/urgent.c3
-rw-r--r--sway/config.c6
-rw-r--r--sway/config/output.c19
-rw-r--r--sway/sway.5.scd6
-rw-r--r--sway/swaynag.c8
9 files changed, 57 insertions, 21 deletions
diff --git a/sway/commands/bar/status_command.c b/sway/commands/bar/status_command.c
index 5ea22525..5b4fdc87 100644
--- a/sway/commands/bar/status_command.c
+++ b/sway/commands/bar/status_command.c
@@ -20,6 +20,8 @@ struct cmd_results *bar_cmd_status_command(int argc, char **argv) {
20 config->current_bar->status_command = new_command; 20 config->current_bar->status_command = new_command;
21 wlr_log(WLR_DEBUG, "Feeding bar with status command: %s", 21 wlr_log(WLR_DEBUG, "Feeding bar with status command: %s",
22 config->current_bar->status_command); 22 config->current_bar->status_command);
23 } else {
24 free(new_command);
23 } 25 }
24 26
25 if (config->active && !config->validating) { 27 if (config->active && !config->validating) {
diff --git a/sway/commands/opacity.c b/sway/commands/opacity.c
index 9cdaad7f..4e4fc994 100644
--- a/sway/commands/opacity.c
+++ b/sway/commands/opacity.c
@@ -21,6 +21,10 @@ struct cmd_results *cmd_opacity(int argc, char **argv) {
21 21
22 struct sway_container *con = config->handler_context.container; 22 struct sway_container *con = config->handler_context.container;
23 23
24 if (con == NULL) {
25 return cmd_results_new(CMD_FAILURE, "opacity", "No current container");
26 }
27
24 float opacity = 0.0f; 28 float opacity = 0.0f;
25 29
26 if (!parse_opacity(argv[0], &opacity)) { 30 if (!parse_opacity(argv[0], &opacity)) {
diff --git a/sway/commands/swaybg_command.c b/sway/commands/swaybg_command.c
index 36f7fdcd..b184b193 100644
--- a/sway/commands/swaybg_command.c
+++ b/sway/commands/swaybg_command.c
@@ -9,12 +9,17 @@ struct cmd_results *cmd_swaybg_command(int argc, char **argv) {
9 return error; 9 return error;
10 } 10 }
11 11
12 if (config->swaybg_command) { 12 free(config->swaybg_command);
13 free(config->swaybg_command); 13 config->swaybg_command = NULL;
14
15 char *new_command = join_args(argv, argc);
16 if (strcmp(new_command, "-") != 0) {
17 config->swaybg_command = new_command;
18 wlr_log(WLR_DEBUG, "Using custom swaybg command: %s",
19 config->swaybg_command);
20 } else {
21 free(new_command);
14 } 22 }
15 config->swaybg_command = join_args(argv, argc);
16 wlr_log(WLR_DEBUG, "Using custom swaybg command: %s",
17 config->swaybg_command);
18 23
19 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 24 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
20} 25}
diff --git a/sway/commands/swaynag_command.c b/sway/commands/swaynag_command.c
index c57a80a6..6c86f1a7 100644
--- a/sway/commands/swaynag_command.c
+++ b/sway/commands/swaynag_command.c
@@ -9,12 +9,17 @@ struct cmd_results *cmd_swaynag_command(int argc, char **argv) {
9 return error; 9 return error;
10 } 10 }
11 11
12 if (config->swaynag_command) { 12 free(config->swaynag_command);
13 free(config->swaynag_command); 13 config->swaynag_command = NULL;
14
15 char *new_command = join_args(argv, argc);
16 if (strcmp(new_command, "-") != 0) {
17 config->swaybg_command = new_command;
18 wlr_log(WLR_DEBUG, "Using custom swaynag command: %s",
19 config->swaynag_command);
20 } else {
21 free(new_command);
14 } 22 }
15 config->swaynag_command = join_args(argv, argc);
16 wlr_log(WLR_DEBUG, "Using custom swaynag command: %s",
17 config->swaynag_command);
18 23
19 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 24 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
20} 25}
diff --git a/sway/commands/urgent.c b/sway/commands/urgent.c
index 53c37d4d..4f283c55 100644
--- a/sway/commands/urgent.c
+++ b/sway/commands/urgent.c
@@ -12,6 +12,9 @@ struct cmd_results *cmd_urgent(int argc, char **argv) {
12 return error; 12 return error;
13 } 13 }
14 struct sway_container *container = config->handler_context.container; 14 struct sway_container *container = config->handler_context.container;
15 if (!container) {
16 return cmd_results_new(CMD_FAILURE, "urgent", "No current container");
17 }
15 if (!container->view) { 18 if (!container->view) {
16 return cmd_results_new(CMD_INVALID, "urgent", 19 return cmd_results_new(CMD_INVALID, "urgent",
17 "Only views can be urgent"); 20 "Only views can be urgent");
diff --git a/sway/config.c b/sway/config.c
index 070b15c8..a50e9144 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -136,6 +136,8 @@ void free_config(struct sway_config *config) {
136 free(config->floating_scroll_left_cmd); 136 free(config->floating_scroll_left_cmd);
137 free(config->floating_scroll_right_cmd); 137 free(config->floating_scroll_right_cmd);
138 free(config->font); 138 free(config->font);
139 free(config->swaybg_command);
140 free(config->swaynag_command);
139 free((char *)config->current_config_path); 141 free((char *)config->current_config_path);
140 free((char *)config->current_config); 142 free((char *)config->current_config);
141 free(config); 143 free(config);
@@ -166,7 +168,7 @@ static void set_color(float dest[static 4], uint32_t color) {
166} 168}
167 169
168static void config_defaults(struct sway_config *config) { 170static void config_defaults(struct sway_config *config) {
169 config->swaynag_command = strdup("swaynag"); 171 if (!(config->swaynag_command = strdup("swaynag"))) goto cleanup;
170 config->swaynag_config_errors = (struct swaynag_instance){ 172 config->swaynag_config_errors = (struct swaynag_instance){
171 .args = "--type error " 173 .args = "--type error "
172 "--message 'There are errors in your config file' " 174 "--message 'There are errors in your config file' "
@@ -241,6 +243,8 @@ static void config_defaults(struct sway_config *config) {
241 243
242 if (!(config->active_bar_modifiers = create_list())) goto cleanup; 244 if (!(config->active_bar_modifiers = create_list())) goto cleanup;
243 245
246 if (!(config->swaybg_command = strdup("swaybg"))) goto cleanup;
247
244 if (!(config->config_chain = create_list())) goto cleanup; 248 if (!(config->config_chain = create_list())) goto cleanup;
245 config->current_config_path = NULL; 249 config->current_config_path = NULL;
246 config->current_config = NULL; 250 config->current_config = NULL;
diff --git a/sway/config/output.c b/sway/config/output.c
index 6f337b66..2b041353 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -229,17 +229,16 @@ void apply_output_config(struct output_config *oc, struct sway_output *output) {
229 } 229 }
230 } 230 }
231 231
232 if (oc && oc->background) { 232 if (output->bg_pid != 0) {
233 if (output->bg_pid != 0) { 233 terminate_swaybg(output->bg_pid);
234 terminate_swaybg(output->bg_pid); 234 }
235 } 235 if (oc && oc->background && config->swaybg_command) {
236
237 wlr_log(WLR_DEBUG, "Setting background for output %d to %s", 236 wlr_log(WLR_DEBUG, "Setting background for output %d to %s",
238 output_i, oc->background); 237 output_i, oc->background);
239 238
240 size_t len = snprintf(NULL, 0, "%s %d \"%s\" %s %s", 239 size_t len = snprintf(NULL, 0, "%s %d \"%s\" %s %s",
241 config->swaybg_command ? config->swaybg_command : "swaybg", 240 config->swaybg_command, output_i, oc->background,
242 output_i, oc->background, oc->background_option, 241 oc->background_option,
243 oc->background_fallback ? oc->background_fallback : ""); 242 oc->background_fallback ? oc->background_fallback : "");
244 char *command = malloc(len + 1); 243 char *command = malloc(len + 1);
245 if (!command) { 244 if (!command) {
@@ -247,8 +246,8 @@ void apply_output_config(struct output_config *oc, struct sway_output *output) {
247 return; 246 return;
248 } 247 }
249 snprintf(command, len + 1, "%s %d \"%s\" %s %s", 248 snprintf(command, len + 1, "%s %d \"%s\" %s %s",
250 config->swaybg_command ? config->swaybg_command : "swaybg", 249 config->swaybg_command, output_i, oc->background,
251 output_i, oc->background, oc->background_option, 250 oc->background_option,
252 oc->background_fallback ? oc->background_fallback : ""); 251 oc->background_fallback ? oc->background_fallback : "");
253 wlr_log(WLR_DEBUG, "-> %s", command); 252 wlr_log(WLR_DEBUG, "-> %s", command);
254 253
@@ -260,6 +259,7 @@ void apply_output_config(struct output_config *oc, struct sway_output *output) {
260 free(command); 259 free(command);
261 } 260 }
262 } 261 }
262
263 if (oc) { 263 if (oc) {
264 switch (oc->dpms_state) { 264 switch (oc->dpms_state) {
265 case DPMS_ON: 265 case DPMS_ON:
@@ -353,4 +353,3 @@ void create_default_output_configs(void) {
353 list_add(config->output_configs, oc); 353 list_add(config->output_configs, oc);
354 } 354 }
355} 355}
356
diff --git a/sway/sway.5.scd b/sway/sway.5.scd
index 387edf54..28ab15df 100644
--- a/sway/sway.5.scd
+++ b/sway/sway.5.scd
@@ -71,6 +71,9 @@ The following commands may only be used in the configuration file.
71 Executes custom background _command_. Default is _swaybg_. Refer to 71 Executes custom background _command_. Default is _swaybg_. Refer to
72 *output* below for more information. 72 *output* below for more information.
73 73
74 It can be disabled by setting the command to a single dash:
75 _swaybg\_command -_
76
74*swaynag\_command* <command> 77*swaynag\_command* <command>
75 Executes custom command for _swaynag_. Default is _swaynag_. Additional 78 Executes custom command for _swaynag_. Default is _swaynag_. Additional
76 arguments may be appended to the end. This should only be used to either 79 arguments may be appended to the end. This should only be used to either
@@ -78,6 +81,9 @@ The following commands may only be used in the configuration file.
78 arguments. This should be placed at the top of the config for the best 81 arguments. This should be placed at the top of the config for the best
79 results. 82 results.
80 83
84 It can be disabled by setting the command to a single dash:
85 _swaynag\_command -_
86
81The following commands cannot be used directly in the configuration file. 87The following commands cannot be used directly in the configuration file.
82They are expected to be used with *bindsym* or at runtime through *swaymsg*(1). 88They are expected to be used with *bindsym* or at runtime through *swaymsg*(1).
83 89
diff --git a/sway/swaynag.c b/sway/swaynag.c
index d905db2b..38e74b88 100644
--- a/sway/swaynag.c
+++ b/sway/swaynag.c
@@ -11,6 +11,10 @@
11 11
12bool swaynag_spawn(const char *swaynag_command, 12bool swaynag_spawn(const char *swaynag_command,
13 struct swaynag_instance *swaynag) { 13 struct swaynag_instance *swaynag) {
14 if (!swaynag_command) {
15 return true;
16 }
17
14 if (swaynag->detailed) { 18 if (swaynag->detailed) {
15 if (pipe(swaynag->fd) != 0) { 19 if (pipe(swaynag->fd) != 0) {
16 wlr_log(WLR_ERROR, "Failed to create pipe for swaynag"); 20 wlr_log(WLR_ERROR, "Failed to create pipe for swaynag");
@@ -58,6 +62,10 @@ void swaynag_kill(struct swaynag_instance *swaynag) {
58 62
59void swaynag_log(const char *swaynag_command, struct swaynag_instance *swaynag, 63void swaynag_log(const char *swaynag_command, struct swaynag_instance *swaynag,
60 const char *fmt, ...) { 64 const char *fmt, ...) {
65 if (!swaynag_command) {
66 return;
67 }
68
61 if (!swaynag->detailed) { 69 if (!swaynag->detailed) {
62 wlr_log(WLR_ERROR, "Attempting to write to non-detailed swaynag inst"); 70 wlr_log(WLR_ERROR, "Attempting to write to non-detailed swaynag inst");
63 return; 71 return;