From 374c91a3d579150498e871ffd5c51d7a1d62e084 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Tue, 17 Nov 2026 21:12:38 -0649 Subject: [PATCH 1/2] omamobile-shell 0.2.134: the touch file chooser and the permission sheet survive Omarchy 4.5's portal file Omarchy 4.5 gives every user a ~/.config/xdg-desktop-portal/hyprland-portals.conf with a default= line. xdg-desktop-portal (1.22.1, xdp_portal_config_find) asks each configuration file in turn for the interface's own line and then for that file's default before it goes on to the next file, so the user's default answers for FileChooser and Access, and the two lines this package ships in /etc/xdg are never reached. A web page's file input opened GTK 3's desktop dialog again, where no tap, double tap or Open enters a folder, and the permission question fell back to GTK's dialog. omamobile-setup-user now adds the two lines to the user's own file, under its [preferred] group, at any login that finds one missing (an Omarchy update may write the file again), and restarts a running xdg-desktop-portal when it changed something. A file that names the interface is left alone, whatever it names, and a user with no such file gets none. Tested: test/setup-user.sh (Omarchy's file gets both lines once and keeps its own; a second login changes and restarts nothing; an owner's own FileChooser line is kept; a rewritten file gets the lines back; no file is made where there is none) and test/all (333). On a Pixel 9a the same two lines were put into the user's file by hand and xdg-desktop-portal restarted: Chromium's file input then opened org.gnome.Nautilus, a tap opened Pictures and a folder below it, and a picked file reached the page; before, the window was xdg-desktop-portal-gtk. The package's own step then ran there against the file as Omarchy wrote it (2026-11-18): both lines went in under [preferred] and xdg-desktop-portal restarted once; a second run changed nothing and restarted nothing. --- .../omamobile-shell/bin/omamobile-setup-user | 27 +++++++++++++++ .../portal/hyprland-portals.conf | 3 ++ packages/omamobile-shell/test/all | 4 +++ packages/omamobile-shell/test/setup-user.sh | 34 +++++++++++++++++++ packages/omamobile-shell/version | 2 +- 5 files changed, 69 insertions(+), 1 deletion(-) diff --git a/packages/omamobile-shell/bin/omamobile-setup-user b/packages/omamobile-shell/bin/omamobile-setup-user index a8e0ba60a..e064e2352 100755 --- a/packages/omamobile-shell/bin/omamobile-setup-user +++ b/packages/omamobile-shell/bin/omamobile-setup-user @@ -483,6 +483,33 @@ fi if omarchy-done ensure omamobile-access-plugin; then add_plugin omamobile.access fi +# The phone's two portal choices (that sheet for Access, Nautilus's touch +# file chooser for FileChooser) are in /etc/xdg/xdg-desktop-portal/ +# hyprland-portals.conf (portal/). Omarchy 4.5 gives every user a +# hyprland-portals.conf of their own with a default= line, and +# xdg-desktop-portal (1.22, xdp_portal_config_find) asks each file in turn +# for the interface's own line and then for that file's default before it +# goes on to the next file. So the user's default answered for both, the +# phone's lines were never reached, and the file chooser was GTK 3's desktop +# dialog again, where a tap or a double tap opens no folder (seen on a Pixel +# 9a from the day it took Omarchy 4.5). The two lines go into the user's file +# too, under its [preferred] group, at any login that finds one missing: an +# Omarchy update may write the file again. A file that names the interface +# is left alone, whatever it names, so an owner who wants another backend +# says so there. xdg-desktop-portal reads its files when it starts. +portals=${XDG_CONFIG_HOME:-$HOME/.config}/xdg-desktop-portal/hyprland-portals.conf +if [[ -f $portals ]] && grep -q '^\[preferred\]' "$portals"; then + portals_changed=0 + for line in 'org.freedesktop.impl.portal.FileChooser=gnome;gtk' 'org.freedesktop.impl.portal.Access=omamobile;gtk'; do + if ! grep -q "^${line%%=*}=" "$portals"; then + sed -i "0,/^\[preferred\]/s//[preferred]\n$line/" "$portals" + portals_changed=1 + fi + done + if ((portals_changed)); then + systemctl --user try-restart xdg-desktop-portal.service 2>/dev/null || true + fi +fi # Calls (omamobile.call): incoming calls over the lock, a heads-up card when # unlocked and the in-call controls, from omatel's agent when it runs. if omarchy-done ensure omamobile-call-plugin; then diff --git a/packages/omamobile-shell/portal/hyprland-portals.conf b/packages/omamobile-shell/portal/hyprland-portals.conf index fec964c85..d24c01053 100644 --- a/packages/omamobile-shell/portal/hyprland-portals.conf +++ b/packages/omamobile-shell/portal/hyprland-portals.conf @@ -3,6 +3,9 @@ # xdg-desktop-portal reads this before /usr/share/xdg-desktop-portal/ # hyprland-portals.conf and falls through to it for every other interface, # so that file's default=hyprland;gtk still applies. +# A hyprland-portals.conf in the user's own config comes before this one, and +# one with a default= line (Omarchy 4.5's) answers for every interface, so +# omamobile-setup-user adds the two lines below to it as well. [preferred] # The permission question ("Allow Camera to use the camera?") as the phone # shell's sheet, not GTK's desktop dialog. gtk is the fallback if diff --git a/packages/omamobile-shell/test/all b/packages/omamobile-shell/test/all index 0b80220d4..4d28e09ac 100755 --- a/packages/omamobile-shell/test/all +++ b/packages/omamobile-shell/test/all @@ -1010,6 +1010,10 @@ python3 -c 'import json; assert {"id": "omamobile.access"} in json.load(open("pr grep -c 'add_plugin omamobile.access' bin/omamobile-setup-user >/dev/null || fail "existing users get the permission sheet" grep -cx 'org.freedesktop.impl.portal.Access=omamobile;gtk' portal/hyprland-portals.conf >/dev/null || fail "Hyprland's portals.conf picks the sheet for Access only" ! grep -c '^default' portal/hyprland-portals.conf >/dev/null || fail "the override leaves the default portals alone" +# The same choices go into a user's own hyprland-portals.conf, whose default= line would answer first +while IFS= read -r line; do + grep -cF "'$line'" bin/omamobile-setup-user >/dev/null || fail "omamobile-setup-user adds $line to the user's portal file" +done < <(grep '^org.freedesktop.impl.portal\.' portal/hyprland-portals.conf) # The file chooser's backend must not itself use the portal (#277): the # session's GDK_DEBUG=portals / GTK_USE_PORTAL=1 made it wait 25 s on the main # portal, which was waiting for it. diff --git a/packages/omamobile-shell/test/setup-user.sh b/packages/omamobile-shell/test/setup-user.sh index 5642ed59b..521435195 100644 --- a/packages/omamobile-shell/test/setup-user.sh +++ b/packages/omamobile-shell/test/setup-user.sh @@ -500,3 +500,37 @@ rm "$ha/.local/state/omarchy/toggles/omamobile-sleep" RUN_HOME=$ha RUN_AUTO_SLEEP=$t/auto-sleep-default run [[ ! -e $ha/.local/state/omarchy/toggles/omamobile-sleep ]] || fail "a user who turns auto-sleep off keeps it off" pass "auto-sleep: on once where the device says suspend is verified, a user's off kept" + +# The phone's portal choices in the user's own file. Omarchy 4.5's +# hyprland-portals.conf has a default= line, which answers for every +# interface before the phone's file in /etc/xdg is reached. +hp=$t/portals; mkdir -p "$hp/.config/hypr" "$hp/.config/xdg-desktop-portal" "$hp/.local/state/omarchy/done" +cp "$H"/.config/hypr/*.lua "$hp/.config/hypr/" +touch "$hp/.local/state/omarchy/done/omamobile-shell-profile" +pf=$hp/.config/xdg-desktop-portal/hyprland-portals.conf +printf '[preferred]\ndefault=hyprland;gtk\norg.freedesktop.impl.portal.Secret=gnome-keyring\n' >"$pf" +RUN_HOME=$hp run +[[ $(sed -n 1p "$pf") == '[preferred]' && $(grep -c '^\[' "$pf") == 1 ]] || fail "the user's portal file keeps its one group" +[[ $(grep -cx 'org.freedesktop.impl.portal.FileChooser=gnome;gtk' "$pf") == 1 && $(grep -cx 'org.freedesktop.impl.portal.Access=omamobile;gtk' "$pf") == 1 ]] \ + || fail "the file chooser and the permission sheet are named in the user's portal file" +[[ $(grep -cx 'default=hyprland;gtk' "$pf") == 1 && $(grep -cx 'org.freedesktop.impl.portal.Secret=gnome-keyring' "$pf") == 1 ]] || fail "Omarchy's own lines are kept" +[[ $(grep -cx 'systemctl --user try-restart xdg-desktop-portal.service' "$hp/calls") == 1 ]] || fail "a running xdg-desktop-portal is restarted to read it" +before=$(sha256sum <"$pf") +RUN_HOME=$hp run +[[ $(sha256sum <"$pf") == "$before" && $(grep -cx 'systemctl --user try-restart xdg-desktop-portal.service' "$hp/calls") == 1 ]] \ + || fail "a file that has the lines is left alone, and nothing is restarted for it" +# The owner's own backend for an interface stays theirs +printf '[preferred]\ndefault=hyprland;gtk\norg.freedesktop.impl.portal.FileChooser=gtk\n' >"$pf" +RUN_HOME=$hp run +[[ $(grep -c 'impl.portal.FileChooser=' "$pf") == 1 ]] && grep -cx 'org.freedesktop.impl.portal.FileChooser=gtk' "$pf" >/dev/null \ + || fail "an owner's own file chooser is kept" +grep -cx 'org.freedesktop.impl.portal.Access=omamobile;gtk' "$pf" >/dev/null || fail "the interface the owner didn't name is still added" +# An Omarchy update writes the file again: the lines come back at the next login +printf '[preferred]\ndefault=hyprland;gtk\n' >"$pf" +RUN_HOME=$hp run +[[ $(grep -c 'impl.portal.\(FileChooser=gnome\|Access=omamobile\);gtk' "$pf") == 2 ]] || fail "a rewritten file gets the lines again" +# No file of the user's: none is made, and the phone's own in /etc/xdg is read +rm "$pf" +RUN_HOME=$hp run +[[ ! -e $pf ]] || fail "no portal file is made for a user who has none" +pass "the portal choices: the touch file chooser and the permission sheet in the user's own portal file, an owner's choice kept, no file made" diff --git a/packages/omamobile-shell/version b/packages/omamobile-shell/version index 89bb7cae3..3abec2f78 100644 --- a/packages/omamobile-shell/version +++ b/packages/omamobile-shell/version @@ -1 +1 @@ -0.2.133 +0.2.134 From 08d5b79526e29948b16bf316d0c305d3636021e9 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Wed, 18 Nov 2026 09:43:30 -0649 Subject: [PATCH 2/2] omamobile-shell 0.2.134: the portal step leaves a linked or unwritable file alone and reads an owner's line with blanks From the review of this pull request. A user's hyprland-portals.conf that is a link (a dotfile setup) is left as it is, with a line saying what it lacks, since sed -i would replace the link with a copy. A file sed can't write to is reported and the rest of omamobile-setup-user goes on, where under set -e it stopped the setup at every login. An owner's line written with blanks around its "=" counts as theirs, so no second line is added above it. Tested: test/setup-user.sh gains the three cases (a linked file stays a link and unchanged, with the line; an unwritable directory is reported and the setup ends normally with nothing half-written; an owner's line with blanks is kept and no second one is added), and test/all passes. --- .../omamobile-shell/bin/omamobile-setup-user | 23 ++++++++++++----- packages/omamobile-shell/test/setup-user.sh | 25 +++++++++++++++++-- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/packages/omamobile-shell/bin/omamobile-setup-user b/packages/omamobile-shell/bin/omamobile-setup-user index e064e2352..c2b611ccd 100755 --- a/packages/omamobile-shell/bin/omamobile-setup-user +++ b/packages/omamobile-shell/bin/omamobile-setup-user @@ -495,15 +495,26 @@ fi # 9a from the day it took Omarchy 4.5). The two lines go into the user's file # too, under its [preferred] group, at any login that finds one missing: an # Omarchy update may write the file again. A file that names the interface -# is left alone, whatever it names, so an owner who wants another backend -# says so there. xdg-desktop-portal reads its files when it starts. +# is left alone, whatever it names (with blanks around its "=" or not), so +# an owner who wants another backend says so there. A file that is a link +# (a dotfile setup) is left as it is, with a line saying what it lacks: sed +# would replace the link with a copy. A file that can't be written is +# reported, and the rest of the setup goes on. xdg-desktop-portal reads its +# files when it starts. portals=${XDG_CONFIG_HOME:-$HOME/.config}/xdg-desktop-portal/hyprland-portals.conf -if [[ -f $portals ]] && grep -q '^\[preferred\]' "$portals"; then +if [[ -L $portals ]]; then + echo "omamobile-setup-user: $portals is a link, left as it is; the phone's file chooser and permission sheet need" \ + "org.freedesktop.impl.portal.FileChooser=gnome;gtk and org.freedesktop.impl.portal.Access=omamobile;gtk under [preferred] there" >&2 +elif [[ -f $portals ]] && grep -q '^\[preferred\]' "$portals"; then portals_changed=0 for line in 'org.freedesktop.impl.portal.FileChooser=gnome;gtk' 'org.freedesktop.impl.portal.Access=omamobile;gtk'; do - if ! grep -q "^${line%%=*}=" "$portals"; then - sed -i "0,/^\[preferred\]/s//[preferred]\n$line/" "$portals" - portals_changed=1 + if ! grep -q "^[[:space:]]*${line%%=*}[[:space:]]*=" "$portals"; then + if sed -i "0,/^\[preferred\]/s//[preferred]\n$line/" "$portals" 2>/dev/null; then + portals_changed=1 + else + echo "omamobile-setup-user: could not add ${line%%=*} to $portals" >&2 + break + fi fi done if ((portals_changed)); then diff --git a/packages/omamobile-shell/test/setup-user.sh b/packages/omamobile-shell/test/setup-user.sh index 521435195..009e14909 100644 --- a/packages/omamobile-shell/test/setup-user.sh +++ b/packages/omamobile-shell/test/setup-user.sh @@ -529,8 +529,29 @@ grep -cx 'org.freedesktop.impl.portal.Access=omamobile;gtk' "$pf" >/dev/null || printf '[preferred]\ndefault=hyprland;gtk\n' >"$pf" RUN_HOME=$hp run [[ $(grep -c 'impl.portal.\(FileChooser=gnome\|Access=omamobile\);gtk' "$pf") == 2 ]] || fail "a rewritten file gets the lines again" -# No file of the user's: none is made, and the phone's own in /etc/xdg is read +# An owner's line written with blanks around its "=" is theirs too +printf '[preferred]\ndefault=hyprland;gtk\n org.freedesktop.impl.portal.FileChooser = gtk\n' >"$pf" +RUN_HOME=$hp run +[[ $(grep -c 'impl.portal.FileChooser' "$pf") == 1 ]] || fail "an owner's line with blanks around its = is kept, and no second one is added" +# A file that is a link (a dotfile setup) stays a link, unchanged, with a line saying what it lacks +printf '[preferred]\ndefault=hyprland;gtk\n' >"$hp/dotfile-portals.conf" +rm "$pf"; ln -s "$hp/dotfile-portals.conf" "$pf" +before=$(sha256sum <"$hp/dotfile-portals.conf") +RUN_HOME=$hp run +[[ -L $pf && $(sha256sum <"$hp/dotfile-portals.conf") == "$before" ]] || fail "a portal file that is a link is left as it is" +grep -c 'is a link, left as it is' "$t/out" >/dev/null || fail "the setup says what a linked portal file lacks" rm "$pf" +# A file that can't be written: said once, and the setup goes on to its end +if ((EUID != 0)); then + printf '[preferred]\ndefault=hyprland;gtk\n' >"$pf" + chmod a-w "$hp/.config/xdg-desktop-portal" + RUN_HOME=$hp run + chmod u+w "$hp/.config/xdg-desktop-portal" + grep -c 'could not add org.freedesktop.impl.portal.FileChooser' "$t/out" >/dev/null || fail "a portal file that can't be written is reported" + [[ $(grep -c 'impl.portal' "$pf") == 0 ]] || fail "nothing is half-written into a file that can't be written" + rm "$pf" +fi +# No file of the user's: none is made, and the phone's own in /etc/xdg is read RUN_HOME=$hp run [[ ! -e $pf ]] || fail "no portal file is made for a user who has none" -pass "the portal choices: the touch file chooser and the permission sheet in the user's own portal file, an owner's choice kept, no file made" +pass "the portal choices: the touch file chooser and the permission sheet in the user's own portal file, an owner's choice kept (blanks or not), a linked or unwritable file left alone, no file made"