Skip to content

Suppress sleep on linux using dbus inhibitor lock#1137

Open
ConnorC432 wants to merge 8 commits intoPokemonAutomation:mainfrom
ConnorC432:sleep
Open

Suppress sleep on linux using dbus inhibitor lock#1137
ConnorC432 wants to merge 8 commits intoPokemonAutomation:mainfrom
ConnorC432:sleep

Conversation

@ConnorC432
Copy link
Contributor

#535
Sleep controller implementation (3f812f2) for linux that allows for both the screen to be kept on all the time, and for the screen to be turned off while preventing sleep.

@Mysticial
Copy link
Collaborator

Thank you for doing this!

This looks fine. I just need to figure out the Linux CI for this. (and get someone to test it) It looks like we need to install the sdbus package.

Lemme ask @pifopi and @Koi-3088 since they know the CI better than me.

@pifopi
Copy link
Member

pifopi commented Mar 20, 2026

I'm attempting this fix ConnorC432#1 Should be trivial but let's wait for CI to run before merging !

@ConnorC432
Copy link
Contributor Author

i have bundled libsdbus-c++ 2.2.1, and managed to build it on ubuntu 24. It just requires the libsystemd-dev package

sudo apt update
sudo apt upgrade
sudo apt install clang-tools libopencv-dev
sudo apt install clang-tools libopencv-dev libsdbus-c++-dev libsystemd-dev
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is libsdbus-c++-dev still needed ?

target_link_libraries(SerialPrograms PRIVATE sdbus-c++)
else()
# Use bundled library
message(STATUS "sdbus-c++ >= 2.2.1 not found, using bundled library")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not always use the bundled one ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made that change in 368a5bd

template <typename Connection>
auto make_login1_proxy(Connection& connection)
{
return make_login1_proxy(connection, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can simplify a lot the code as we do have C++20 !

Suggested change
return make_login1_proxy(connection, 0);
if constexpr (requires { sdbus::BusName{"org.freedesktop.login1"}; }) {
return sdbus::createProxy(connection,
sdbus::BusName{"org.freedesktop.login1"},
sdbus::ObjectPath{"/org/freedesktop/login1"});
} else {
return sdbus::createProxy(connection,
"org.freedesktop.login1",
"/org/freedesktop/login1");
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9497646 reverts this change, when using bundled sdbus 2.2.1 the strongly typed api is fine on its own
might still be worth adding this in case there are conflicts between sdbus 2.2.1 and an older libsystemd?

@Mysticial
Copy link
Collaborator

Verbally approving for the changes to our code. I'll let pif do the final merge when CI when everything is clear.

@pifopi
Copy link
Member

pifopi commented Mar 21, 2026

All good for me, I already approved! There is a merge conflict though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants