dwm: Sleep before attempting to reconnect to dwm
Sleep before trying to reconnect to the dwm socket after a detected disconnection. If dwm is restarted in place, in most cases the reconnect will fail before dwm gets a change to re-setup itself and the socket. A 1-second delay can provide enough time for dwm to reinitalize itself before polybar attempts to reconnect. As a result, the module can recovoer instead of the entire application just quitting.
This commit is contained in:
parent
339d059441
commit
bacfca5c3a
@ -157,6 +157,7 @@ namespace modules {
|
|||||||
return m_ipc->handle_event();
|
return m_ipc->handle_event();
|
||||||
} catch (const dwmipc::SocketClosedError& err) {
|
} catch (const dwmipc::SocketClosedError& err) {
|
||||||
m_log.err("%s: Disconnected from socket: %s", name(), err.what());
|
m_log.err("%s: Disconnected from socket: %s", name(), err.what());
|
||||||
|
sleep(chrono::duration<double>(1));
|
||||||
return reconnect_dwm();
|
return reconnect_dwm();
|
||||||
} catch (const dwmipc::IPCError& err) {
|
} catch (const dwmipc::IPCError& err) {
|
||||||
m_log.err("%s: Failed to handle event (reason: %s)", name(), err.what());
|
m_log.err("%s: Failed to handle event (reason: %s)", name(), err.what());
|
||||||
@ -248,6 +249,7 @@ namespace modules {
|
|||||||
return true;
|
return true;
|
||||||
} catch (const dwmipc::SocketClosedError& err) {
|
} catch (const dwmipc::SocketClosedError& err) {
|
||||||
m_log.err("%s: Disconnected from socket: %s", name(), err.what());
|
m_log.err("%s: Disconnected from socket: %s", name(), err.what());
|
||||||
|
sleep(chrono::duration<double>(1));
|
||||||
reconnect_dwm();
|
reconnect_dwm();
|
||||||
} catch (const dwmipc::IPCError& err) {
|
} catch (const dwmipc::IPCError& err) {
|
||||||
throw module_error(err.what());
|
throw module_error(err.what());
|
||||||
@ -376,6 +378,7 @@ namespace modules {
|
|||||||
new_title = m_ipc->get_client(m_focused_client_id)->name;
|
new_title = m_ipc->get_client(m_focused_client_id)->name;
|
||||||
} catch (const dwmipc::SocketClosedError& err) {
|
} catch (const dwmipc::SocketClosedError& err) {
|
||||||
m_log.err("%s: Disconnected from socket: %s", name(), err.what());
|
m_log.err("%s: Disconnected from socket: %s", name(), err.what());
|
||||||
|
sleep(chrono::duration<double>(1));
|
||||||
reconnect_dwm();
|
reconnect_dwm();
|
||||||
} catch (const dwmipc::IPCError& err) {
|
} catch (const dwmipc::IPCError& err) {
|
||||||
throw module_error(err.what());
|
throw module_error(err.what());
|
||||||
@ -390,6 +393,7 @@ namespace modules {
|
|||||||
m_is_floating = m_ipc->get_client(m_focused_client_id)->states.is_floating;
|
m_is_floating = m_ipc->get_client(m_focused_client_id)->states.is_floating;
|
||||||
} catch (const dwmipc::SocketClosedError& err) {
|
} catch (const dwmipc::SocketClosedError& err) {
|
||||||
m_log.err("%s: Disconnected from socket: %s", name(), err.what());
|
m_log.err("%s: Disconnected from socket: %s", name(), err.what());
|
||||||
|
sleep(chrono::duration<double>(1));
|
||||||
reconnect_dwm();
|
reconnect_dwm();
|
||||||
} catch (const dwmipc::IPCError& err) {
|
} catch (const dwmipc::IPCError& err) {
|
||||||
throw module_error(err.what());
|
throw module_error(err.what());
|
||||||
|
Loading…
Reference in New Issue
Block a user