From cacc11e3a22962756afbc3fc8c5b1fc0275b93a4 Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Fri, 13 Jan 2017 04:50:33 +0100 Subject: [PATCH] fix: Do not require bar name to list monitors Refs #208 --- src/main.cpp | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 88896eb4..72e6333b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -61,9 +61,6 @@ int main(int argc, char** argv) { } else if (cli->has("version")) { print_build_info(version_details(args)); return EXIT_SUCCESS; - } else if (!cli->has(0)) { - cli->usage(); - return EXIT_FAILURE; } //================================================== @@ -80,11 +77,31 @@ int main(int argc, char** argv) { connection& conn{connection::make(xdisplay)}; conn.ensure_event_mask(conn.root(), XCB_EVENT_MASK_PROPERTY_CHANGE); + //================================================== + // List available XRandR entries + //================================================== + if (cli->has("list-monitors")) { + for (auto&& mon : randr_util::get_monitors(conn, conn.root(), true)) { + if (ENABLE_XRANDR_MONITORS && mon->output == XCB_NONE) { + printf("%s: %ix%i+%i+%i (XRandR monitor)\n", mon->name.c_str(), mon->w, mon->h, mon->x, mon->y); + } else { + printf("%s: %ix%i+%i+%i\n", mon->name.c_str(), mon->w, mon->h, mon->x, mon->y); + } + } + return EXIT_SUCCESS; + } + //================================================== // Load user configuration //================================================== string confpath; + // Make sure a bar name is passed in + if (!cli->has(0)) { + cli->usage(); + return EXIT_FAILURE; + } + if (cli->has("config")) { confpath = cli->get("config"); } else if (env_util::has("XDG_CONFIG_HOME")) { @@ -108,16 +125,6 @@ int main(int argc, char** argv) { printf("%s\n", bar::make(true)->settings().wmname.c_str()); return EXIT_SUCCESS; } - if (cli->has("list-monitors")) { - for (auto&& mon : randr_util::get_monitors(conn, conn.root(), true)) { - if (ENABLE_XRANDR_MONITORS && mon->output == XCB_NONE) { - printf("%s: %ix%i+%i+%i (XRandR monitor)\n", mon->name.c_str(), mon->w, mon->h, mon->x, mon->y); - } else { - printf("%s: %ix%i+%i+%i\n", mon->name.c_str(), mon->w, mon->h, mon->x, mon->y); - } - } - return EXIT_SUCCESS; - } //================================================== // Create controller and run application