i3: Better error reporting when connection fails
Prints the output and exit code of 'i3 --get-socketpath' if it fails and prints the socket path if the connection fails. Ref polybar/i3ipcpp#13 Ref #2942
This commit is contained in:
parent
f5169abde2
commit
d74a4fab77
@ -1 +1 @@
|
|||||||
Subproject commit 85b444c06267fbae8e9e06877cae6f03b42acbfb
|
Subproject commit b361f1e074e21f7b43e57f7545c3e2d1ca3e1658
|
@ -7,6 +7,8 @@
|
|||||||
#include "modules/meta/base.inl"
|
#include "modules/meta/base.inl"
|
||||||
#include "utils/file.hpp"
|
#include "utils/file.hpp"
|
||||||
|
|
||||||
|
#include <i3ipc++/ipc-util.hpp>
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
namespace modules {
|
namespace modules {
|
||||||
@ -18,10 +20,15 @@ namespace modules {
|
|||||||
m_router->register_action(EVENT_NEXT, [this]() { action_next(); });
|
m_router->register_action(EVENT_NEXT, [this]() { action_next(); });
|
||||||
m_router->register_action(EVENT_PREV, [this]() { action_prev(); });
|
m_router->register_action(EVENT_PREV, [this]() { action_prev(); });
|
||||||
|
|
||||||
auto socket_path = i3ipc::get_socketpath();
|
try {
|
||||||
|
auto socket_path = i3ipc::get_socketpath();
|
||||||
if (!file_util::exists(socket_path)) {
|
if (!file_util::exists(socket_path)) {
|
||||||
throw module_error("Could not find socket: " + (socket_path.empty() ? "<empty>" : socket_path));
|
throw module_error("i3 socket does not exist: " + (socket_path.empty() ? "<empty>" : socket_path));
|
||||||
|
} else {
|
||||||
|
m_log.info("%s: Found i3 socket at '%s'", name(), socket_path);
|
||||||
|
}
|
||||||
|
} catch (const i3ipc::ipc_error& e) {
|
||||||
|
throw module_error("Could not find i3 socket: " + string(e.what()));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ipc = std::make_unique<i3ipc::connection>();
|
m_ipc = std::make_unique<i3ipc::connection>();
|
||||||
|
Loading…
Reference in New Issue
Block a user