From e1fd8247e10ed8601be3c3474805fb921ee2f390 Mon Sep 17 00:00:00 2001 From: den-kloot <1522975+den-kloot@users.noreply.github.com> Date: Fri, 13 Nov 2026 14:20:22 +0100 Subject: [PATCH 1/2] omamobile-shell 0.2.128: the phone's file chooser and permission sheet survive Omarchy's Secret-portal migration Omarchy's migration 1788261467 ("Expose GNOME Keyring to sandboxed apps through the Secret portal") writes ~/.config/xdg-desktop-portal/ hyprland-portals.conf with default=hyprland;gtk and the Secret line. xdg-desktop-portal takes the user's file first, so after that migration the phone's picks in /etc/xdg/xdg-desktop-portal/hyprland-portals.conf (FileChooser=gnome;gtk, Access=omamobile;gtk) no longer applied: file dialogs were GTK 3's desktop chooser again. It needs 623 px; on the Pixel 9a's 405 px Hyprland squeezed its buffer to the screen, text drawn tall and narrow (WhatsApp web app, Attach > Photos & videos). omamobile-setup-user now adds, at each login, every line of the /etc file whose interface the user's file doesn't name yet, under a comment, and restarts xdg-desktop-portal only when it added one. No user file: nothing is made. A line the user set (FileChooser=gtk) stays. Every login, not once, since the migration can arrive with any later update. test/setup-user.sh: Omarchy's file, two logins: both lines added once, Secret kept, one portal restart; a user's own FileChooser line kept; no file made where there was none. On a Pixel 9a (omamobile-shell 0.2.127, omarchy-settings 4.5.0-3): with Omarchy's file in place a portal OpenFile opened xdg-desktop-portal-gtk; after the new step the file gained the two lines and the same call opened Nautilus (org.gnome.Nautilus), full screen; WhatsApp's Attach > Photos & videos picked a file through it. Co-Authored-By: Claude Opus 5.5 --- packages/omamobile-shell/README.md | 2 +- .../omamobile-shell/bin/omamobile-setup-user | 29 +++++++++++++++++++ packages/omamobile-shell/test/setup-user.sh | 20 +++++++++++++ packages/omamobile-shell/version | 2 +- 4 files changed, 51 insertions(+), 2 deletions(-) diff --git a/packages/omamobile-shell/README.md b/packages/omamobile-shell/README.md index 71f4ac874..8148cf93b 100644 --- a/packages/omamobile-shell/README.md +++ b/packages/omamobile-shell/README.md @@ -94,7 +94,7 @@ afterwards. ## File dialogs -Open, save and choose-a-folder requests through the portal (Qt, GTK, Electron and Flatpak apps alike) get Nautilus's libadwaita file chooser from xdg-desktop-portal-gnome, not xdg-desktop-portal-gtk's GTK 3 desktop chooser, whose Places sidebar took half of the 480 px width. Nautilus's chooser folds its sidebar away at phone width and has touch-sized rows; `hypr/phone.lua` tiles it, even when it has a parent window, so it fills the screen between the bar and the on-screen keyboard. Only FileChooser goes to the gnome backend: its other interfaces need gnome-shell. It runs without gnome-shell (its Mutter service channel is missing, so it falls back to a plain Wayland connection). xdg-desktop-portal-gtk stays as the fallback and for its other interfaces. GTK apps that would draw their own chooser in-process are sent to the portal too (`GTK_USE_PORTAL=1` for GTK 3, `GDK_DEBUG=portals` for GTK 4, in `environment.d/20-omamobile-osk.conf`); Qt Widgets apps keep Omarchy's `QT_QPA_PLATFORMTHEME=gtk3` for now. +Open, save and choose-a-folder requests through the portal (Qt, GTK, Electron and Flatpak apps alike) get Nautilus's libadwaita file chooser from xdg-desktop-portal-gnome, not xdg-desktop-portal-gtk's GTK 3 desktop chooser, whose Places sidebar took half of the 480 px width. Nautilus's chooser folds its sidebar away at phone width and has touch-sized rows; `hypr/phone.lua` tiles it, even when it has a parent window, so it fills the screen between the bar and the on-screen keyboard. Only FileChooser goes to the gnome backend: its other interfaces need gnome-shell. It runs without gnome-shell (its Mutter service channel is missing, so it falls back to a plain Wayland connection). xdg-desktop-portal-gtk stays as the fallback and for its other interfaces. Omarchy's Secret-portal migration writes the user's own `~/.config/xdg-desktop-portal/hyprland-portals.conf`, whose `default=hyprland;gtk` would hide these picks, so `omamobile-setup-user` adds the phone's lines that file doesn't name yet at each login (a line the user set stays). GTK apps that would draw their own chooser in-process are sent to the portal too (`GTK_USE_PORTAL=1` for GTK 3, `GDK_DEBUG=portals` for GTK 4, in `environment.d/20-omamobile-osk.conf`); Qt Widgets apps keep Omarchy's `QT_QPA_PLATFORMTHEME=gtk3` for now. ## Windows on a phone screen diff --git a/packages/omamobile-shell/bin/omamobile-setup-user b/packages/omamobile-shell/bin/omamobile-setup-user index b6f4c60cd..c42b48566 100755 --- a/packages/omamobile-shell/bin/omamobile-setup-user +++ b/packages/omamobile-shell/bin/omamobile-setup-user @@ -729,3 +729,32 @@ fi # installer, so run Omarchy's own script: it creates only what is missing. keyring=${OMARCHY_PATH:-/usr/share/omarchy}/install/user/default-keyring.sh if [[ -f $keyring ]]; then bash "$keyring"; fi + +# The phone's portal picks (the permission sheet for Access, Nautilus's +# chooser for FileChooser) are in /etc/xdg/xdg-desktop-portal/ +# hyprland-portals.conf. Omarchy's migration 1788261467 (the Secret portal) +# writes ~/.config/xdg-desktop-portal/hyprland-portals.conf with its own +# default=hyprland;gtk, and xdg-desktop-portal goes by the first file that +# answers: from then on file dialogs were GTK 3's desktop chooser, which +# Hyprland squeezed to the screen (623 px into 405 on the Pixel 9a, text drawn +# tall and narrow), and the permission question GTK's dialog. Every login, +# since the migration can come with any update: the user's file gets each of +# the phone's lines whose interface it doesn't name yet. One the user set +# stays as it is. +portals=${OMAMOBILE_PORTALS_CONF:-/etc/xdg/xdg-desktop-portal/hyprland-portals.conf} +user_portals=${XDG_CONFIG_HOME:-$HOME/.config}/xdg-desktop-portal/hyprland-portals.conf +if [[ -f $portals && -f $user_portals ]]; then + added= + while IFS= read -r line; do + grep -q "^${line%%=*}=" "$user_portals" && continue + if [[ -z $added ]]; then + [[ -z $(tail -c1 "$user_portals") ]] || echo >>"$user_portals" + echo "# Omarchy Mobile (omamobile-setup-user): the phone's picks from $portals" >>"$user_portals" + fi + echo "$line" >>"$user_portals" + added=1 + done < <(grep -E '^org\.freedesktop\.impl\.portal\.[A-Za-z]+=' "$portals") + if [[ -n $added ]]; then + systemctl --user try-restart xdg-desktop-portal.service 2>/dev/null || true + fi +fi diff --git a/packages/omamobile-shell/test/setup-user.sh b/packages/omamobile-shell/test/setup-user.sh index 45621364d..8ab060550 100644 --- a/packages/omamobile-shell/test/setup-user.sh +++ b/packages/omamobile-shell/test/setup-user.sh @@ -75,6 +75,7 @@ run() { OMAMOBILE_VOICE_MODELS="${RUN_VOICE_MODELS:-$t/no-voice-models}" OMAMOBILE_VOXTYPE="${RUN_VOXTYPE:-voxtype}" \ OMARCHY_PATH="${RUN_OMARCHY_PATH:-$t/omarchy}" \ OMAMOBILE_USER_UNITS="${RUN_USER_UNITS:-$t/no-user-units}" \ + OMAMOBILE_PORTALS_CONF="$pkg/portal/hyprland-portals.conf" \ bash bin/omamobile-setup-user "$@" >"$t/out" 2>&1 || { cat "$t/out"; fail "omamobile-setup-user runs"; } } run @@ -484,3 +485,22 @@ for gliff in no yes; do done rm -f "$F/gliff-server" pass "Omarchy's remote session is off on every phone, once, with or without gliff, and a user can turn it back on" + +# Omarchy's Secret-portal migration writes the user's own hyprland-portals.conf, +# which hides the phone's in /etc. Each login adds the phone's lines the file +# doesn't name yet, once, restarts the portal only then, and keeps the user's own. +hp=$t/portals; mkdir -p "$hp/.config/hypr" "$hp/.config/xdg-desktop-portal"; cp "$H"/.config/hypr/*.lua "$hp/.config/hypr/" +up=$hp/.config/xdg-desktop-portal/hyprland-portals.conf +printf '[preferred]\ndefault=hyprland;gtk\norg.freedesktop.impl.portal.Secret=gnome-keyring\n' >"$up" +RUN_HOME=$hp run; RUN_HOME=$hp run +grep -qx 'org.freedesktop.impl.portal.FileChooser=gnome;gtk' "$up" || fail "the user's portals file gets the phone's file chooser" +grep -qx 'org.freedesktop.impl.portal.Access=omamobile;gtk' "$up" || fail "the user's portals file gets the phone's permission sheet" +grep -qx 'org.freedesktop.impl.portal.Secret=gnome-keyring' "$up" || fail "Omarchy's Secret line stays" +[[ $(grep -c '^org.freedesktop.impl.portal.FileChooser=' "$up") == 1 ]] || fail "two logins add the file chooser once" +[[ $(grep -c 'try-restart xdg-desktop-portal' "$hp/calls") == 1 ]] || fail "the portal restarts once, when lines were added" +sed -i 's|^org.freedesktop.impl.portal.FileChooser=.*|org.freedesktop.impl.portal.FileChooser=gtk|' "$up" +RUN_HOME=$hp run +grep -qx 'org.freedesktop.impl.portal.FileChooser=gtk' "$up" || fail "a file chooser the user picked stays" +[[ $(grep -c '^org.freedesktop.impl.portal.FileChooser=' "$up") == 1 ]] || fail "a user's own file chooser line isn't joined by the phone's" +[[ ! -e $H/.config/xdg-desktop-portal/hyprland-portals.conf ]] || fail "without a user portals file none is made" +pass "the user's portals file (Omarchy's Secret migration) gets the phone's file chooser and permission sheet, once" diff --git a/packages/omamobile-shell/version b/packages/omamobile-shell/version index 4f079a5e5..97d931a2b 100644 --- a/packages/omamobile-shell/version +++ b/packages/omamobile-shell/version @@ -1 +1 @@ -0.2.127 +0.2.128 From ed9410ce71b5d62ed97b942d467a5ad6934fd989 Mon Sep 17 00:00:00 2001 From: den-kloot <1522975+den-kloot@users.noreply.github.com> Date: Tue, 24 Nov 2026 08:38:26 +0100 Subject: [PATCH 2/2] omamobile-shell: the portal step leaves a symlinked, read-only or other-group file alone Review of #727: - A symlinked ~/.config/xdg-desktop-portal/hyprland-portals.conf (dotfile setups) or one the user can't write is left as it is, with a line in the login's output, instead of writing through the link or failing the setup unit under set -e at every login. - A user's line with blanks around the = ("FileChooser = gtk") counts as theirs, and the key's dots are escaped in the pattern, so they no longer match any character. - The lines are only added while the file's last group is [preferred], since they go at the end. test/setup-user.sh checks each case; taking out the symlink check, the writable check, the group check, the blanks or the escaping each fails a check of its own. Co-Authored-By: Claude Opus 5.5 --- packages/omamobile-shell/README.md | 2 +- .../omamobile-shell/bin/omamobile-setup-user | 37 ++++++++++++------- packages/omamobile-shell/test/setup-user.sh | 26 ++++++++++++- 3 files changed, 50 insertions(+), 15 deletions(-) diff --git a/packages/omamobile-shell/README.md b/packages/omamobile-shell/README.md index 94d018ba9..3ded5ce8d 100644 --- a/packages/omamobile-shell/README.md +++ b/packages/omamobile-shell/README.md @@ -94,7 +94,7 @@ afterwards. ## File dialogs -Open, save and choose-a-folder requests through the portal (Qt, GTK, Electron and Flatpak apps alike) get Nautilus's libadwaita file chooser from xdg-desktop-portal-gnome, not xdg-desktop-portal-gtk's GTK 3 desktop chooser, whose Places sidebar took half of the 480 px width. Nautilus's chooser folds its sidebar away at phone width and has touch-sized rows; `hypr/phone.lua` tiles it, even when it has a parent window, so it fills the screen between the bar and the on-screen keyboard. Only FileChooser goes to the gnome backend: its other interfaces need gnome-shell. It runs without gnome-shell (its Mutter service channel is missing, so it falls back to a plain Wayland connection). xdg-desktop-portal-gtk stays as the fallback and for its other interfaces. Omarchy's Secret-portal migration writes the user's own `~/.config/xdg-desktop-portal/hyprland-portals.conf`, whose `default=hyprland;gtk` would hide these picks, so `omamobile-setup-user` adds the phone's lines that file doesn't name yet at each login (a line the user set stays). GTK apps that would draw their own chooser in-process are sent to the portal too (`GTK_USE_PORTAL=1` for GTK 3, `GDK_DEBUG=portals` for GTK 4, in `environment.d/20-omamobile-osk.conf`); Qt Widgets apps keep Omarchy's `QT_QPA_PLATFORMTHEME=gtk3` for now. +Open, save and choose-a-folder requests through the portal (Qt, GTK, Electron and Flatpak apps alike) get Nautilus's libadwaita file chooser from xdg-desktop-portal-gnome, not xdg-desktop-portal-gtk's GTK 3 desktop chooser, whose Places sidebar took half of the 480 px width. Nautilus's chooser folds its sidebar away at phone width and has touch-sized rows; `hypr/phone.lua` tiles it, even when it has a parent window, so it fills the screen between the bar and the on-screen keyboard. Only FileChooser goes to the gnome backend: its other interfaces need gnome-shell. It runs without gnome-shell (its Mutter service channel is missing, so it falls back to a plain Wayland connection). xdg-desktop-portal-gtk stays as the fallback and for its other interfaces. Omarchy's Secret-portal migration writes the user's own `~/.config/xdg-desktop-portal/hyprland-portals.conf`, whose `default=hyprland;gtk` would hide these picks, so `omamobile-setup-user` adds the phone's lines that file doesn't name yet at each login (a line the user set stays, blanks around its `=` or not). A symlinked or read-only file, or one whose last group isn't `[preferred]`, is left alone with a line in the login's output. GTK apps that would draw their own chooser in-process are sent to the portal too (`GTK_USE_PORTAL=1` for GTK 3, `GDK_DEBUG=portals` for GTK 4, in `environment.d/20-omamobile-osk.conf`); Qt Widgets apps keep Omarchy's `QT_QPA_PLATFORMTHEME=gtk3` for now. ## Windows on a phone screen diff --git a/packages/omamobile-shell/bin/omamobile-setup-user b/packages/omamobile-shell/bin/omamobile-setup-user index 7be7ebfbd..b8712622f 100755 --- a/packages/omamobile-shell/bin/omamobile-setup-user +++ b/packages/omamobile-shell/bin/omamobile-setup-user @@ -713,22 +713,33 @@ if [[ -f $keyring ]]; then bash "$keyring"; fi # Hyprland squeezed to the screen (623 px into 405 on the Pixel 9a, text drawn # tall and narrow), and the permission question GTK's dialog. Every login, # since the migration can come with any update: the user's file gets each of -# the phone's lines whose interface it doesn't name yet. One the user set -# stays as it is. +# the phone's lines whose interface it doesn't name yet (with or without +# blanks around the =). One the user set stays as it is. The lines go at the +# end, so only while the file's last group is [preferred]; a symlinked file +# (dotfile setups) or one we can't write is left alone, with a line in the +# output, rather than writing through the link or failing the login. portals=${OMAMOBILE_PORTALS_CONF:-/etc/xdg/xdg-desktop-portal/hyprland-portals.conf} user_portals=${XDG_CONFIG_HOME:-$HOME/.config}/xdg-desktop-portal/hyprland-portals.conf if [[ -f $portals && -f $user_portals ]]; then - added= - while IFS= read -r line; do - grep -q "^${line%%=*}=" "$user_portals" && continue - if [[ -z $added ]]; then - [[ -z $(tail -c1 "$user_portals") ]] || echo >>"$user_portals" - echo "# Omarchy Mobile (omamobile-setup-user): the phone's picks from $portals" >>"$user_portals" + last_group=$(grep -E '^[[:space:]]*\[' "$user_portals" | tail -n1 | tr -d '[:space:]' || true) + if [[ -L $user_portals || ! -w $user_portals ]]; then + echo "omamobile-setup-user: $user_portals is a symlink or not writable; the phone's portal picks aren't added to it" >&2 + elif [[ $last_group != '[preferred]' ]]; then + echo "omamobile-setup-user: $user_portals doesn't end in its [preferred] group; the phone's portal picks aren't added to it" >&2 + else + added= + while IFS= read -r line; do + key=${line%%=*} + grep -Eq "^[[:space:]]*${key//./\\.}[[:space:]]*=" "$user_portals" && continue + if [[ -z $added ]]; then + [[ -z $(tail -c1 "$user_portals") ]] || echo >>"$user_portals" + echo "# Omamobile (omamobile-setup-user): the phone's picks from $portals" >>"$user_portals" + fi + echo "$line" >>"$user_portals" + added=1 + done < <(grep -E '^org\.freedesktop\.impl\.portal\.[A-Za-z]+=' "$portals") + if [[ -n $added ]]; then + systemctl --user try-restart xdg-desktop-portal.service 2>/dev/null || true fi - echo "$line" >>"$user_portals" - added=1 - done < <(grep -E '^org\.freedesktop\.impl\.portal\.[A-Za-z]+=' "$portals") - if [[ -n $added ]]; then - systemctl --user try-restart xdg-desktop-portal.service 2>/dev/null || true fi fi diff --git a/packages/omamobile-shell/test/setup-user.sh b/packages/omamobile-shell/test/setup-user.sh index db849d9b3..fd6f2a929 100644 --- a/packages/omamobile-shell/test/setup-user.sh +++ b/packages/omamobile-shell/test/setup-user.sh @@ -581,4 +581,28 @@ RUN_HOME=$hp run grep -qx 'org.freedesktop.impl.portal.FileChooser=gtk' "$up" || fail "a file chooser the user picked stays" [[ $(grep -c '^org.freedesktop.impl.portal.FileChooser=' "$up") == 1 ]] || fail "a user's own file chooser line isn't joined by the phone's" [[ ! -e $H/.config/xdg-desktop-portal/hyprland-portals.conf ]] || fail "without a user portals file none is made" -pass "the user's portals file (Omarchy's Secret migration) gets the phone's file chooser and permission sheet, once" +# A user's line written with blanks around the = counts as theirs, and a dot +# in the key isn't a wildcard (an "orgXfreedesktop" line doesn't count). +printf '[preferred]\ndefault=hyprland;gtk\norg.freedesktop.impl.portal.FileChooser = kde\norgXfreedesktopXimplXportalXAccess=gtk\n' >"$up" +RUN_HOME=$hp run +[[ $(grep -c 'portal.FileChooser' "$up") == 1 ]] || fail "a user's 'FileChooser = kde' isn't joined by the phone's line" +grep -qx 'org.freedesktop.impl.portal.Access=omamobile;gtk' "$up" || fail "a key with other characters in place of the dots doesn't hide the phone's line" +# The lines go at the end, so only while [preferred] is the last group. +printf '[preferred]\ndefault=hyprland;gtk\n[other]\nkey=value\n' >"$up" +cp "$up" "$t/portals-other.conf" +RUN_HOME=$hp run +cmp -s "$up" "$t/portals-other.conf" || fail "a file whose last group isn't [preferred] is left alone" +grep -q "doesn't end in its \[preferred\] group" "$t/out" || fail "a file left alone for its last group says so" +# A symlinked file (dotfiles) or a read-only one is left alone, and the login goes on. +printf '[preferred]\ndefault=hyprland;gtk\n' >"$t/dotfiles-portals.conf" +rm "$up"; ln -s "$t/dotfiles-portals.conf" "$up" +RUN_HOME=$hp run +[[ -L $up ]] || fail "the symlink stays a symlink" +[[ $(cat "$t/dotfiles-portals.conf") == $'[preferred]\ndefault=hyprland;gtk' ]] || fail "nothing is written through a symlinked portals file" +grep -q 'is a symlink or not writable' "$t/out" || fail "a symlinked portals file left alone says so" +rm "$up"; printf '[preferred]\ndefault=hyprland;gtk\n' >"$up"; chmod a-w "$up" +RUN_HOME=$hp run +[[ $(grep -c '^org.freedesktop.impl.portal.' "$up") == 0 ]] || fail "a read-only portals file is left alone" +grep -q 'is a symlink or not writable' "$t/out" || fail "a read-only portals file left alone says so" +chmod u+w "$up" +pass "the user's portals file (Omarchy's Secret migration) gets the phone's file chooser and permission sheet, once, and a symlinked, read-only or other-group file is left alone"