graysky2 / profile-sync-daemon

Symlinks and syncs browser profile dirs to RAM thus reducing HDD/SDD calls and speeding-up browsers.
https://wiki.archlinux.org/index.php/Profile-sync-daemon
Other
898 stars 84 forks source link

Move $VOLATILE to dedicated directory in $XDG_RUNTIME_DIR #336

Closed ranisalt closed 1 year ago

ranisalt commented 1 year ago

This is required to share the synced profiles with Flatpak executables.

Explanation: $XDG_RUNTIME_DIR can't be shared with sandboxes, so the symlinked profile directories aren't accessible. However, selected directories inside it can be shared, therefore this change allows Flatpak-ed browsers to use psd by sharing $XDG_RUNTIME_DIR with them.

Keeps $PID_FILE in the same location for compatibility purposes, in case any daemons or service units depend on that.

To use with Flatpak, share xdg-run/psd with the sandbox, i.e. flatpak override --filesystem=xdg-run/psd <application id>. I'll try and contribute with Flathub to have that by default.

How to use?

I slightly modified the Firefox script to find directories inside the Flatpak sandbox, changing the base directory from $HOME to $HOME/.var/app/org.mozilla.firefox was enough:

BASEDIR="$HOME/.var/app/org.mozilla.firefox"

if [[ -d "$BASEDIR/.mozilla/firefox" ]]; then
    index=0
    PSNAME="firefox-bin"
    while read -r profileItem; do
        if [[ $(echo "$profileItem" | cut -c1) = "/" ]]; then
            # path is not relative
            DIRArr[$index]="$profileItem"
        else
            # we need to append the default path to give a
            # fully qualified path
            DIRArr[$index]="$BASEDIR/.mozilla/firefox/$profileItem"
        fi
        (( index=index+1 ))
    done < <(grep '[Pp]'ath= "$BASEDIR/.mozilla/firefox/profiles.ini" | sed 's/[Pp]ath=//')
fi

check_suffix=1

psd could either have separate scripts for Flatpak-ed versions, or just check both locations with the same script.

graysky2 commented 1 year ago

I haven't played with what you're describing here but I don't see an issue with the change you propose so long as the user first stops psd before the upgrade occurs. That can be taken care of in a pre-install scriptlet.

ranisalt commented 1 year ago

That can be taken care of in a pre-install scriptlet

The one in the AUR package (now in community?) works perfectly!

graysky2 commented 1 year ago

Make sure you pull the latest commit post your merge or else it will not umount properly on a stop (with overlayfs). You might have to manually umount it once stopped until that is applied. Check the out put of mount | grep xxx where xxx is your browser.