-
Notifications
You must be signed in to change notification settings - Fork 4
/
pivid_scan_displays.cpp
52 lines (43 loc) · 1.68 KB
/
pivid_scan_displays.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Simple command line tool to print available drivers, connectors and modes.
#include <CLI/App.hpp>
#include <CLI/Config.hpp>
#include <CLI/Formatter.hpp>
#include <fmt/core.h>
#include "display_output.h"
#include "logging_policy.h"
namespace pivid {
// Main program, parses flags and scans displays.
extern "C" int main(int const argc, char const* const* const argv) {
std::string log_arg;
CLI::App app("Print video drivers, connectors and modes");
app.add_option("--log", log_arg, "Log level/configuration");
CLI11_PARSE(app, argc, argv);
configure_logging(log_arg);
auto const logger = make_logger("pivid_scan_displays");
try {
std::shared_ptr sys = global_system();
for (auto const& listing : list_display_drivers(sys)) {
fmt::print("=== {}\n", debug(listing));
auto driver = open_display_driver(sys, listing.dev_file);
for (auto const& screen : driver->scan_screens()) {
fmt::print(
"Screen #{:<3} {} {}\n",
screen.id, screen.connector,
screen.display_detected ? "[connected]" : "[no connection]"
);
if (screen.active_mode.nominal_hz)
fmt::print(" {} [ACTIVE]\n", debug(screen.active_mode));
for (auto const& mode : screen.modes) {
if (debug(mode) != debug(screen.active_mode))
fmt::print(" {}\n", debug(mode));
}
fmt::print("\n");
}
}
} catch (std::exception const& e) {
logger->critical("{}", e.what());
return 1;
}
return 0;
}
} // namespace pivid