aboutsummaryrefslogtreecommitdiffstats
path: root/swaynag/swaynag.c
diff options
context:
space:
mode:
authorLibravatar M Stoeckl <code@mstoeckl.com>2019-01-20 13:51:12 -0500
committerLibravatar emersion <contact@emersion.fr>2019-01-21 12:59:42 +0100
commit1211a81aad18bbc4d9e8fb9973238ad8e7e1f688 (patch)
tree5c3f60e0219cb8b4a1b7cafb760a871661866e32 /swaynag/swaynag.c
parentLog libinput_config_status errors (diff)
downloadsway-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/swaynag.c')
-rw-r--r--swaynag/swaynag.c20
1 files changed, 10 insertions, 10 deletions
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
39static void swaynag_button_execute(struct swaynag *swaynag, 39static 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 }