From 754fbd868b1d0c450e6bf56602d77b9043dce939 Mon Sep 17 00:00:00 2001 From: Stephen Horvath Date: Thu, 20 Mar 2025 16:16:43 +1000 Subject: [PATCH] Add support for pip again --- .gitignore | 3 +++ MANIFEST.in | 1 + README.md | 47 ++++++++++++++++++++++++++++++++------------ pyproject.toml | 5 ++++- yafi/__init__.py | 10 +++++++++- yafi/__main__.py | 3 --- yafi/hardware.py | 2 ++ yafi/main.py | 3 ++- yafi/yafi.gresource | Bin 0 -> 15319 bytes yafi/yafi.in | 4 ++-- 10 files changed, 57 insertions(+), 21 deletions(-) create mode 100644 yafi/yafi.gresource diff --git a/.gitignore b/.gitignore index 0a19790..a92495f 100644 --- a/.gitignore +++ b/.gitignore @@ -172,3 +172,6 @@ cython_debug/ # PyPI configuration file .pypirc + +# Flatpak builder +.flatpak-builder/ diff --git a/MANIFEST.in b/MANIFEST.in index ead7aba..7ab5cc0 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1,2 @@ include yafi/ui/*.ui +include yafi/yafi.gresource diff --git a/README.md b/README.md index e9b7502..05a5808 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,40 @@ YAFI is another GUI for the Framework Laptop Embedded Controller. It is written in Python with a GTK4 Adwaita theme, and uses the `CrOS_EC_Python` library to communicate with the EC. -## Features +It has support for fan control, temperature monitoring, LED control, and battery limiting. + +## Installation + +### udev Rules (MUST READ) + +To allow YAFI to communicate with the EC, you need to copy the [`60-cros_ec_python.rules`](https://github.com/Steve-Tech/YAFI/blob/main/60-cros_ec_python.rules) file to `/etc/udev/rules.d/` and reload the rules with `sudo udevadm control --reload-rules && sudo udevadm trigger`. + +### Flatpak + +Build and install the Flatpak package with `flatpak-builder --install --user build au.stevetech.yafi.json`. + +You can also create a flatpak bundle with `flatpak-builder --repo=repo build au.stevetech.yafi.json` and install it with `flatpak install --user repo au.stevetech.yafi.flatpak`. + +### Pip + +#### System Dependencies + +The following system dependencies are required for `PyGObject`: + +- `python3-dev` +- `libcairo2-dev` +- `libgirepository-2.0-dev` +- `gir1.2-adw-1` + +There's probably more, but I happened to have them installed. + +#### Install + +Install the package with `pip install git+https://github.com/Steve-Tech/YAFI.git`. + +Pipx is also supported. + +## Screenshots ### Fan Control and Temperature Monitoring @@ -24,15 +57,3 @@ It is written in Python with a GTK4 Adwaita theme, and uses the `CrOS_EC_Python` ### Hardware Info ![Hardware Page](docs/4-hardware.png) - -## Installation - -### udev Rules (MUST READ) - -To allow YAFI to communicate with the EC, you need to copy the `60-cros_ec_python.rules` file to `/etc/udev/rules.d/` and reload the rules with `sudo udevadm control --reload-rules && sudo udevadm trigger`. - -### Flatpak - -Build and install the Flatpak package with `flatpak-builder --install --user build au.stevetech.yafi.json`. - -You can also create a flatpak bundle with `flatpak-builder --repo=repo build au.stevetech.yafi.json` and install it with `flatpak install --user repo au.stevetech.yafi.flatpak`. diff --git a/pyproject.toml b/pyproject.toml index ae33340..8893d34 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,10 +15,10 @@ classifiers = [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: End Users/Desktop", "Programming Language :: Python :: 3", - "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", "Operating System :: POSIX :: Linux", "Topic :: System :: Hardware", ] +license = "GPL-2.0-or-later" [project.optional-dependencies] lpc = ["portio"] @@ -33,3 +33,6 @@ yafi = "yafi:main" [build-system] requires = ["setuptools>=61.0"] build-backend = "setuptools.build_meta" + +[tool.setuptools] +packages = ["yafi"] diff --git a/yafi/__init__.py b/yafi/__init__.py index 12a7e52..a486981 100644 --- a/yafi/__init__.py +++ b/yafi/__init__.py @@ -1 +1,9 @@ -from . import main +import os + +# Register resources if not running in Flatpak +if not os.environ.get('FLATPAK_ID'): + from gi.repository import Gio + resource = Gio.Resource.load(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'yafi.gresource')) + resource._register() + +from .main import main diff --git a/yafi/__main__.py b/yafi/__main__.py index 1648817..e69de29 100644 --- a/yafi/__main__.py +++ b/yafi/__main__.py @@ -1,3 +0,0 @@ -from . import main - -main.main() \ No newline at end of file diff --git a/yafi/hardware.py b/yafi/hardware.py index cb7816c..68d2ca3 100644 --- a/yafi/hardware.py +++ b/yafi/hardware.py @@ -62,6 +62,8 @@ class HardwarePage(Gtk.Box): else: self.hw_fp_pwr.set_visible(False) + self._update_hardware(app) + # Schedule _update_hardware to run every second GLib.timeout_add_seconds(1, self._update_hardware, app) diff --git a/yafi/main.py b/yafi/main.py index 18b0adf..1e2ca5c 100644 --- a/yafi/main.py +++ b/yafi/main.py @@ -36,6 +36,7 @@ from .hardware import HardwarePage from cros_ec_python import get_cros_ec + class YafiApplication(Adw.Application): """The main application singleton class.""" @@ -134,7 +135,7 @@ class YafiApplication(Adw.Application): dialog.present(self.win) -def main(version): +def main(): """The application's entry point.""" app = YafiApplication() return app.run(sys.argv) diff --git a/yafi/yafi.gresource b/yafi/yafi.gresource new file mode 100644 index 0000000000000000000000000000000000000000..39ee0eb9f659f0c229f4307ee0ad8065a068a5bc GIT binary patch literal 15319 zcmeHOOOG5$5pM4TgFzgY3*2)1f>)yFv9?z>%=GSf?6EDz_Q*5dl@U@ayDGaocj`q} zR`;~Th5a1}egGhG0PU3nR|H5%9N-s##0hD+AowyXv%4PIukrY?vu>$W)!9**kr|N@ zUqnXV`H%`uBiS&YZ{mLag8p*(l4*MbcXhpq>!P{7jJvuNjk^Bw+t(WZ!$-Y)p|RiC z!u0e;4;3;(FtgwMfyc=dXf(fcrX_ zdW*+zsdn|O+CRYkUvD=Wzxexi|E%~>&u^lif8+iiTz~lN2WyI6J*#mW%|_#w-)=N+ z{N&`vXx7ha++U;ZH@MPI|M4v~H}!l8?Z3nQ_qcw(^U1GNKkE4s`uP*?fBhc#K-)!J z0rS(fj5q%IHGIKm>;023AVVfn9!J~F&9#jtVUZX6JnC;ZA0O?tt~cLrU)p-R)grrs zQOSHV;&MQCY1pL!^#+V=tlhY}wnsKaUTRuxY!4rvL$Pr%JzkMqu z3GFk|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