feat(root): add keyboard layouts, OSDWindow, and update services & utilities

Introduce a new OSDWindow implementation, expose keyboard layout configuration, and modernize dependency handling and helper utilities.

- **New Features**
  - Added `keyboard_layouts` list (`us`, `np`) to `config.json`
  - Created `OSDWindow` class and updated `main.py` to use it
  - Introduced new service modules (`battery`, `brightness`, `capslock`, `network`, `mpris`, `todo`, `modus`) and expanded `services/__init__.py`
  - Added `CommandResult` and `run_command` helper in `utils/functions.py`

- **Enhancements**
  - Upgraded numerous dependencies to newer versions and switched `fabric` to a git source
  - Replaced bare `except:` with `except Exception:` in `WiFiPasswordDialog`
  - Improved type hints (`NamedTuple`, `TypeVar`) and refactored JSON file helpers
  - Added property notifications for battery percentage, state, and presence

- **Bug Fixes**
  - Fixed incorrect return type annotation in `read_json_file`
  - Corrected tick‑handler logic to avoid double registration
  - Properly notify listeners on battery property changes
  - Ensured proper exception handling and cleanup in utility functions
This commit is contained in:
sankalp committed 2026-03-23 23:33:53 +05:45
1 parent 129906cb9c
commit 34cfb2f49e
12 files changed
+504 -96

No files matched your search

+18 -3
View File
@@ -1,6 +1,6 @@
from typing import Literal, Optional
from fabric import Service, Signal
from fabric.core.service import Property, Service, Signal
from fabric.utils import Gio, GLib, logger
from utils.dbus_helper import GioDBusHelper
@@ -178,8 +178,23 @@ class BatteryService(Service):
"""Get display name for a power profile."""
return PowerProfile.get(profile, profile.title())
def handle_property_change(self, *_):
# You may filter which property changed by checking parameters[1]
@Property(int, "readable", default_value=0)
def percentage(self) -> int:
return self.get_property("Percentage") or 0
@Property(int, "readable", default_value=0)
def state(self) -> int:
return self.get_property("State") or 0
@Property(bool, "readable", default_value=False)
def is_present(self) -> bool:
return self.get_property("IsPresent") or False
def handle_property_change(self, *args):
# Notify about property changes for OSD and other listeners
self.notify("percentage")
self.notify("state")
self.notify("is-present")
self.emit("changed")
def handle_power_profile_change(self, *_):