From a194b576be36423c64618148a6f789dd4362e9c1 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Mon, 9 Feb 2026 08:52:00 -0600 Subject: [PATCH] feat(niri): niri depends on socket Don't attempt to use niri modules when socket connection fails. Prevents rendering modules when running another compositor. In same concept as previous Hyprland change https://github.com/Alexays/Waybar/commit/4295faa7c4b23b7f6e86669d1fe8c93562e10241 Signed-off-by: Austin Horstman --- src/modules/niri/backend.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/modules/niri/backend.cpp b/src/modules/niri/backend.cpp index 1ee1bf3f..5284e0be 100644 --- a/src/modules/niri/backend.cpp +++ b/src/modules/niri/backend.cpp @@ -24,8 +24,7 @@ int IPC::connectToSocket() { const char* socket_path = getenv("NIRI_SOCKET"); if (socket_path == nullptr) { - spdlog::warn("Niri is not running, niri IPC will not be available."); - return -1; + throw std::runtime_error("Niri IPC: NIRI_SOCKET was not set! (Is Niri running?)"); } struct sockaddr_un addr; @@ -54,15 +53,9 @@ int IPC::connectToSocket() { void IPC::startIPC() { // will start IPC and relay events to parseIPC - std::thread([&]() { - int socketfd; - try { - socketfd = connectToSocket(); - } catch (std::exception& e) { - spdlog::error("Niri IPC: failed to start, reason: {}", e.what()); - return; - } - if (socketfd == -1) return; + int socketfd = connectToSocket(); + + std::thread([this, socketfd]() { spdlog::info("Niri IPC starting"); @@ -242,7 +235,6 @@ void IPC::unregisterForIPC(EventHandler* ev_handler) { Json::Value IPC::send(const Json::Value& request) { int socketfd = connectToSocket(); - if (socketfd == -1) throw std::runtime_error("Niri is not running"); auto unix_istream = Gio::UnixInputStream::create(socketfd, true); auto unix_ostream = Gio::UnixOutputStream::create(socketfd, false);