mirror of
https://github.com/hyprwm/hypridle.git
synced 2025-12-20 01:00:01 +01:00
core: guard against dbus logind interface not existing and check if on_(un)lock_cmd is empty (#151)
* core: guard against dbus logind interface not existing * core: check if on_(un)lock_cmd is empty
This commit is contained in:
parent
ecf2a3649d
commit
4f1c165d3e
1 changed files with 7 additions and 2 deletions
|
|
@ -313,7 +313,7 @@ void CHypridle::onLocked() {
|
|||
m_isLocked = true;
|
||||
|
||||
static const auto LOCKCMD = g_pConfigManager->getValue<Hyprlang::STRING>("general:on_lock_cmd");
|
||||
if (*LOCKCMD)
|
||||
if (!std::string{*LOCKCMD}.empty())
|
||||
spawn(*LOCKCMD);
|
||||
|
||||
if (m_inhibitSleepBehavior == SLEEP_INHIBIT_LOCK_NOTIFY)
|
||||
|
|
@ -328,7 +328,7 @@ void CHypridle::onUnlocked() {
|
|||
inhibitSleep();
|
||||
|
||||
static const auto UNLOCKCMD = g_pConfigManager->getValue<Hyprlang::STRING>("general:on_unlock_cmd");
|
||||
if (*UNLOCKCMD)
|
||||
if (!std::string{*UNLOCKCMD}.empty())
|
||||
spawn(*UNLOCKCMD);
|
||||
}
|
||||
|
||||
|
|
@ -576,6 +576,11 @@ void CHypridle::handleInhibitOnDbusSleep(bool toSleep) {
|
|||
}
|
||||
|
||||
void CHypridle::inhibitSleep() {
|
||||
if (!m_sDBUSState.login) {
|
||||
Debug::log(WARN, "Can't inhibit sleep. Dbus logind interface is not available.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_sDBUSState.sleepInhibitFd.isValid()) {
|
||||
Debug::log(WARN, "Called inhibitSleep, but previous sleep inhibitor is still active!");
|
||||
m_sDBUSState.sleepInhibitFd.reset();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue