Repository navigation
Use the xdg-desktop-portal file chooser on Linux - #133
Merged
Merged
Conversation
Wails v2 draws GtkFileChooserDialog directly, which bypasses xdg-desktop-portal, so the file picker the user configured for their desktop (KDE, GTK portal, a terminal file manager, ...) is never used. Ask the portal's FileChooser over D-Bus for the five open-file and open-directory dialogs, and fall back to the Wails dialog when no portal answers.
wienieclaurowy
force-pushed
the
portal-file-chooser
branch
from
October 1, 2026 19:43
0f071bb to
9a72772
Compare
Limit the OpenFile method call to 10 seconds, so a stuck portal no longer blocks the dialog forever. Treat response 2 as an error, because portal backends send it when they fail. Match Response signals only from the portal bus name.
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.
Fixes #132.
Wails v2 draws
GtkFileChooserDialogdirectly on Linux, so Aether's file and folder dialogs never reach xdg-desktop-portal and ignore the file picker the user has configured. This routes them through the portal's FileChooser and keeps the Wails dialog as a fallback.What this changes
internal/platform/filechooser.go(new):PortalOpenFilecallsorg.freedesktop.portal.FileChooser.OpenFileover the session bus with godbus (already in the module graph through Wails;go.modjust marks it direct). It subscribes to theRequest.Responsesignal before making the call so a fast reply can't be missed, and also handles the case where the portal returns a handle other than the one derived fromhandle_token. Wails-style;-joined patterns are split into portal glob rules. Returnedfile://URIs are decoded withurl.Parse, so a+in a filename stays a+.dialogs.go(new): unexportedopenFileDialog/openDirectoryDialoghelpers onApp. On Linux they try the portal first; if the call errors (no portal running, no FileChooser backend), they log it and show the Wails dialog as before. A cancelled pick returns""just like the Wails dialog. On macOS and Windows nothing changes. The helpers are unexported, so no new frontend bindings are generated.app.go: the five existingwailsrt.OpenFileDialog/wailsrt.OpenDirectoryDialogcalls go through those helpers. Titles, filters and default directories are passed through unchanged.No new dependencies.
Behaviour to be aware of
hyprland;gtk), users get the GTK portal's file chooser instead of the in-process GTK3 dialog. It looks very close, but it is a visible change.Testing
internal/platform/filechooser_test.go: request path derivation, filter splitting, thea(sa(us))D-Bus signature of the filters, response parsing (selected, cancelled, ended, no URIs, a path with spaces and+), and rejection of malformed bodies and non-fileURIs.go test ./internal/... ./cli/...passes.go vetclean on the changed packages;gofmt -lclean on changed files.npm run check: 0 errors.npm test: 116/116 pass (frontend untouched).xdg-desktop-portal-termfilechooseras the FileChooser backend: built withmake build, launched withoutGTK_USE_PORTAL/GDK_DEBUG, opened Select Wallpaper and Choose Wallpaper Folder.dbus-monitorshowed the portalOpenFilecalls answered through the configured backend, and no fallback was logged.🤖 Generated with Claude Code