Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions packages/omamobile-shell/bin/omamobile-setup-user
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,44 @@ 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 (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 [[ -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 "^[[: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
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
Expand Down
3 changes: 3 additions & 0 deletions packages/omamobile-shell/portal/hyprland-portals.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions packages/omamobile-shell/test/all
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
55 changes: 55 additions & 0 deletions packages/omamobile-shell/test/setup-user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -500,3 +500,58 @@ 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"
# 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 (blanks or not), a linked or unwritable file left alone, no file made"
2 changes: 1 addition & 1 deletion packages/omamobile-shell/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.133
0.2.134