mirror of
https://github.com/swaywm/sway.git
synced 2025-11-08 13:29:50 -05:00
Write to swaynag pipe fd directly on config errors
This commit is contained in:
parent
f9a6407111
commit
a7f7d4a488
12 changed files with 227 additions and 110 deletions
|
|
@ -7,19 +7,10 @@ struct cmd_results *cmd_include(int argc, char **argv) {
|
|||
return error;
|
||||
}
|
||||
|
||||
char *errors = NULL;
|
||||
if (!load_include_configs(argv[0], config, &errors)) {
|
||||
struct cmd_results *result = cmd_results_new(CMD_INVALID, "include",
|
||||
if (!load_include_configs(argv[0], config,
|
||||
&config->swaynag_config_errors)) {
|
||||
return cmd_results_new(CMD_INVALID, "include",
|
||||
"Failed to include sub configuration file: %s", argv[0]);
|
||||
free(errors);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (errors) {
|
||||
struct cmd_results *result = cmd_results_new(CMD_INVALID, "include",
|
||||
"There are errors in the included config\n%s", errors);
|
||||
free(errors);
|
||||
return result;
|
||||
}
|
||||
|
||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#define _XOPEN_SOURCE 500
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include "sway/commands.h"
|
||||
#include "sway/config.h"
|
||||
|
|
@ -20,9 +19,7 @@ struct cmd_results *cmd_reload(int argc, char **argv) {
|
|||
list_add(bar_ids, strdup(bar->id));
|
||||
}
|
||||
|
||||
char *errors = NULL;
|
||||
if (!load_main_config(config->current_config_path, true, &errors)) {
|
||||
free(errors);
|
||||
if (!load_main_config(config->current_config_path, true, false)) {
|
||||
return cmd_results_new(CMD_FAILURE, "reload",
|
||||
"Error(s) reloading config.");
|
||||
}
|
||||
|
|
@ -47,15 +44,5 @@ struct cmd_results *cmd_reload(int argc, char **argv) {
|
|||
|
||||
arrange_windows(&root_container);
|
||||
|
||||
if (config->swaynag_pid > 0) {
|
||||
kill(config->swaynag_pid, SIGTERM);
|
||||
config->swaynag_pid = -1;
|
||||
}
|
||||
|
||||
if (errors) {
|
||||
spawn_swaynag_config_errors(config, errors);
|
||||
free(errors);
|
||||
}
|
||||
|
||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
}
|
||||
|
|
|
|||
20
sway/commands/swaynag_command.c
Normal file
20
sway/commands/swaynag_command.c
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#include <string.h>
|
||||
#include "sway/commands.h"
|
||||
#include "log.h"
|
||||
#include "stringop.h"
|
||||
|
||||
struct cmd_results *cmd_swaynag_command(int argc, char **argv) {
|
||||
struct cmd_results *error = NULL;
|
||||
if ((error = checkarg(argc, "swaynag_command", EXPECTED_AT_LEAST, 1))) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (config->swaynag_command) {
|
||||
free(config->swaynag_command);
|
||||
}
|
||||
config->swaynag_command = join_args(argv, argc);
|
||||
wlr_log(WLR_DEBUG, "Using custom swaynag command: %s",
|
||||
config->swaynag_command);
|
||||
|
||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue