diff options
author | M Stoeckl <code@mstoeckl.com> | 2019-01-20 13:51:12 -0500 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2019-01-21 12:59:42 +0100 |
commit | 1211a81aad18bbc4d9e8fb9973238ad8e7e1f688 (patch) | |
tree | 5c3f60e0219cb8b4a1b7cafb760a871661866e32 /swaynag | |
parent | Log libinput_config_status errors (diff) | |
download | sway-1211a81aad18bbc4d9e8fb9973238ad8e7e1f688.tar.gz sway-1211a81aad18bbc4d9e8fb9973238ad8e7e1f688.tar.zst sway-1211a81aad18bbc4d9e8fb9973238ad8e7e1f688.zip |
Replace wlr_log with sway_log
This commit mostly duplicates the wlr_log functions, although
with a sway_* prefix. (This is very similar to PR #2009.)
However, the logging function no longer needs to be replaceable,
so sway_log_init's second argument is used to set the exit
callback for sway_abort.
wlr_log_init is still invoked in sway/main.c
This commit makes it easier to remove the wlroots dependency for
the helper programs swaymsg, swaybg, swaybar, and swaynag.
Diffstat (limited to 'swaynag')
-rw-r--r-- | swaynag/main.c | 20 | ||||
-rw-r--r-- | swaynag/render.c | 2 | ||||
-rw-r--r-- | swaynag/swaynag.c | 20 |
3 files changed, 21 insertions, 21 deletions
diff --git a/swaynag/main.c b/swaynag/main.c index 9f00ac7e..4a785f40 100644 --- a/swaynag/main.c +++ b/swaynag/main.c | |||
@@ -47,13 +47,13 @@ int main(int argc, char **argv) { | |||
47 | exit_code = launch_status; | 47 | exit_code = launch_status; |
48 | goto cleanup; | 48 | goto cleanup; |
49 | } | 49 | } |
50 | wlr_log_init(debug ? WLR_DEBUG : WLR_ERROR, NULL); | 50 | sway_log_init(debug ? SWAY_DEBUG : SWAY_ERROR, NULL); |
51 | 51 | ||
52 | if (!config_path) { | 52 | if (!config_path) { |
53 | config_path = swaynag_get_config_path(); | 53 | config_path = swaynag_get_config_path(); |
54 | } | 54 | } |
55 | if (config_path) { | 55 | if (config_path) { |
56 | wlr_log(WLR_DEBUG, "Loading config file: %s", config_path); | 56 | sway_log(SWAY_DEBUG, "Loading config file: %s", config_path); |
57 | int config_status = swaynag_load_config(config_path, &swaynag, types); | 57 | int config_status = swaynag_load_config(config_path, &swaynag, types); |
58 | free(config_path); | 58 | free(config_path); |
59 | if (config_status != 0) { | 59 | if (config_status != 0) { |
@@ -77,7 +77,7 @@ int main(int argc, char **argv) { | |||
77 | } | 77 | } |
78 | 78 | ||
79 | if (!swaynag.message) { | 79 | if (!swaynag.message) { |
80 | wlr_log(WLR_ERROR, "No message passed. Please provide --message/-m"); | 80 | sway_log(SWAY_ERROR, "No message passed. Please provide --message/-m"); |
81 | exit_code = EXIT_FAILURE; | 81 | exit_code = EXIT_FAILURE; |
82 | goto cleanup; | 82 | goto cleanup; |
83 | } | 83 | } |
@@ -106,15 +106,15 @@ int main(int argc, char **argv) { | |||
106 | free(swaynag.details.button_details); | 106 | free(swaynag.details.button_details); |
107 | } | 107 | } |
108 | 108 | ||
109 | wlr_log(WLR_DEBUG, "Output: %s", swaynag.type->output); | 109 | sway_log(SWAY_DEBUG, "Output: %s", swaynag.type->output); |
110 | wlr_log(WLR_DEBUG, "Anchors: %d", swaynag.type->anchors); | 110 | sway_log(SWAY_DEBUG, "Anchors: %d", swaynag.type->anchors); |
111 | wlr_log(WLR_DEBUG, "Type: %s", swaynag.type->name); | 111 | sway_log(SWAY_DEBUG, "Type: %s", swaynag.type->name); |
112 | wlr_log(WLR_DEBUG, "Message: %s", swaynag.message); | 112 | sway_log(SWAY_DEBUG, "Message: %s", swaynag.message); |
113 | wlr_log(WLR_DEBUG, "Font: %s", swaynag.type->font); | 113 | sway_log(SWAY_DEBUG, "Font: %s", swaynag.type->font); |
114 | wlr_log(WLR_DEBUG, "Buttons"); | 114 | sway_log(SWAY_DEBUG, "Buttons"); |
115 | for (int i = 0; i < swaynag.buttons->length; i++) { | 115 | for (int i = 0; i < swaynag.buttons->length; i++) { |
116 | struct swaynag_button *button = swaynag.buttons->items[i]; | 116 | struct swaynag_button *button = swaynag.buttons->items[i]; |
117 | wlr_log(WLR_DEBUG, "\t[%s] `%s`", button->text, button->action); | 117 | sway_log(SWAY_DEBUG, "\t[%s] `%s`", button->text, button->action); |
118 | } | 118 | } |
119 | 119 | ||
120 | signal(SIGTERM, sig_handler); | 120 | signal(SIGTERM, sig_handler); |
diff --git a/swaynag/render.c b/swaynag/render.c index 7db9fe60..661e27a1 100644 --- a/swaynag/render.c +++ b/swaynag/render.c | |||
@@ -281,7 +281,7 @@ void render_frame(struct swaynag *swaynag) { | |||
281 | swaynag->width * swaynag->scale, | 281 | swaynag->width * swaynag->scale, |
282 | swaynag->height * swaynag->scale); | 282 | swaynag->height * swaynag->scale); |
283 | if (!swaynag->current_buffer) { | 283 | if (!swaynag->current_buffer) { |
284 | wlr_log(WLR_DEBUG, "Failed to get buffer. Skipping frame."); | 284 | sway_log(SWAY_DEBUG, "Failed to get buffer. Skipping frame."); |
285 | goto cleanup; | 285 | goto cleanup; |
286 | } | 286 | } |
287 | 287 | ||
diff --git a/swaynag/swaynag.c b/swaynag/swaynag.c index 186e9011..f0c6a3c5 100644 --- a/swaynag/swaynag.c +++ b/swaynag/swaynag.c | |||
@@ -21,24 +21,24 @@ static bool terminal_execute(char *terminal, char *command) { | |||
21 | char fname[] = "/tmp/swaynagXXXXXX"; | 21 | char fname[] = "/tmp/swaynagXXXXXX"; |
22 | FILE *tmp= fdopen(mkstemp(fname), "w"); | 22 | FILE *tmp= fdopen(mkstemp(fname), "w"); |
23 | if (!tmp) { | 23 | if (!tmp) { |
24 | wlr_log(WLR_ERROR, "Failed to create temp script"); | 24 | sway_log(SWAY_ERROR, "Failed to create temp script"); |
25 | return false; | 25 | return false; |
26 | } | 26 | } |
27 | wlr_log(WLR_DEBUG, "Created temp script: %s", fname); | 27 | sway_log(SWAY_DEBUG, "Created temp script: %s", fname); |
28 | fprintf(tmp, "#!/bin/sh\nrm %s\n%s", fname, command); | 28 | fprintf(tmp, "#!/bin/sh\nrm %s\n%s", fname, command); |
29 | fclose(tmp); | 29 | fclose(tmp); |
30 | chmod(fname, S_IRUSR | S_IWUSR | S_IXUSR); | 30 | chmod(fname, S_IRUSR | S_IWUSR | S_IXUSR); |
31 | char *cmd = malloc(sizeof(char) * (strlen(terminal) + strlen(" -e ") + strlen(fname) + 1)); | 31 | char *cmd = malloc(sizeof(char) * (strlen(terminal) + strlen(" -e ") + strlen(fname) + 1)); |
32 | sprintf(cmd, "%s -e %s", terminal, fname); | 32 | sprintf(cmd, "%s -e %s", terminal, fname); |
33 | execl("/bin/sh", "/bin/sh", "-c", cmd, NULL); | 33 | execl("/bin/sh", "/bin/sh", "-c", cmd, NULL); |
34 | wlr_log_errno(WLR_ERROR, "Failed to run command, execl() returned."); | 34 | sway_log_errno(SWAY_ERROR, "Failed to run command, execl() returned."); |
35 | free(cmd); | 35 | free(cmd); |
36 | return false; | 36 | return false; |
37 | } | 37 | } |
38 | 38 | ||
39 | static void swaynag_button_execute(struct swaynag *swaynag, | 39 | static void swaynag_button_execute(struct swaynag *swaynag, |
40 | struct swaynag_button *button) { | 40 | struct swaynag_button *button) { |
41 | wlr_log(WLR_DEBUG, "Executing [%s]: %s", button->text, button->action); | 41 | sway_log(SWAY_DEBUG, "Executing [%s]: %s", button->text, button->action); |
42 | if (button->type == SWAYNAG_ACTION_DISMISS) { | 42 | if (button->type == SWAYNAG_ACTION_DISMISS) { |
43 | swaynag->run_display = false; | 43 | swaynag->run_display = false; |
44 | } else if (button->type == SWAYNAG_ACTION_EXPAND) { | 44 | } else if (button->type == SWAYNAG_ACTION_EXPAND) { |
@@ -52,14 +52,14 @@ static void swaynag_button_execute(struct swaynag *swaynag, | |||
52 | // Child of the child. Will be reparented to the init process | 52 | // Child of the child. Will be reparented to the init process |
53 | char *terminal = getenv("TERMINAL"); | 53 | char *terminal = getenv("TERMINAL"); |
54 | if (button->terminal && terminal && strlen(terminal)) { | 54 | if (button->terminal && terminal && strlen(terminal)) { |
55 | wlr_log(WLR_DEBUG, "Found $TERMINAL: %s", terminal); | 55 | sway_log(SWAY_DEBUG, "Found $TERMINAL: %s", terminal); |
56 | if (!terminal_execute(terminal, button->action)) { | 56 | if (!terminal_execute(terminal, button->action)) { |
57 | swaynag_destroy(swaynag); | 57 | swaynag_destroy(swaynag); |
58 | exit(EXIT_FAILURE); | 58 | exit(EXIT_FAILURE); |
59 | } | 59 | } |
60 | } else { | 60 | } else { |
61 | if (button->terminal) { | 61 | if (button->terminal) { |
62 | wlr_log(WLR_DEBUG, | 62 | sway_log(SWAY_DEBUG, |
63 | "$TERMINAL not found. Running directly"); | 63 | "$TERMINAL not found. Running directly"); |
64 | } | 64 | } |
65 | execl("/bin/sh", "/bin/sh", "-c", button->action, NULL); | 65 | execl("/bin/sh", "/bin/sh", "-c", button->action, NULL); |
@@ -98,7 +98,7 @@ static void surface_enter(void *data, struct wl_surface *surface, | |||
98 | struct swaynag_output *swaynag_output; | 98 | struct swaynag_output *swaynag_output; |
99 | wl_list_for_each(swaynag_output, &swaynag->outputs, link) { | 99 | wl_list_for_each(swaynag_output, &swaynag->outputs, link) { |
100 | if (swaynag_output->wl_output == output) { | 100 | if (swaynag_output->wl_output == output) { |
101 | wlr_log(WLR_DEBUG, "Surface enter on output %s", | 101 | sway_log(SWAY_DEBUG, "Surface enter on output %s", |
102 | swaynag_output->name); | 102 | swaynag_output->name); |
103 | swaynag->output = swaynag_output; | 103 | swaynag->output = swaynag_output; |
104 | swaynag->scale = swaynag->output->scale; | 104 | swaynag->scale = swaynag->output->scale; |
@@ -273,10 +273,10 @@ static void xdg_output_handle_name(void *data, | |||
273 | struct zxdg_output_v1 *xdg_output, const char *name) { | 273 | struct zxdg_output_v1 *xdg_output, const char *name) { |
274 | struct swaynag_output *swaynag_output = data; | 274 | struct swaynag_output *swaynag_output = data; |
275 | char *outname = swaynag_output->swaynag->type->output; | 275 | char *outname = swaynag_output->swaynag->type->output; |
276 | wlr_log(WLR_DEBUG, "Checking against output %s for %s", name, outname); | 276 | sway_log(SWAY_DEBUG, "Checking against output %s for %s", name, outname); |
277 | if (!swaynag_output->swaynag->output && outname && name | 277 | if (!swaynag_output->swaynag->output && outname && name |
278 | && strcmp(outname, name) == 0) { | 278 | && strcmp(outname, name) == 0) { |
279 | wlr_log(WLR_DEBUG, "Using output %s", name); | 279 | sway_log(SWAY_DEBUG, "Using output %s", name); |
280 | swaynag_output->swaynag->output = swaynag_output; | 280 | swaynag_output->swaynag->output = swaynag_output; |
281 | } | 281 | } |
282 | swaynag_output->name = strdup(name); | 282 | swaynag_output->name = strdup(name); |
@@ -368,7 +368,7 @@ void swaynag_setup(struct swaynag *swaynag) { | |||
368 | } | 368 | } |
369 | 369 | ||
370 | if (!swaynag->output && swaynag->type->output) { | 370 | if (!swaynag->output && swaynag->type->output) { |
371 | wlr_log(WLR_ERROR, "Output '%s' not found", swaynag->type->output); | 371 | sway_log(SWAY_ERROR, "Output '%s' not found", swaynag->type->output); |
372 | swaynag_destroy(swaynag); | 372 | swaynag_destroy(swaynag); |
373 | exit(EXIT_FAILURE); | 373 | exit(EXIT_FAILURE); |
374 | } | 374 | } |