Hyprland IPC improvements

Fixes IPC being blocked at shutdown
This commit is contained in:
zjeffer
2025-02-19 00:58:08 +01:00
parent c32d5e3883
commit 5b8839ab5c
12 changed files with 188 additions and 154 deletions

View File

@ -10,13 +10,9 @@
namespace waybar::modules::hyprland {
Language::Language(const std::string& id, const Bar& bar, const Json::Value& config)
: ALabel(config, "language", id, "{}", 0, true), bar_(bar) {
: ALabel(config, "language", id, "{}", 0, true), bar_(bar), m_ipc(IPC::inst()) {
modulesReady = true;
if (!gIPC) {
gIPC = std::make_unique<IPC>();
}
// get the active layout when open
initLanguage();
@ -24,11 +20,11 @@ Language::Language(const std::string& id, const Bar& bar, const Json::Value& con
update();
// register for hyprland ipc
gIPC->registerForIPC("activelayout", this);
m_ipc.registerForIPC("activelayout", this);
}
Language::~Language() {
gIPC->unregisterForIPC(this);
m_ipc.unregisterForIPC(this);
// wait for possible event handler to finish
std::lock_guard<std::mutex> lg(mutex_);
}
@ -85,7 +81,7 @@ void Language::onEvent(const std::string& ev) {
}
void Language::initLanguage() {
const auto inputDevices = gIPC->getSocket1Reply("devices");
const auto inputDevices = m_ipc.getSocket1Reply("devices");
const auto kbName = config_["keyboard-name"].asString();