summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-08-02 21:37:29 -0400
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-08-03 10:37:35 -0400
commita7f7d4a488c8d3b2461122765f9904c8a411a583 (patch)
tree7abee51265a8b9550c62255d0c6649935ee1d6a2 /include
parentShow swaynag on config errors (diff)
downloadsway-a7f7d4a488c8d3b2461122765f9904c8a411a583.tar.gz
sway-a7f7d4a488c8d3b2461122765f9904c8a411a583.tar.zst
sway-a7f7d4a488c8d3b2461122765f9904c8a411a583.zip
Write to swaynag pipe fd directly on config errors
Diffstat (limited to 'include')
-rw-r--r--include/sway/commands.h1
-rw-r--r--include/sway/config.h14
-rw-r--r--include/sway/swaynag.h33
3 files changed, 42 insertions, 6 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h
index 41858ccc..f83907b2 100644
--- a/include/sway/commands.h
+++ b/include/sway/commands.h
@@ -150,6 +150,7 @@ sway_cmd cmd_splitt;
150sway_cmd cmd_splitv; 150sway_cmd cmd_splitv;
151sway_cmd cmd_sticky; 151sway_cmd cmd_sticky;
152sway_cmd cmd_swaybg_command; 152sway_cmd cmd_swaybg_command;
153sway_cmd cmd_swaynag_command;
153sway_cmd cmd_swap; 154sway_cmd cmd_swap;
154sway_cmd cmd_title_format; 155sway_cmd cmd_title_format;
155sway_cmd cmd_unmark; 156sway_cmd cmd_unmark;
diff --git a/include/sway/config.h b/include/sway/config.h
index 4fc3eadb..632aca14 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -7,6 +7,7 @@
7#include <wlr/types/wlr_box.h> 7#include <wlr/types/wlr_box.h>
8#include <xkbcommon/xkbcommon.h> 8#include <xkbcommon/xkbcommon.h>
9#include "list.h" 9#include "list.h"
10#include "swaynag.h"
10#include "tree/layout.h" 11#include "tree/layout.h"
11#include "tree/container.h" 12#include "tree/container.h"
12#include "wlr-layer-shell-unstable-v1-protocol.h" 13#include "wlr-layer-shell-unstable-v1-protocol.h"
@@ -308,7 +309,8 @@ enum focus_wrapping_mode {
308 * The configuration struct. The result of loading a config file. 309 * The configuration struct. The result of loading a config file.
309 */ 310 */
310struct sway_config { 311struct sway_config {
311 pid_t swaynag_pid; 312 char *swaynag_command;
313 struct swaynag_instance swaynag_config_errors;
312 list_t *symbols; 314 list_t *symbols;
313 list_t *modes; 315 list_t *modes;
314 list_t *bars; 316 list_t *bars;
@@ -346,6 +348,7 @@ struct sway_config {
346 bool failed; 348 bool failed;
347 bool reloading; 349 bool reloading;
348 bool reading; 350 bool reading;
351 bool validating;
349 bool auto_back_and_forth; 352 bool auto_back_and_forth;
350 bool show_marks; 353 bool show_marks;
351 354
@@ -404,18 +407,19 @@ struct sway_config {
404 * Loads the main config from the given path. is_active should be true when 407 * Loads the main config from the given path. is_active should be true when
405 * reloading the config. 408 * reloading the config.
406 */ 409 */
407bool load_main_config(const char *path, bool is_active, char **errors); 410bool load_main_config(const char *path, bool is_active, bool validating);
408 411
409/** 412/**
410 * Loads an included config. Can only be used after load_main_config. 413 * Loads an included config. Can only be used after load_main_config.
411 */ 414 */
412bool load_include_configs(const char *path, struct sway_config *config, 415bool load_include_configs(const char *path, struct sway_config *config,
413 char **errors); 416 struct swaynag_instance *swaynag);
414 417
415/** 418/**
416 * Reads the config from the given FILE. 419 * Reads the config from the given FILE.
417 */ 420 */
418bool read_config(FILE *file, struct sway_config *config, char **errors); 421bool read_config(FILE *file, struct sway_config *config,
422 struct swaynag_instance *swaynag);
419 423
420/** 424/**
421 * Free config struct 425 * Free config struct
@@ -424,8 +428,6 @@ void free_config(struct sway_config *config);
424 428
425void free_sway_variable(struct sway_variable *var); 429void free_sway_variable(struct sway_variable *var);
426 430
427void spawn_swaynag_config_errors(struct sway_config *config, char *errors);
428
429/** 431/**
430 * Does variable replacement for a string based on the config's currently loaded variables. 432 * Does variable replacement for a string based on the config's currently loaded variables.
431 */ 433 */
diff --git a/include/sway/swaynag.h b/include/sway/swaynag.h
new file mode 100644
index 00000000..ac0086a1
--- /dev/null
+++ b/include/sway/swaynag.h
@@ -0,0 +1,33 @@
1#ifndef _SWAY_SWAYNAG_H
2#define _SWAY_SWAYNAG_H
3
4struct swaynag_instance {
5 const char *args;
6 pid_t pid;
7 int fd[2];
8 bool detailed;
9};
10
11// Copy all fields of one instance to another
12void swaynag_clone(struct swaynag_instance *dest,
13 struct swaynag_instance *src);
14
15// Spawn swaynag. If swaynag->detailed, then swaynag->fd[1] will left open
16// so it can be written to. Call swaynag_show when done writing. This will
17// be automatically called by swaynag_log if the instance is not spawned and
18// swaynag->detailed is true.
19bool swaynag_spawn(const char *swaynag_command,
20 struct swaynag_instance *swaynag);
21
22// Kill the swaynag instance
23void swaynag_kill(struct swaynag_instance *swaynag);
24
25// Write a log message to swaynag->fd[1]. This will fail when swaynag->detailed
26// is false.
27void swaynag_log(const char *swaynag_command, struct swaynag_instance *swaynag,
28 const char *fmt, ...);
29
30// If swaynag->detailed, close swaynag->fd[1] so swaynag displays
31void swaynag_show(struct swaynag_instance *swaynag);
32
33#endif