Skip to content

Commit

Permalink
feature: Support for snapped versions of Firefox and Chromium.
Browse files Browse the repository at this point in the history
  • Loading branch information
vasilev committed Aug 8, 2022
1 parent f57d452 commit 37a47e9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
33 changes: 25 additions & 8 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 @@ -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

0 comments on commit 37a47e9

Please sign in to comment.