Ok, so I've had a bit of a play with this and it seems there's a bit of a problem. Although, not with your code.
The inhibit doesn't work with this branch or with trunk. I tested by letting some updates build up and then tried to suspend mid way through the updates being applied, and the computer happily suspended.
I've done a bit of investigation and it seems as though there's a permissions issue.
For example, if you run:
systemd-inhibit --what="idle:sleep:shutdown" --mode=block sleep 40
and then try to suspend the computer, it suspends instantly.
However, if you run that with sudo on the front and give it your password, and then try to suspend, you get the polkit dialog telling you that suspend is inhibited.
I wrote a little helper to talk to the org.freedesktop.login1 D-BUS server and the same applies, if you run as a normal user, it looks like the inhibit calls succeed, but you can still suspend. If you run the helper as root, it works.
Couldn't test the org.gnome.SessionManager stuff as root as that's running on the session D-BUS, but I imagine the result might have been the same. So I don't think there's any point merging this until we can come up with a fix for why the inhibit doesn't work at all.
Ok, so I've had a bit of a play with this and it seems there's a bit of a problem. Although, not with your code.
The inhibit doesn't work with this branch or with trunk. I tested by letting some updates build up and then tried to suspend mid way through the updates being applied, and the computer happily suspended.
I've done a bit of investigation and it seems as though there's a permissions issue.
For example, if you run: "idle:sleep: shutdown" --mode=block sleep 40
systemd-inhibit --what=
and then try to suspend the computer, it suspends instantly.
However, if you run that with sudo on the front and give it your password, and then try to suspend, you get the polkit dialog telling you that suspend is inhibited.
I wrote a little helper to talk to the org.freedesktop .login1 D-BUS server and the same applies, if you run as a normal user, it looks like the inhibit calls succeed, but you can still suspend. If you run the helper as root, it works.
Couldn't test the org.gnome. SessionManager stuff as root as that's running on the session D-BUS, but I imagine the result might have been the same. So I don't think there's any point merging this until we can come up with a fix for why the inhibit doesn't work at all.