mirror of https://github.com/polybar/polybar.git
refactor(main): Parse args before connecting to X
This commit is contained in:
parent
bb0d6f580d
commit
85c915d35b
37
src/main.cpp
37
src/main.cpp
|
@ -41,24 +41,6 @@ int main(int argc, char** argv) {
|
|||
logger& logger{const_cast<decltype(logger)>(logger::make(loglevel::WARNING))};
|
||||
|
||||
try {
|
||||
//==================================================
|
||||
// Connect to X server
|
||||
//==================================================
|
||||
XInitThreads();
|
||||
|
||||
// Store the xcb connection pointer with a disconnect deleter
|
||||
unique_ptr<xcb_connection_t, xutils::xcb_connection_deleter> xcbconn{xutils::get_connection()};
|
||||
|
||||
if (!xcbconn) {
|
||||
logger.err("A connection to X could not be established... ");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
connection& conn{connection::make(&*xcbconn)};
|
||||
conn.preload_atoms();
|
||||
conn.query_extensions();
|
||||
conn.ensure_event_mask(conn.root(), XCB_EVENT_MASK_PROPERTY_CHANGE);
|
||||
|
||||
//==================================================
|
||||
// Parse command line arguments
|
||||
//==================================================
|
||||
|
@ -85,6 +67,25 @@ int main(int argc, char** argv) {
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Connect to X server
|
||||
//==================================================
|
||||
XInitThreads();
|
||||
|
||||
// Store the xcb connection pointer with a disconnect deleter
|
||||
unique_ptr<xcb_connection_t, xutils::xcb_connection_deleter> xcbconn{xutils::get_connection()};
|
||||
|
||||
if (!xcbconn) {
|
||||
logger.err("A connection to X could not be established... ");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
connection& conn{connection::make(&*xcbconn)};
|
||||
conn.preload_atoms();
|
||||
conn.query_extensions();
|
||||
conn.ensure_event_mask(conn.root(), XCB_EVENT_MASK_PROPERTY_CHANGE);
|
||||
|
||||
|
||||
//==================================================
|
||||
// Load user configuration
|
||||
//==================================================
|
||||
|
|
Loading…
Reference in New Issue