core: Fix running without logind (#76)

* dbus: Move logind matches inside try-catch

* core: Don't exit when logind is absent

logind being missing is non-fatal
This commit is contained in:
gnusenpai 2024-07-18 20:03:02 +00:00 committed by GitHub
parent 9163a9f318
commit e5366d34b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -476,15 +476,14 @@ void CHypridle::setupDBUS() {
try { try {
auto reply = proxy->callMethod(method); auto reply = proxy->callMethod(method);
reply >> path; reply >> path;
} catch (std::exception& e) {
Debug::log(CRIT, "Couldn't connect to logind service ({})", e.what());
exit(1);
}
Debug::log(LOG, "Using dbus path {}", path.c_str());
m_sDBUSState.connection->addMatch("type='signal',path='" + path + "',interface='org.freedesktop.login1.Session'", handleDbusLogin, sdbus::floating_slot_t{}); m_sDBUSState.connection->addMatch("type='signal',path='" + path + "',interface='org.freedesktop.login1.Session'", handleDbusLogin, sdbus::floating_slot_t{});
m_sDBUSState.connection->addMatch("type='signal',path='/org/freedesktop/login1',interface='org.freedesktop.login1.Manager'", handleDbusSleep, sdbus::floating_slot_t{}); m_sDBUSState.connection->addMatch("type='signal',path='/org/freedesktop/login1',interface='org.freedesktop.login1.Manager'", handleDbusSleep, sdbus::floating_slot_t{});
} catch (std::exception& e) {
Debug::log(WARN, "Couldn't connect to logind service ({})", e.what());
}
Debug::log(LOG, "Using dbus path {}", path.c_str());
if (!IGNORE_SYSTEMD_INHIBIT) { if (!IGNORE_SYSTEMD_INHIBIT) {
m_sDBUSState.connection->addMatch("type='signal',path='/org/freedesktop/login1',interface='org.freedesktop.DBus.Properties'", handleDbusBlockInhibitsPropertyChanged, sdbus::floating_slot_t{}); m_sDBUSState.connection->addMatch("type='signal',path='/org/freedesktop/login1',interface='org.freedesktop.DBus.Properties'", handleDbusBlockInhibitsPropertyChanged, sdbus::floating_slot_t{});