Frewacom / pywalfox

Dynamic theming of Firefox (and Thunderbird) using your Pywal colors
https://addons.mozilla.org/en-US/firefox/addon/pywalfox/
Mozilla Public License 2.0
650 stars 11 forks source link

A firefox-extension AUR package. #105

Open m00nwtchr opened 1 year ago

m00nwtchr commented 1 year ago

As you can see in https://wiki.archlinux.org/title/Browser_extensions browser extensions themselves can also be packaged, it'd be nice to have the extension side of pywalfox in the AUR as well :)

m00nwtchr commented 1 year ago

Also side note for the existing native messaging host package: the manifest should probably be placed by the package in /usr/lib/mozilla/native-messaging-hosts/ (according to https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_manifests#linux) instead of requiring the user to manually execute a command. (especially since the command will incorrectly try to chmod something in a inaccessible due to permissions location, causing an error that doesn't actually prevent the app from working, since the package already installs the files with the correct permissions)

Frewacom commented 1 year ago

Hi,

Yes, that would be very nice. I might have a look in the future if I find the time, but feel free to contribute your own PKGBUILD to the AUR if you want to 👍🏼

Also side note for the existing native messaging host package: the manifest should probably be placed by the package in /usr/lib/mozilla/native-messaging-hosts/ (according to https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_manifests#linux) instead of requiring the user to manually execute a command. (especially since the command will incorrectly try to chmod something in a inaccessible due to permissions location, when the package can just make sure all the files are installed with the correct permissions)

Good point. I think the path to the messenger host is inserted dynamically into the manifest when you run pywalfox install, but that should not be an issue, since I assume you have access to the output path of the package.

m00nwtchr commented 1 year ago

Yep, this is how I'd do it, though:

diff --git a/PKGBUILD b/PKGBUILD
index da8c2de..ddae0dd 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -18,6 +18,12 @@ makedepends=(
 source=("$pkgname-$pkgver.tar.gz::https://pypi.python.org/packages/source/p/$_name/$_name-$pkgver.tar.gz")
 sha256sums=('59e73d7e27389574fb801634e03d8471f09bfe062865cad803f68c456680ed66')

+prepare() {
+    cd $_name-$pkgver
+    local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
+    sed -i "s:<path>:$site_packages/pywalfox/bin/main.sh:" pywalfox/assets/manifest.json
+}
+
 build() {
     cd $_name-$pkgver
     python setup.py build
@@ -26,4 +32,5 @@ build() {
 package() {
     cd $_name-$pkgver
     python setup.py install --root="$pkgdir" --optimize=1 --skip-build
+    install -Dm644 pywalfox/assets/manifest.json -T "$pkgdir/usr/lib/mozilla/native-messaging-hosts/pywalfox.json"
 }

(site_packages location script from Arch wiki, https://wiki.archlinux.org/title/Python_package_guidelines#Using_site-packages)

Frewacom commented 1 year ago

Thanks!

Have you tested it locally to see if it works as expected?

m00nwtchr commented 1 year ago

Yes