From 93145ebc2acdcc241d07f4b12e96a600fe4e5767 Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Fri, 23 Oct 2020 20:08:56 +0100 Subject: [PATCH] main: add -v option --- docs/labwc.1.md | 6 +++++- src/main.c | 25 ++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/docs/labwc.1.md b/docs/labwc.1.md index 7e128453..9f89d23e 100644 --- a/docs/labwc.1.md +++ b/docs/labwc.1.md @@ -8,7 +8,7 @@ labwc - A Wayland stacking compositor with the look and feel of Openbox # SYNOPSIS -labwc \[\-c <*config-file*>] \[\-h] \[\-s <*startup-command*>] +labwc \[\-c <*config-file*>] \[\-h] \[\-s <*startup-command*>] [-v] # DESCRIPTION @@ -28,6 +28,10 @@ Labwc is a [WIP] free, stacking compositor for Wayland. It aims to be light-weig : Specify startup command +`-v` + +: Increase verbosity. '-v' for info; '-vv' for debug. + # CONFIGURATION AND THEMES Labwc aims to be compatible with openbox configuration and theming, with the diff --git a/src/main.c b/src/main.c index d30d0cef..efcaf5ff 100644 --- a/src/main.c +++ b/src/main.c @@ -12,7 +12,7 @@ struct rcxml rc = { 0 }; struct theme theme = { 0 }; static const char labwc_usage[] = - "Usage: labwc [-h] [-s ] [-c ]\n"; + "Usage: labwc [-h] [-s ] [-c ] [-v]\n"; static void usage(void) @@ -26,9 +26,14 @@ main(int argc, char *argv[]) { char *startup_cmd = NULL; char *config_file = NULL; + enum verbosity { + LAB_VERBOSITY_ERROR = 0, + LAB_VERBOSITY_INFO, + LAB_VERBOSITY_DEBUG, + } verbosity = LAB_VERBOSITY_ERROR; int c; - while ((c = getopt(argc, argv, "c:s:h")) != -1) { + while ((c = getopt(argc, argv, "c:s:hv")) != -1) { switch (c) { case 'c': config_file = optarg; @@ -36,6 +41,9 @@ main(int argc, char *argv[]) case 's': startup_cmd = optarg; break; + case 'v': + ++verbosity; + break; case 'h': default: usage(); @@ -45,7 +53,18 @@ main(int argc, char *argv[]) usage(); } - wlr_log_init(WLR_ERROR, NULL); + switch (verbosity) { + case LAB_VERBOSITY_ERROR: + wlr_log_init(WLR_ERROR, NULL); + break; + case LAB_VERBOSITY_INFO: + wlr_log_init(WLR_INFO, NULL); + break; + case LAB_VERBOSITY_DEBUG: + default: + wlr_log_init(WLR_DEBUG, NULL); + break; + } session_environment_init(); rcxml_read(config_file);