caio.co/de/arch/firefox

Now with browser.sessionstore.always_restore_tabs

Cleaner patch, with a bool pref and functionality disabled
by default
Id
7862d56249214c3d3696e40baed03e6e75600b60
Author
Caio
Commit time
2024-03-24T08:35:20+01:00

Modified PKGBUILD

@@ -61,7 +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
+ 0001-always-restore-tabs-pref.patch
)
validpgpkeys=(
# Mozilla Software Releases <release@mozilla.com>
@@ -72,12 +72,12
'SKIP'
'1f241fdc619f92a914c75aece7c7c717401d7467c9a306458e106b05f34e5044'
'a9b8b4a0a1f4a7b4af77d5fc70c2686d624038909263c795ecc81e0aec7711e9'
- '1b40bfb38b1ffd7d794ea261091b6e650fd58f02bed81c46eeb427a3e3e56c69')
+ 'b38b8ddea2cef26229e1033b3a8f6b83d0a24652ddedbbdfbda3a9692e1fd24a')
b2sums=('b986833fbf28ebcb5588a68367054ca7a2f51f69685349ba65d25e118c90ded55c6e626842bbda8f00717ee55aa784c808e8f09855de423234a592ad23d9e9bf'
'SKIP'
'd07557840097dd48a60c51cc5111950781e1c6ce255557693bd11306c7a9258b2a82548329762148f117b2295145f9e66e0483a18e2fe09c5afcffed2e4b8628'
'63a8dd9d8910f9efb353bed452d8b4b2a2da435857ccee083fc0c557f8c4c1339ca593b463db320f70387a1b63f1a79e709e9d12c69520993e26d85a3d742e34'
- 'ed73aa80826f78c5b4f693d1a2b63ba19189fd5cc168382c2e3ad319ec14070a48a90301561e884780cff55397d7a453f98e5a4d24c4eae77c7d5264c56912d3')
+ 'a22eaee217be2ca5cf79ebb7f874643a4c956593e25ba8bf282e5b991b5d1cea6fc317248a8bdbd81b05591b22635e13742f180d278f99b04a442d8e35525686')

# 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
@@ -140,7 +140,7
ac_add_options --disable-tests
END

-patch -Np1 -i ../firefox-restore-tabs-but-clear-history.patch
+patch -Np1 -i ../0001-always-restore-tabs-pref.patch
}

build() {
@@ -183,6 +183,9

// Don't disable extensions in the application directory
pref("extensions.autoDisableScopes", 11);
+
+// Patch leaves the setting as off by default
+pref("browser.sessionstore.always_restore_tabs", true);
END

local distini="$pkgdir/usr/lib/$pkgname/distribution/distribution.ini"

Created 0001-always-restore-tabs-pref.patch

@@ -1,0 +1,44
+diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js
+--- a/browser/app/profile/firefox.js
++++ b/browser/app/profile/firefox.js
+@@ -1311,6 +1311,9 @@
+ // temporary pref that will be removed in a future release, see bug 1836952
+ pref("browser.sessionstore.persist_closed_tabs_between_sessions", true);
+
++// prevent clearing the open tabs even when clear history is enabled
++pref("browser.sessionstore.always_restore_tabs", false);
++
+ // Don't quit the browser when Ctrl + Q is pressed.
+ pref("browser.quitShortcut.disabled", false);
+
+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,6 +2669,11 @@
+ * String type of quitting
+ */
+ onQuitApplication: function ssi_onQuitApplication(aData) {
++ let always = (
++ !PrivateBrowsingUtils.permanentPrivateBrowsing &&
++ this._prefBranch.getBoolPref("sessionstore.always_restore_tabs")
++ );
++
+ if (aData == "restart" || aData == "os-restart") {
+ if (!PrivateBrowsingUtils.permanentPrivateBrowsing) {
+ if (
+@@ -2690,9 +2695,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") {
++ } else if (always) {
++ this._prefBranch.setBoolPref("sessionstore.resume_session_once", true);
++ Services.obs.removeObserver(this, "browser:purge-session-history");
++ }
++
++ if (!always && aData != "restart") {
+ // Throw away the previous session on shutdown without notification
+ LastSession.clear(true);
+ }

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

@@ -1,30 +1,0
-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();
- },