Conversation
Without a restore token the portal asks for consent each time the session is created, so the capture dialog comes back after every restart. Use CreateSession2 and Start with a persistent restore token when the portal offers InputCapture v2, and fall back to CreateSession on v1. The token is single-use, so save the one each Start returns, next to the RemoteDesktop token in $XDG_CACHE_HOME/lan-mouse and handled the same way. Close the session when Start fails: ashpd's Session has no Drop, so it would otherwise stay on the bus.
Owner
|
Your load and save token functions are overly complicated. |
cantona
force-pushed
the
libei-persist-capture
branch
from
September 28, 2026 08:43
c36592b to
b3c1d9a
Compare
A restore token lets whoever holds it skip the portal's consent dialog, but fs::write creates the file with the umask; the remote-desktop.token on the machine this was tested on was 0664. Create both token files 0600, and tighten the mode of one written by an older version where the filesystem allows it: a refused chmod only warns, since the file has already been truncated and the token still has to be written.
cantona
force-pushed
the
libei-persist-capture
branch
2 times, most recently
from
September 28, 2026 09:08
b3c1d9a to
44ec8de
Compare
Author
|
Thanks, simplified.
I also added a separate commit that writes both token files with mode 0600. |
cantona
marked this pull request as ready for review
September 28, 2026 09:20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Remember the InputCapture permission across sessions. When the portal offers InputCapture v2, create the session with
CreateSession2and callStartwithpersist_mode = ExplicitlyRevokedand the stored restore token. On v1, fall back toCreateSessionas before.$XDG_STATE_HOME/lan-mouse/input-capture-restore-token(falling back to~/.local/state; only absolute paths are used). It is written with mode 0600 through a per-process temp file and a rename, and the file work runs onspawn_blocking.Startreplaces the stored one. The stored token is dropped whenStartfails or answers without a replacement, because ashpd's errors cannot tell whether the portal saw the token.Why draft
The v2 path is untested. No portal I have access to reports InputCapture v2. On GNOME 50 (xdg-desktop-portal 1.21.1, xdg-desktop-portal-gnome 50.0), the frontend exposes
CreateSession2/Start, but the interface version is 1 and the GNOME backend implements noStart. So ashpd returnsRequiresVersion(2, 1)and the fallback runs.Testing
InputCapture portal is v1, persistence needs v2: permission cannot be remembered, and capture works as before.cargo fmt --check,clippy -D warningsandtestpass locally (workspace minuslan-mouse-gtk, whose system libraries I don't have).Testing on a portal with InputCapture v2 would be very welcome.