forked from canonical/firefox-snap
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfirefox.launcher
executable file
·46 lines (43 loc) · 2.02 KB
/
firefox.launcher
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
# When running the snap for the first time, try and locate an existing
# firefox config in $SNAP_REAL_HOME/.mozilla/firefox, and import it.
# This requires the personal-files plug to be connected.
# This is a stopgap measure until proper profile migration is implemented
# in firefox (see https://bugzilla.mozilla.org/1730530).
DOTMOZILLA="$SNAP_USER_COMMON/.mozilla"
if [ ! -d "$DOTMOZILLA" ]; then
FIREFOX_CONFIG="$SNAP_REAL_HOME/.mozilla/firefox"
cat "$FIREFOX_CONFIG/profiles.ini" >/dev/null 2>&1
if [ "$?" -eq "0" ]; then
SIZE=$(du -sb $FIREFOX_CONFIG | cut -f 1)
AVAILABLE_BLOCKS=$(stat -f -c %a $SNAP_USER_COMMON)
BLOCK_SIZE=$(stat -f -c %s $SNAP_USER_COMMON)
AVAILABLE_SIZE=$(($AVAILABLE_BLOCKS*$BLOCK_SIZE))
if [ $AVAILABLE_SIZE -gt $SIZE ]; then
printf "Importing existing firefox profiles from $FIREFOX_CONFIG\n"
TS1=$(date +%s.%3N)
mkdir -p "$DOTMOZILLA"
cp -R "$FIREFOX_CONFIG" "$DOTMOZILLA/"
# Search and replace absolute file paths in plain-text config files.
for FILENAME in "pkcs11.txt" "extensions.json"; do
find "$DOTMOZILLA/firefox" -name "$FILENAME" \
-exec sed -i "s#$FIREFOX_CONFIG#$DOTMOZILLA/firefox#g" {} \;
done
# Patch the imported profiles to set the default one for use by the snap
# (legacy mode, no dedicated profiles).
$SNAP/patch-default-profile.py "$DOTMOZILLA/firefox/profiles.ini"
TS2=$(date +%s.%3N)
T=$(printf "$TS1 $TS2" | awk '{printf "%.3f",$2-$1}')
printf "Import done in $T s\n"
else
printf "Not importing existing firefox profiles from $FIREFOX_CONFIG "
printf "because there is not enough available space in $SNAP_USER_COMMON "
printf "(required: $SIZE bytes / available: $AVAILABLE_SIZE bytes)\n"
fi
fi
fi
# Default to XWayland until native Wayland support is properly tested
# (see https://bugzilla.mozilla.org/show_bug.cgi?id=1725245)
[ -z "$MOZ_ENABLE_WAYLAND" ] && export MOZ_ENABLE_WAYLAND=0
unset GDK_BACKEND
exec "$SNAP/usr/lib/firefox/firefox" "$@"