caio.co/de/arch/firefox

Always restore open tabs

Even if the "clear history" option is enabled.
Id
d0e5cb33037b87e34377f581b2cec82ea6e3bf31
Author
Caio
Commit time
2024-03-21T15:15:42+01:00

Modified PKGBUILD

@@ -1,10 +1,10
# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Ionut Biru <ibiru@archlinux.org>
# Contributor: Jakub Schmidtke <sjakub@gmail.com>

pkgname=firefox
pkgver=124.0
-pkgrel=1
+pkgrel=3
pkgdesc="Standalone web browser from mozilla.org"
url="https://www.mozilla.org/firefox/"
arch=(x86_64)
@@ -42,6 +42,7
xorg-server-xvfb
yasm
zip
+ sccache
)
optdepends=(
'hunspell-en_US: Spell checking, American English'
@@ -60,6 +61,7
https://archive.mozilla.org/pub/firefox/releases/$pkgver/source/firefox-$pkgver.source.tar.xz{,.asc}
$pkgname.desktop
identity-icons-brand.svg
+ firefox-restore-tabs-but-clear-history.patch
)
validpgpkeys=(
# Mozilla Software Releases <release@mozilla.com>
@@ -69,11 +71,13
sha256sums=('345a1235123ad808cecdb4a9af09ea48bf52ad09d3d380fc704406e3dd13c9d8'
'SKIP'
'1f241fdc619f92a914c75aece7c7c717401d7467c9a306458e106b05f34e5044'
- 'a9b8b4a0a1f4a7b4af77d5fc70c2686d624038909263c795ecc81e0aec7711e9')
+ 'a9b8b4a0a1f4a7b4af77d5fc70c2686d624038909263c795ecc81e0aec7711e9'
+ '1b40bfb38b1ffd7d794ea261091b6e650fd58f02bed81c46eeb427a3e3e56c69')
b2sums=('e62264b8c400a29d092c9e034a58431106e5f1dd29bd8a9dcc3b5b204b4da8fa7a395c610ce0e4a932ca6305d243978bf212d57912bc4b6a85f95e6f34353ed0'
'SKIP'
'd07557840097dd48a60c51cc5111950781e1c6ce255557693bd11306c7a9258b2a82548329762148f117b2295145f9e66e0483a18e2fe09c5afcffed2e4b8628'
- '63a8dd9d8910f9efb353bed452d8b4b2a2da435857ccee083fc0c557f8c4c1339ca593b463db320f70387a1b63f1a79e709e9d12c69520993e26d85a3d742e34')
+ '63a8dd9d8910f9efb353bed452d8b4b2a2da435857ccee083fc0c557f8c4c1339ca593b463db320f70387a1b63f1a79e709e9d12c69520993e26d85a3d742e34'
+ 'ed73aa80826f78c5b4f693d1a2b63ba19189fd5cc168382c2e3ad319ec14070a48a90301561e884780cff55397d7a453f98e5a4d24c4eae77c7d5264c56912d3')

# Google API keys (see http://www.chromium.org/developers/how-tos/api-keys)
# Note: These are for Arch Linux use ONLY. For your own distribution, please
@@ -108,6 +112,7
ac_add_options --disable-elf-hack
ac_add_options --disable-bootstrap
ac_add_options --with-wasi-sysroot=/usr/share/wasi-sysroot
+ac_add_options --with-ccache=sccache

# Branding
ac_add_options --enable-official-branding
@@ -134,6 +139,8
ac_add_options --disable-updater
ac_add_options --disable-tests
END
+
+patch -Np1 -i ../firefox-restore-tabs-but-clear-history.patch
}

build() {
@@ -151,36 +158,11
# LTO needs more open files
ulimit -n 4096

- # Do 3-tier PGO
- echo "Building instrumented browser..."
- cat >.mozconfig ../mozconfig - <<END
-ac_add_options --enable-profile-generate=cross
-END
- ./mach build
-
- echo "Profiling instrumented browser..."
- ./mach package
- LLVM_PROFDATA=llvm-profdata \
- JARLOG_FILE="$PWD/jarlog" \
- xvfb-run -s "-screen 0 1920x1080x24 -nolisten local" \
- ./mach python build/pgo/profileserver.py
-
- stat -c "Profile data found (%s bytes)" merged.profdata
- test -s merged.profdata
-
- stat -c "Jar log found (%s bytes)" jarlog
- test -s jarlog
-
- echo "Removing instrumented browser..."
- ./mach clobber
-
echo "Building optimized browser..."
cat >.mozconfig ../mozconfig - <<END
-ac_add_options --enable-lto=cross,full
-ac_add_options --enable-profile-use=cross
-ac_add_options --with-pgo-profile-path=${PWD@Q}/merged.profdata
-ac_add_options --with-pgo-jarlog=${PWD@Q}/jarlog
+ #nothing
END
+
./mach build
}

@@ -201,9 +183,6

// Don't disable extensions in the application directory
pref("extensions.autoDisableScopes", 11);
-
-// Enable GNOME Shell search provider
-pref("browser.gnome-search-provider.enabled", true);
END

local distini="$pkgdir/usr/lib/$pkgname/distribution/distribution.ini"
@@ -211,7 +190,7
[Global]
id=archlinux
version=1.0
-about=Mozilla Firefox for Arch Linux
+about=Mozilla Firefox for Caio

[Preferences]
app.distributor=archlinux

Created README.md

@@ -1,0 +1,15
+# Firefox + Always-Restore-Open-Tabs
+
+I use Firefox with the "clear history on exit" setting enabled and
+while it does work, it also clears all my open tabs...
+
+I noticed that when firefox upgrades (or crashes) it behaves the
+exact way I wanted: it clears my history but preserves my open
+tabs.
+
+So for years I've been using `killall -9 firefox` instead of closing
+it normally 🤡
+
+Now I have this hack instead. I can go back to exiting Firefox
+normally and it happily restores my open tabs, no questions
+asked.

Created firefox-restore-tabs-but-clear-history.patch

@@ -1,0 +1,30
+diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs
+--- a/browser/components/sessionstore/SessionStore.sys.mjs
++++ b/browser/components/sessionstore/SessionStore.sys.mjs
+@@ -2669,7 +2669,7 @@
+ * String type of quitting
+ */
+ onQuitApplication: function ssi_onQuitApplication(aData) {
+- if (aData == "restart" || aData == "os-restart") {
++ // if (aData == "restart" || aData == "os-restart") {
+ if (!PrivateBrowsingUtils.permanentPrivateBrowsing) {
+ if (
+ aData == "os-restart" &&
+@@ -2690,12 +2690,12 @@
+ // perform any other sanitization processing on a restart as the
+ // browser is about to exit anyway.
+ Services.obs.removeObserver(this, "browser:purge-session-history");
+- }
+-
+- if (aData != "restart") {
++ // }
++
++ // if (aData != "restart") {
+ // Throw away the previous session on shutdown without notification
+- LastSession.clear(true);
+- }
++ // LastSession.clear(true);
++ // }
+
+ this._uninit();
+ },