fix: Do not require bar name to list monitors

Refs #208
This commit is contained in:
Michael Carlberg 2017-01-13 04:50:33 +01:00
parent b48a275235
commit cacc11e3a2

View File

@ -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