aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntonin Dach2021-04-03 00:10:15 +0200
committerAntonin Dach2021-04-04 22:38:49 +0200
commitdfbc35964ee7db271b008778db57c512b10d7163 (patch)
tree0f7dfb3a8d8ae9c8feab3119da3578680a78af5b
downloadaur-dfbc35964ee7db271b008778db57c512b10d7163.tar.gz
Librewolf comment out hooks
-rw-r--r--.SRCINFO12
-rw-r--r--.gitignore4
-rw-r--r--LICENSE21
-rw-r--r--PKGBUILD32
-rw-r--r--README.md91
-rw-r--r--librewolf-cfg-comment-out-values.hook12
-rwxr-xr-xlibrewolf-cfg-comment-out-values.sh23
-rw-r--r--librewolf-cfg-uncomment-out-values.hook10
-rwxr-xr-xlibrewolf-cfg-uncomment-out-values.sh19
9 files changed, 224 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..e575542c9a6e
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,12 @@
+pkgbase = librewolf-comment-out-cfg-hook
+ pkgdesc = Comment out custom cfg values via pacman hook
+ pkgver = 1
+ pkgrel = 1
+ url = https://git.sr.ht/~freed00m/librewolf-comment-out-cfg-hook
+ arch = x86_64
+ arch = aarch64
+ license = MIT
+ depends = librewolf
+
+pkgname = librewolf-comment-out-cfg-hook
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000000..6a85b4c5f2f2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+*.tar*
+/pkg
+
+
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 000000000000..8d11b6a12adf
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2021 AntonĂ­n Dach
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..8e50dc80c9d5
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,32 @@
+# Maintainer: AntonĂ­n Dach <dach@protonmail.com>
+
+pkgname=librewolf-comment-out-cfg-hook
+pkgver=1
+pkgrel=1
+pkgdesc='Comment out custom cfg values via pacman hook'
+arch=(x86_64 aarch64)
+url='https://git.sr.ht/~freed00m/librewolf-comment-out-cfg-hook'
+license=('MIT')
+depends=(librewolf)
+
+package() {
+ # -m will set the mode
+ # -D will just create the non-existing directories to the target.
+ #cd "$srcdir" && find usr/ -type f -exec install -Dm 644 "{}" "$pkgdir/{}" \;
+
+ mkdir -p "$pkgdir/usr/share/libalpm/scripts/"
+ mkdir -p "$pkgdir/usr/share/libalpm/hooks/"
+
+ cd "$srcdir"
+
+ cp ../librewolf-cfg-comment-out-values.hook "$pkgdir/usr/share/libalpm/hooks/librewolf-cfg-comment-out-values.hook"
+ cp ../librewolf-cfg-uncomment-out-values.hook "$pkgdir/usr/share/libalpm/hooks/librewolf-cfg-uncomment-out-values.hook"
+ cp ../librewolf-cfg-comment-out-values.sh "$pkgdir/usr/share/libalpm/scripts/librewolf-cfg-comment-out-values.sh"
+ cp ../librewolf-cfg-uncomment-out-values.sh "$pkgdir/usr/share/libalpm/scripts/librewolf-cfg-uncomment-out-values.sh"
+
+ # Set executable afterwards
+ chmod +x "$pkgdir/usr/share/libalpm/scripts/librewolf-cfg-uncomment-out-values.sh"
+ chmod +x "$pkgdir/usr/share/libalpm/scripts/librewolf-cfg-comment-out-values.sh"
+}
+
+# vim: ts=2 sw=2 et:
diff --git a/README.md b/README.md
new file mode 100644
index 000000000000..ccb1df431409
--- /dev/null
+++ b/README.md
@@ -0,0 +1,91 @@
+# Librewolf
+
+When librewolf's defaults are way to strict and your custom values are lost during update.
+
+Disable cfg values and polies by making sure they are commented out :)
+
+Very simple design, feed a list of values and the hooks will sed it out.
+
+## Why would you want this?
+
+The browser [librewolf](https://librewolf-community.gitlab.io/)
+comes with very opinionated defaults.
+The defaults are fine tuned for maximum privacy and security but you might find
+few settings and policies that goes against your usecase.
+
+For example, you might want
+ * to enable DRM
+ * to enable Firefox Sync for bookmarks only
+ * to enable WebGL
+ * to disable titlebar paint for dark GTK themes
+
+This hook package will allow you to set your custom defaults are blocked
+by checking `librewolf.cfg` and `policies.json` post install.
+
+If there is a entry blocking you in any way,
+this package will allow you to undo the hardoced values.
+
+** But keep in mind **
+It's not for setting up your values.
+You should do create a new files with your custom prefs your self.
+
+Put your created files here
+```
+$ ls /usr/lib/librewolf/browser/defaults/preferences
+ctrl-q-disable.js urlbar-suggestions.js wayland.js
+disable-drawInTiltebar.js
+```
+
+## How it works
+
+Any values blocked by `librewolf.cfg` and `policies.json` can be *unblocked*
+by commenting out the said value.
+
+Many setting from `librewolf.cfg` and `policies.json` cannot bet set via `*.js`
+file at $HOME or at `/usr/lib/librewolf`
+
+Basically this package will put 2 pacman hooks into the ALPM directories.
+
+The first hook `/usr/share/libalpm/hooks/librewolf-apply-cfg-mod.hook`
+will be applied post install of this package and post upgrade of Librewolf itself.
+
+The second hook `/usr/share/libalpm/hooks/librewolf-undo-cfg-mod.hook` will
+undo every modification from first hook prior the Librewolf update.
+
+It's there to basically return the `librewolf.cfg` and `policies.json`
+back to stock to prevent any `*.pacnew` files from being created by deault.
+
+Note - currently there is no backup() in the PKGBUILD of librewolf so undo-hook
+is redundant, however that might change in future.
+
+## Caveats and what to take pay more attention
+
+`librewolf.cfg` states
+
+```
+// "pref" : Sets the preference as if a user had set it, every time you start the browser. So users can make changes,
+// but they will be erased on restart. If you set a particular preference this way,
+// it shows up in about:config as "user set".
+```
+
+however, any function call `pref();` from a `/usr/lib/librewolf/browser/defaults/preferences/*.js`
+does behave more or less like "defaultPref" instead, so user changes done via GUI will be kept on restart.
+
+Also `lockPref, lock_pref, defaultPref, default_pref` are not working function calls in `/usr/lib/librewolf/browser/defaults/preferences/*.js` so they have no effect but does work at `$HOME/.librewolf/user-profile/user.js`.
+
+
+## TODOs for future?
+
+I am mostly responsive on mail `dach@protonmail.com` don't hesitate to ask, send PR or issue to me.
+
+### Implementing some sort value changer for policies
+
+Currently the `policies.json` can only comment out keys, not change a value.
+
+The only scenario I can imagine that there is policy being set by librewolf
+ and is the same as the firefox default.
+You might want to set a different value.
+
+Not implemented due to high complexity. Validating json + multiline parsing.
+
+
diff --git a/librewolf-cfg-comment-out-values.hook b/librewolf-cfg-comment-out-values.hook
new file mode 100644
index 000000000000..c706863e82c6
--- /dev/null
+++ b/librewolf-cfg-comment-out-values.hook
@@ -0,0 +1,12 @@
+[Trigger]
+Type = Package
+Operation = Install
+Operation = Upgrade
+Target = personal-privacy-and-security
+Target = librewolf
+
+[Action]
+Description = Commenting out values from librewolf.cfg and policy.json...
+When = PostTransaction
+Exec = /usr/share/libalpm/scripts/librewolf-cfg-comment-out-values.sh
+Depends = librewolf
diff --git a/librewolf-cfg-comment-out-values.sh b/librewolf-cfg-comment-out-values.sh
new file mode 100755
index 000000000000..53e098afe237
--- /dev/null
+++ b/librewolf-cfg-comment-out-values.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+POLICY_FILE=/usr/lib/librewolf/distribution/policies.json
+CFG_FILE=/usr/lib/librewolf/librewolf.cfg
+
+POLICY_MOD_FILE=/usr/lib/librewolf/distribution/policies.json-comment-out-list
+CFG_MOD_FILE=/usr/lib/librewolf/librewolf.cfg-comment-out-list
+
+touch $CFG_MOD_FILE
+touch $POLICY_MOD_FILE
+
+while IFS= read -r line
+do
+ sed -i "s/^lockPref(\"$line\"/\/\/lockPref(\"$line\"/g" $CFG_FILE
+done < $CFG_MOD_FILE
+
+
+while IFS= read -r line
+do
+ sed -i "s/\"$line\":/\"__COMMENT__ $line\":/g" $POLICY_FILE
+done < $POLICY_MOD_FILE
+
+# vim:fileencoding=utf-8:ts=2:shiftwidth=2
diff --git a/librewolf-cfg-uncomment-out-values.hook b/librewolf-cfg-uncomment-out-values.hook
new file mode 100644
index 000000000000..6de4c9621ba0
--- /dev/null
+++ b/librewolf-cfg-uncomment-out-values.hook
@@ -0,0 +1,10 @@
+[Trigger]
+Type = Package
+Operation = Upgrade
+Target = librewolf
+
+[Action]
+Description = Reverting comments to cfg and policy before librewolf upgrades...
+When = PreTransaction
+Exec = /usr/share/libalpm/scripts/librewolf-cfg-uncomment-out-value.sh
+Depends = librewolf
diff --git a/librewolf-cfg-uncomment-out-values.sh b/librewolf-cfg-uncomment-out-values.sh
new file mode 100755
index 000000000000..a88cc1a40840
--- /dev/null
+++ b/librewolf-cfg-uncomment-out-values.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+POLICY_FILE=/usr/lib/librewolf/distribution/policies.json
+CFG_FILE=/usr/lib/librewolf/librewolf.cfg
+
+POLICY_MOD_FILE=/usr/lib/librewolf/distribution/policies.json-comment-out-list
+CFG_MOD_FILE=/usr/lib/librewolf/librewolf.cfg-comment-out-list
+
+while IFS= read -r line
+do
+ sed -i "s/\/\/lockPref(\"$line\"/lockPref(\"$line\"/g" $CFG_FILE
+done < $CFG_MOD_FILE
+
+while IFS= read -r line
+do
+ sed -i "s/\"__COMMENT__ $line\":/\"$line\":/g" $POLICY_FILE
+done < $POLICY_MOD_FILE
+
+# vim:fileencoding=utf-8:ts=2:shiftwidth=2