diff --git a/include/common/log.h b/include/common/log.h index e3beb8cb..81ece2a7 100644 --- a/include/common/log.h +++ b/include/common/log.h @@ -1,19 +1,9 @@ #ifndef __LABWC_LOG_H #define __LABWC_LOG_H -/** - * info - print info message - */ -void info(const char *msg, ...); - /** * warn - print warning */ void warn(const char *err, ...); -/** - * die - print fatal message and exit() - */ -void die(const char *err, ...); - #endif /* __LABWC_LOG_H */ diff --git a/src/common/dir.c b/src/common/dir.c index c3a7f09e..82889af2 100644 --- a/src/common/dir.c +++ b/src/common/dir.c @@ -85,7 +85,7 @@ find_dir(struct ctx *ctx) /* handle /etc/xdg... */ ctx->build_path_fn(ctx, NULL, d.path); if (debug) { - info("%s", ctx->buf); + fprintf(stderr, "%s\n", ctx->buf); } if (isdir(ctx->buf)) { return ctx->buf; @@ -100,7 +100,7 @@ find_dir(struct ctx *ctx) for (gchar **p = prefixes; *p; p++) { ctx->build_path_fn(ctx, *p, d.path); if (debug) { - info("%s", ctx->buf); + fprintf(stderr, "%s\n", ctx->buf); } if (isdir(ctx->buf)) { g_strfreev(prefixes); diff --git a/src/common/log.c b/src/common/log.c index 8e597db1..2049e0f3 100644 --- a/src/common/log.c +++ b/src/common/log.c @@ -3,17 +3,6 @@ #include #include -void -info(const char *msg, ...) -{ - va_list params; - fprintf(stderr, "[labwc] info: "); - va_start(params, msg); - vfprintf(stderr, msg, params); - va_end(params); - fprintf(stderr, "\n"); -} - void warn(const char *err, ...) { @@ -25,14 +14,3 @@ warn(const char *err, ...) fprintf(stderr, "\n"); } -void -die(const char *err, ...) -{ - va_list params; - fprintf(stderr, "[labwc] fatal: "); - va_start(params, err); - vfprintf(stderr, err, params); - va_end(params); - fprintf(stderr, "\n"); - exit(EXIT_FAILURE); -} diff --git a/src/config/rcxml.c b/src/config/rcxml.c index dd92f702..79178501 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -10,7 +10,7 @@ #include #include #include - +#include #include "common/dir.h" #include "common/log.h" #include "common/nodename.h" @@ -273,7 +273,7 @@ static void post_processing(void) { if (!wl_list_length(&rc.keybinds)) { - info("load default key bindings"); + wlr_log(WLR_INFO, "load default key bindings"); bind("A-Escape", "Exit", NULL); bind("A-Tab", "NextWindow", NULL); bind("A-F3", "Execute", "bemenu-run"); @@ -323,7 +323,7 @@ rcxml_read(const char *filename) find_config_file(rcxml, sizeof(rcxml), filename); } if (rcxml[0] == '\0') { - info("cannot find rc.xml config file; using defaults"); + wlr_log(WLR_INFO, "cannot find rc.xml config file"); goto no_config; } @@ -333,7 +333,7 @@ rcxml_read(const char *filename) warn("cannot read (%s)", rcxml); goto no_config; } - info("read config file (%s)", rcxml); + wlr_log(WLR_INFO, "read config file %s", rcxml); buf_init(&b); while (getline(&line, &len, stream) != -1) { char *p = strrchr(line, '\n'); diff --git a/src/config/session.c b/src/config/session.c index b046bece..695a79e1 100644 --- a/src/config/session.c +++ b/src/config/session.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "common/dir.h" #include "common/log.h" #include "common/spawn.h" @@ -52,7 +53,7 @@ read_environment_file(const char *filename) if (!stream) { return; } - info("read environment file (%s)", filename); + wlr_log(WLR_INFO, "read environment file %s", filename); while (getline(&line, &len, stream) != -1) { char *p = strrchr(line, '\n'); if (p) { @@ -101,7 +102,7 @@ session_autostart_init(void) warn("no autostart file"); goto out; } - info("run autostart file (%s)", autostart); + wlr_log(WLR_INFO, "run autostart file %s", autostart); int len = strlen(autostart) + 4; char *cmd = calloc(len, 1); strcat(cmd, "sh "); diff --git a/src/main.c b/src/main.c index 23a13d91..6f8092ad 100644 --- a/src/main.c +++ b/src/main.c @@ -59,7 +59,8 @@ main(int argc, char *argv[]) rcxml_read(config_file); if (!getenv("XDG_RUNTIME_DIR")) { - die("XDG_RUNTIME_DIR is unset"); + wlr_log(WLR_ERROR, "XDG_RUNTIME_DIR is unset"); + exit(EXIT_FAILURE); } struct server server = { 0 }; diff --git a/src/menu/menu.c b/src/menu/menu.c index 0709cf68..81d4c76b 100644 --- a/src/menu/menu.c +++ b/src/menu/menu.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "common/buf.h" #include "common/dir.h" #include "common/font.h" @@ -209,7 +210,7 @@ parse_xml(const char *filename, struct menu *menu) warn("cannot read (%s)", menuxml); return; } - info("read menu file (%s)", menuxml); + wlr_log(WLR_INFO, "read menu file %s", menuxml); buf_init(&b); while (getline(&line, &len, stream) != -1) { char *p = strrchr(line, '\n'); diff --git a/src/output.c b/src/output.c index 43036aa4..a3c1e930 100644 --- a/src/output.c +++ b/src/output.c @@ -834,7 +834,7 @@ new_output_notify(struct wl_listener *listener, void *data) */ if (getenv("LABWC_ADAPTIVE_SYNC")) { - info("Set %s adaptive sync to 'true'", wlr_output->name); + wlr_log(WLR_INFO, "enable adaptive sync on %s", wlr_output->name); wlr_output_enable_adaptive_sync(wlr_output, true); } wlr_output_layout_add_auto(server->output_layout, wlr_output); diff --git a/src/seat.c b/src/seat.c index 8beef3dc..e5a1dbec 100644 --- a/src/seat.c +++ b/src/seat.c @@ -31,7 +31,7 @@ configure_libinput(struct wlr_input_device *wlr_input_device) if (libinput_device_config_tap_get_finger_count(libinput_dev) <= 0) { return; } - info("tap enabled for libinput device"); + wlr_log(WLR_INFO, "tap enabled"); libinput_device_config_tap_set_enabled(libinput_dev, LIBINPUT_CONFIG_TAP_ENABLED); } diff --git a/src/server.c b/src/server.c index 036ee7a6..a9d23927 100644 --- a/src/server.c +++ b/src/server.c @@ -24,13 +24,14 @@ static struct server *g_server; static void reload_config_and_theme(void) { + damage_all_outputs(g_server); + /* TODO: use rc.config_path */ rcxml_finish(); rcxml_read(NULL); theme_finish(g_server->theme); theme_init(g_server->theme, g_server->renderer, rc.theme_name); menu_reconfigure(g_server, g_server->rootmenu); - damage_all_outputs(g_server); } static int @@ -54,14 +55,17 @@ drop_permissions(void) { if (getuid() != geteuid() || getgid() != getegid()) { if (setgid(getgid())) { - die("unable to drop root group"); + wlr_log(WLR_ERROR, "unable to drop root group"); + exit(EXIT_FAILURE); } if (setuid(getuid())) { - die("unable to drop root user"); + wlr_log(WLR_ERROR, "unable to drop root user"); + exit(EXIT_FAILURE); } } if (setgid(0) != -1 || setuid(0) != -1) { - die("unable to drop root"); + wlr_log(WLR_ERROR, "unable to drop root"); + exit(EXIT_FAILURE); } } diff --git a/src/theme.c b/src/theme.c index f80e2448..ca760ed5 100644 --- a/src/theme.c +++ b/src/theme.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "common/dir.h" #include "common/font.h" @@ -191,12 +192,11 @@ theme_read(struct theme *theme, const char *theme_name) } if (!stream) { if (theme_name) { - info("cannot find theme (%s), using built-in", - theme_name); + wlr_log(WLR_INFO, "cannot find theme %s", theme_name); } return; } - info("read themerc (%s)", themerc); + wlr_log(WLR_INFO, "read theme %s", themerc); while (getline(&line, &len, stream) != -1) { char *p = strrchr(line, '\n'); if (p) {