1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-11 13:50:56 -05:00

refactor(main): Parse args before connecting to X

This commit is contained in:
Michael Carlberg 2016-12-24 02:55:21 +01:00
parent bb0d6f580d
commit 85c915d35b

View file

@ -41,24 +41,6 @@ int main(int argc, char** argv) {
logger& logger{const_cast<decltype(logger)>(logger::make(loglevel::WARNING))}; logger& logger{const_cast<decltype(logger)>(logger::make(loglevel::WARNING))};
try { 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 // Parse command line arguments
//================================================== //==================================================
@ -85,6 +67,25 @@ int main(int argc, char** argv) {
return EXIT_FAILURE; 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 // Load user configuration
//================================================== //==================================================