aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-10-08 09:56:34 -0400
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-10-08 09:59:38 -0400
commit09c3c33081a8b8c941cbc1eeab0e5a70e54d04ff (patch)
tree9f657329f7775cd764b60326a419d369eae8a605
parentMerge pull request #2793 from emersion/disable-swaybg (diff)
downloadsway-09c3c33081a8b8c941cbc1eeab0e5a70e54d04ff.tar.gz
sway-09c3c33081a8b8c941cbc1eeab0e5a70e54d04ff.tar.zst
sway-09c3c33081a8b8c941cbc1eeab0e5a70e54d04ff.zip
Allow swaynag to be disabled
-rw-r--r--sway/commands/swaynag_command.c15
-rw-r--r--sway/config.c3
-rw-r--r--sway/sway.5.scd3
-rw-r--r--sway/swaynag.c8
4 files changed, 23 insertions, 6 deletions
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/config.c b/sway/config.c
index 7f29347a..e95c7b35 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -137,6 +137,7 @@ void free_config(struct sway_config *config) {
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); 139 free(config->swaybg_command);
140 free(config->swaynag_command);
140 free((char *)config->current_config_path); 141 free((char *)config->current_config_path);
141 free((char *)config->current_config); 142 free((char *)config->current_config);
142 free(config); 143 free(config);
@@ -167,7 +168,7 @@ static void set_color(float dest[static 4], uint32_t color) {
167} 168}
168 169
169static void config_defaults(struct sway_config *config) { 170static void config_defaults(struct sway_config *config) {
170 config->swaynag_command = strdup("swaynag"); 171 if (!(config->swaynag_command = strdup("swaynag"))) goto cleanup;
171 config->swaynag_config_errors = (struct swaynag_instance){ 172 config->swaynag_config_errors = (struct swaynag_instance){
172 .args = "--type error " 173 .args = "--type error "
173 "--message 'There are errors in your config file' " 174 "--message 'There are errors in your config file' "
diff --git a/sway/sway.5.scd b/sway/sway.5.scd
index c7d20b17..43f0e132 100644
--- a/sway/sway.5.scd
+++ b/sway/sway.5.scd
@@ -81,6 +81,9 @@ The following commands may only be used in the configuration file.
81 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
82 results. 82 results.
83 83
84 It can be disabled by setting the command to a single dash:
85 _swaynag\_command -_
86
84The following commands cannot be used directly in the configuration file. 87The following commands cannot be used directly in the configuration file.
85They 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).
86 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;