main: add -v option

This commit is contained in:
Johan Malm 2020-10-23 20:08:56 +01:00
parent 109d942534
commit 93145ebc2a
2 changed files with 27 additions and 4 deletions

View file

@ -8,7 +8,7 @@ labwc - A Wayland stacking compositor with the look and feel of Openbox
# SYNOPSIS # SYNOPSIS
labwc \[\-c <*config-file*>] \[\-h] \[\-s <*startup-command*>] labwc \[\-c <*config-file*>] \[\-h] \[\-s <*startup-command*>] [-v]
# DESCRIPTION # DESCRIPTION
@ -28,6 +28,10 @@ Labwc is a [WIP] free, stacking compositor for Wayland. It aims to be light-weig
: Specify startup command : Specify startup command
`-v`
: Increase verbosity. '-v' for info; '-vv' for debug.
# CONFIGURATION AND THEMES # CONFIGURATION AND THEMES
Labwc aims to be compatible with openbox configuration and theming, with the Labwc aims to be compatible with openbox configuration and theming, with the

View file

@ -12,7 +12,7 @@ struct rcxml rc = { 0 };
struct theme theme = { 0 }; struct theme theme = { 0 };
static const char labwc_usage[] = static const char labwc_usage[] =
"Usage: labwc [-h] [-s <startup-command>] [-c <config-file>]\n"; "Usage: labwc [-h] [-s <startup-command>] [-c <config-file>] [-v]\n";
static void static void
usage(void) usage(void)
@ -26,9 +26,14 @@ main(int argc, char *argv[])
{ {
char *startup_cmd = NULL; char *startup_cmd = NULL;
char *config_file = NULL; char *config_file = NULL;
enum verbosity {
LAB_VERBOSITY_ERROR = 0,
LAB_VERBOSITY_INFO,
LAB_VERBOSITY_DEBUG,
} verbosity = LAB_VERBOSITY_ERROR;
int c; int c;
while ((c = getopt(argc, argv, "c:s:h")) != -1) { while ((c = getopt(argc, argv, "c:s:hv")) != -1) {
switch (c) { switch (c) {
case 'c': case 'c':
config_file = optarg; config_file = optarg;
@ -36,6 +41,9 @@ main(int argc, char *argv[])
case 's': case 's':
startup_cmd = optarg; startup_cmd = optarg;
break; break;
case 'v':
++verbosity;
break;
case 'h': case 'h':
default: default:
usage(); usage();
@ -45,7 +53,18 @@ main(int argc, char *argv[])
usage(); usage();
} }
switch (verbosity) {
case LAB_VERBOSITY_ERROR:
wlr_log_init(WLR_ERROR, NULL); 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(); session_environment_init();
rcxml_read(config_file); rcxml_read(config_file);