Looking for a way to detect that the user has not been interacting with their XPRA session for 'x' seconds. The goal would be to do something configurable when the user has not sent any keyboard or mouse click events for the specified period of time. Mouse movements may or may not be taken into consideration depending on level of effort.
We already have a value which fits the bill exactly: the
last_user_event records when the last key event or button event was received by the server, you can see it with:
xpra info | grep client.idle_time
I think we can just add a server option (call it
idle-timeout? and make it default to 0 = disabled), we then just (re-)schedule a timer in
As for the exact action to take, the easiest thing would be to hardcode it to drop the connection with a "idle timeout" warning message. Or maybe you want to exit the server instead? (in which case this would probably need to be configurable, in a similar way to the key shortcuts in the client)
Adding a server option + timer would be excellent.
Dropping the connection with an "idle timeout" sounds like a good (and useful) default behavior and will work well for us.
Additionally, we would need to receive an event on the server somehow so that we can decide to trigger a shutdown of the server or not.
Perhaps a method that I can override that returns true for "disconnect and shutdown" or false for "just disconnect"? Or a void method in which I could invoke a shutdown if needed?
Done in r8642.
To use it:
xpra start --idle-timeout=10
Then attach and the client should get disconnected after 10 seconds of inactivity (key presses or mouse clicks).
You can also change the timeout value at runtime using xpra control:
xpra control :DISPLAY idle-timeout 120
The value zero disables the timeout.
As for overriding the code to inject your own logic, you should be able to just override (or monkey patch)
Missed bits in r8654.
Just to make it even friendlier, would it be possible to add mouse cursor events over an xpra window which has focus to the list of events that reset timeout clock?
r8679 resets the timer when:
To make it easier to debug, I've added a new debug category for the server:
-d timeout. Shows things like:
user_event() schedule_idle_timeout() idle_timer=1465, idle_timeout=20 user_event() schedule_idle_timeout() idle_timer=1467, idle_timeout=20
Something else that Scott mentioned, is the ability to have another event that fires before real the timeout so that we can trigger some things (like slowing down window updates, etc). This should probably go in a separate ticket.
If that works OK then I think we can close this and follow up in #816.
Closing this, please re-open if you have problems or follow up in #816.
this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/803