Automatic suspend inhibit with active TurboVNC session

27 views
Skip to first unread message

Felix Natter

unread,
Dec 21, 2024, 7:06:02 AM12/21/24
to turbovn...@googlegroups.com
Dear turbovnc developers/users,
dear DRC,

we are using systemd-logind's suspend mechanism for setting idle computers
to sleep. This works with ssh and physical sessions, but not with (T)VNC
sessions (the vncserver computer will go to sleep even if you are interacting
with the desktop in the VNC session).

You can see this when the "IdleSinceHint" of the tvnc session does not update:
$ enable logind automatic suspend (/etc/systemd/logind.conf):
IdleAction=suspend
IdleActionSec=30min
$ systemctl restart systemd-logind
$ loginctl list-sessions
$ loginctl show-session <id> -p IdleSinceHint

I could use systemd-inhibit(1) on the vncserver instance,
but I would like to reuse the tvnc session also in the
office. Of course I can run systemd-inhibit on *any* process
that runs all day, but I would like to have a more automated solution :-)

Do you have any idea/solution?

Many Thanks and Best Regards!
Felix

DRC

unread,
Dec 22, 2024, 11:44:35 AM12/22/24
to turbovn...@googlegroups.com
It seems like it may be possible by calling SetIdleHint(), but I’m not sure what criteria I should use to determine the idle state. Also, I need to do some testing to determine whether it is necessary to use the login D-Bus instance with this, which would limit you to one simultaneous session per user account.

On Dec 21, 2024, at 6:06 AM, 'Felix Natter' via TurboVNC User Discussion/Support <turbovn...@googlegroups.com> wrote:


--
You received this message because you are subscribed to the Google Groups "TurboVNC User Discussion/Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to turbovnc-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/turbovnc-users/CAPBq%2BwYNm9vC8mf8oLBLLy73eh7Rw9BwcxD9qB0eCYJtcGfevA%40mail.gmail.com.

Felix Natter

unread,
Dec 23, 2024, 8:36:20 AM12/23/24
to turbovn...@googlegroups.com
Dear DRC,

you _might_ be able to use xprintidle (https://github.com/g0hl1n/xprintidle)
for that (if that honors the VNC session and the X session reports correctly).
You can copy code from it because it is GPL-2.

One simulteanous session per user would indeed be a problem for me ;-)

Since we have other problems with sessions not being closed [1]
which leads to suspend being inhibited, I must say that this feature
is _probably_ not even high on my list (unless it is easily implemented),
(and I would check again with Ubuntu 24.04 ;))


Many Thanks and Best Regards!
Felix

DRC

unread,
Dec 23, 2024, 9:35:09 AM12/23/24
to turbovn...@googlegroups.com
I’ll look into it, but my previous message was fishing for advice regarding how to set the boolean idle state based on the non-boolean idle time, since TurboVNC already measures the latter. I presume that other applications do this based on an idle timeout? But I also presume that the timeout would have to be much shorter than the session timeout that is already configurable in the TurboVNC Server, because that feature is designed to kill sessions that have been idle for days.

On Dec 23, 2024, at 7:36 AM, 'Felix Natter' via TurboVNC User Discussion/Support <turbovn...@googlegroups.com> wrote:


--
You received this message because you are subscribed to the Google Groups "TurboVNC User Discussion/Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to turbovnc-user...@googlegroups.com.

DRC

unread,
Jan 3, 2025, 11:30:40 AMJan 3
to turbovn...@googlegroups.com

I can't make the TurboVNC sessions show up with 'loginctl list-sessions' at all.  The only thing I see in that list are GDM and the SSH sessions, so there will be a login session associated with a TurboVNC session only if there is an active connection to that TurboVNC session that uses SSH tunneling.

What am I doing wrong?  I tried on both Rocky and Ubuntu.

DRC

--
You received this message because you are subscribed to the Google Groups "TurboVNC User Discussion/Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to turbovnc-user...@googlegroups.com.

Felix Natter

unread,
Jan 3, 2025, 2:26:47 PMJan 3
to turbovn...@googlegroups.com
hello DRC,

thank you for looking into this issue! A colleague and I tried the setup again (we are both in HO),
and we also cannot see a login session generated by (turbo-)VNC. Probably this is never generated,
and we were wrong :-/

Are you saying that a TurboVNC session that uses ssh tunneling likely would stop the suspend
when working in the VNC session? Is there any other way to create a login session from VNC?

Many Thanks and Best Regards!
Felix

DRC

unread,
Jan 3, 2025, 5:34:05 PMJan 3
to turbovn...@googlegroups.com

At least in my testing, IdleSinceHint is 0 for the SSH sessions that the TurboVNC Viewer creates for tunneling, so I doubt that any of those sessions would stop the suspend.  Also, the SSH sessions (and associated logind sessions) created for tunneling only persist while the TurboVNC Viewer is connected.  If the TurboVNC session is started using the TurboVNC Session Manager, then it will have a separate logind session that persists for the life of the TurboVNC session, but that logind session remains in the "Closing" state.

TigerVNC actually does have a logind session associated with the TigerVNC session.  However, that comes at a steep price.  You can't have multiple simultaneous TigerVNC sessions (or a TigerVNC session and a local session), you have to start all TigerVNC sessions as root, and you have to statically assign a display number to each TigerVNC session (one per user.)  Also, TigerVNC doesn't appear to set IdleSinceHint either.

TurboVNC's multi-session capability is a result of creating an independent D-Bus session bus instance for every TurboVNC session.  It may be possible to feed idle state information back to the SSH session's logind session, but I strongly suspect that we couldn't do that unless we used the logind D-Bus session bus instance.  You can make a TurboVNC session use the logind D-Bus session bus instance by setting TVNC_USERDBUS=1 in the environment, but it subjects you to the same single-session limitation of TigerVNC (although not the other limitations, so the TurboVNC Session Manager would still work.)

Sorry I don't have any good ideas.  My knowledge of systemd is very limited.

DRC

Reply all
Reply to author
Forward
0 new messages