From 37a47e98de312b1c66e6fb2c699c9be5d9d1b532 Mon Sep 17 00:00:00 2001 From: vasilev Date: Tue, 9 Aug 2022 00:40:19 +0600 Subject: [PATCH] feature: Support for snapped versions of Firefox and Chromium. --- common/profile-sync-daemon.in | 33 +++++++++++++++++++++++++-------- contrib/chromium-in-snap | 2 ++ contrib/firefox-in-snap | 17 +++++++++++++++++ 3 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 contrib/chromium-in-snap create mode 100644 contrib/firefox-in-snap diff --git a/common/profile-sync-daemon.in b/common/profile-sync-daemon.in index 09a3a701..e992a85a 100644 --- a/common/profile-sync-daemon.in +++ b/common/profile-sync-daemon.in @@ -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 @@ -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 @@ -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" @@ -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 @@ -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 diff --git a/contrib/chromium-in-snap b/contrib/chromium-in-snap new file mode 100644 index 00000000..d76012f2 --- /dev/null +++ b/contrib/chromium-in-snap @@ -0,0 +1,2 @@ +DIRArr[0]="$HOME/snap/chromium/common/chromium" +PSNAME="chrome" diff --git a/contrib/firefox-in-snap b/contrib/firefox-in-snap new file mode 100644 index 00000000..53f26674 --- /dev/null +++ b/contrib/firefox-in-snap @@ -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