From 017c127a441ea1066b3bc82d34de50656291dfa2 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Thu, 2 Apr 2026 23:12:37 +0545 Subject: [PATCH] chore(root): migrate touv and simplify dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New Features - Added uv as the primary package manager and introduced new system packages awww, apple-fonts, swappy, and wl-clipboard. - Removed many redundant Python packages from the install script. Enhancements - Replaced Pillow-based QR code detection with GdkPixbuf, eliminating the python-pillow dependency. - Fixed a typo in the import (`ConfigServic` → `ConfigService`) and corrected service imports. - Updated the application launch to use `uwsm app -- uv run main.py` for uv-managed execution. Bug Fixes - Resolved import typo that prevented proper ConfigService initialization. - Adjusted QR-code decoding logic to correctly handle image pixel channels, improving robustness. --- install.sh | 24 +++--------------------- services/__init__.py | 2 +- services/auth.py | 31 ++++++++++++++++++++----------- 3 files changed, 24 insertions(+), 33 deletions(-) diff --git a/install.sh b/install.sh index dc66055..8608417 100755 --- a/install.sh +++ b/install.sh @@ -21,39 +21,21 @@ REPO_URL="https://github.com/S4NKALP/Modus.git" INSTALL_DIR="$HOME/.config/Modus" PACKAGES=( - python-fabric-git + uv fabric-cli-git glace-git cliphist gnome-bluetooth-3.0 - gobject-introspection slurp ffmpeg hypridle hyprsunset hyprpicker - imagemagick libnotify matugen-bin playerctl - python-gobject - python-pillow - python-setproctitle - python-toml - python-requests - python-numpy - python-pywayland - python-pyxdg - python-ijson - python-watchdog - python-pyotp - pyzbar - python-psutil - python-pydbus - python-thefuzz - python-pam gtk-session-lock - swww + awww apple-fonts swappy wl-clipboard @@ -349,7 +331,7 @@ else fi step "Starting Modus..." -if uwsm app -- python "$INSTALL_DIR/main.py" >/dev/null 2>&1 & then +if uwsm app -- uv run "$INSTALL_DIR/main.py" >/dev/null 2>&1 & then disown sleep 1 if pgrep -f "python.*main.py" >/dev/null; then diff --git a/services/__init__.py b/services/__init__.py index 6999ed4..7d00053 100644 --- a/services/__init__.py +++ b/services/__init__.py @@ -7,4 +7,4 @@ from .network import NetworkClient, Wifi, Ethernet, AccessPoint # noqa: F401 from .mpris import MprisPlayer, MprisPlayerManager # noqa: F401 from .todo import TodoService # noqa: F401 from .modus import ModusService # noqa: F401 -from .config import on_config_change, start_config_service, ConfigServic # noqa: F401 +from .config import on_config_change, start_config_service, ConfigService # noqa: F401 diff --git a/services/auth.py b/services/auth.py index 3a7b070..c205987 100644 --- a/services/auth.py +++ b/services/auth.py @@ -7,7 +7,7 @@ from pathlib import Path from urllib.parse import parse_qs, urlparse import pyotp -from PIL import Image +from fabric.utils import GdkPixbuf from pyzbar.pyzbar import decode import config.data as data @@ -70,15 +70,14 @@ def read_and_save_to_json(): # Open the captured image try: - img = Image.open(screenshot) - except Exception as e: - print("Error opening the image:", e) - return False - - # Decode QR Code(s) from the image - decoded_objects = decode(img) + pixbuf = GdkPixbuf.Pixbuf.new_from_file(screenshot) + pixels = pixbuf.get_pixels() + channels = pixbuf.get_n_channels() + gray_pixels = pixels[::channels] + decoded_objects = decode((gray_pixels, pixbuf.get_width(), pixbuf.get_height())) + finally: + del pixbuf if not decoded_objects: - print("No QR Code detected in the selected area.") return False results = [] @@ -279,8 +278,18 @@ def scan_qr_and_add_account(account_name: str, secrets_file_path: str) -> dict: # Decode QR code try: - img = Image.open(screenshot_path) - decoded_objects = decode(img) + try: + pixbuf = GdkPixbuf.Pixbuf.new_from_file(screenshot_path) + pixels = pixbuf.get_pixels() + channels = pixbuf.get_n_channels() + gray_pixels = pixels[::channels] + decoded_objects = decode( + (gray_pixels, pixbuf.get_width(), pixbuf.get_height()) + ) + finally: + # Delete pixbuf to free native memory immediately + if "pixbuf" in locals(): + del pixbuf if not decoded_objects: return {