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