Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Support for snapped versions of Firefox and Chromium #335

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
35 changes: 26 additions & 9 deletions common/profile-sync-daemon.in
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,11 @@ suffix_needed() {
[[ -n "$check_suffix" ]]
}

infix_needed() {
browser=$1
[[ $browser == *"-in-snap" ]]
}

dup_check() {
# only for firefox, icecat, seamonkey, and palemoon
# the LAST directory in the profile MUST be unique
Expand Down Expand Up @@ -465,13 +470,17 @@ do_sync_for() {
DIR="$item"
BACKUP="$item-backup"
BACK_OVFS="$item-back-ovfs"
infix=
if infix_needed "$browser"; then
infix="../snap.${browser%-in-snap}/"
fi
suffix=
if suffix_needed "$browser"; then
suffix="-${item##*/}"
fi
TMP="$VOLATILE/$user-$browser$suffix"
UPPER="$VOLATILE/$user-$browser${suffix}-rw"
WORK="$VOLATILE/.$user-$browser${suffix}"
TMP="$VOLATILE/$infix$user-$browser$suffix"
UPPER="$VOLATILE/$infix$user-$browser${suffix}-rw"
WORK="$VOLATILE/$infix.$user-$browser${suffix}"
local REPORT

# make tmpfs container
Expand Down Expand Up @@ -514,7 +523,7 @@ do_sync_for() {
fi
else
# keep user from launching browser while rsync is active
rsync -aX --inplace --no-whole-file "$BACKUP/" "$TMP"
rsync -aX --inplace --no-whole-file --mkpath "$BACKUP/" "$TMP"
fi

# now browser can start
Expand Down Expand Up @@ -590,13 +599,17 @@ do_unsync() {
DIR="$item"
BACKUP="$item-backup"
BACK_OVFS="$item-back-ovfs"
infix=
if infix_needed "$browser"; then
infix="../snap.${browser%-in-snap}/"
fi
suffix=
if suffix_needed "$browser"; then
suffix="-${item##*/}"
fi
TMP="$VOLATILE/$user-$browser$suffix"
UPPER="$VOLATILE/$user-$browser${suffix}-rw"
WORK="$VOLATILE/.$user-$browser${suffix}"
TMP="$VOLATILE/$infix$user-$browser$suffix"
UPPER="$VOLATILE/$infix$user-$browser${suffix}-rw"
WORK="$VOLATILE/$infix.$user-$browser${suffix}"
# check if user has browser profile
if [[ -h "$DIR" ]]; then
unlink "$DIR"
Expand Down Expand Up @@ -657,11 +670,15 @@ parse() {
for item in "${DIRArr[@]}"; do
DIR="$item"
BACKUP="$item-backup"
infix=
if infix_needed "$browser"; then
infix="../snap.${browser%-in-snap}/"
fi
suffix=
if suffix_needed "$browser"; then
suffix="-${item##*/}"
fi
UPPER="$VOLATILE/$user-$browser${suffix}-rw"
UPPER="$VOLATILE/$infix$user-$browser${suffix}-rw"
if [[ -d "$DIR" ]]; then
local CRASHArr=()
while IFS= read -d '' -r backup; do
Expand Down Expand Up @@ -691,7 +708,7 @@ parse() {
warn=
fi
echo -en " ${BLD}tmpfs dir:"
echo -e "$(tput cr)$(tput cuf 17) ${GRN}$VOLATILE/$user-$browser$suffix${NRM}"
echo -e "$(tput cr)$(tput cuf 17) ${GRN}$VOLATILE/$infix$user-$browser$suffix${NRM}"
echo -en " ${BLD}profile size:"
echo -e "$(tput cr)$(tput cuf 17) $psize${NRM}"
if [[ $OLFS -eq 1 ]]; then
Expand Down
2 changes: 2 additions & 0 deletions contrib/chromium-in-snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DIRArr[0]="$HOME/snap/chromium/common/chromium"
PSNAME="chrome"
17 changes: 17 additions & 0 deletions contrib/firefox-in-snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
if [[ -d "$HOME"/snap/firefox/common/.mozilla/firefox ]]; then
index=0
PSNAME="firefox"
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]="$HOME/snap/firefox/common/.mozilla/firefox/$profileItem"
fi
(( index=index+1 ))
done < <(grep '[Pp]'ath= "$HOME"/snap/firefox/common/.mozilla/firefox/profiles.ini | sed 's/[Pp]ath=//')
fi

check_suffix=1