chore: refactor imports and adopt new utils utilities

This commit is contained in:
sankalp committed 2026-07-14 18:45:52 +05:45
1 parent b2114f52b1
commit 6f2d0bf444
65 files changed
+221 -266

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@ from pathlib import Path
from fabric.core.service import Property, Service, Signal
from fabric.utils import logger
from utils.utils import EvdevLEDMonitor
from utils.gtk_utils import EvdevLEDMonitor
# Discover CapsLock LED device
capslock_leds = list(Path("/sys/class/leds").glob("input*::capslock"))
+1 -1
View File
@@ -15,7 +15,7 @@ from tomlkit import dump as toml_dump
from tomlkit import load as toml_load
from tomlkit.items import Array, Bool, Integer, String
from utils.utils import toml_file
from utils.gtk_utils import toml_file
class ConfigService:
+3 -6
View File
@@ -271,12 +271,9 @@ class CachedNotifications(Notifications):
def load_cached_notifications(self) -> dict[int, CachedNotification]:
"""Load cached notifications from a JSON file (deserialization)."""
try:
with open(NOTIFICATION_CACHE_FILE) as file:
data = json.load(file) # Load list of serialized notifications
except (FileNotFoundError, json.JSONDecodeError):
# If file doesn't exist or is corrupted, start with empty list
data = []
from utils.functions import read_json_file
data = read_json_file(NOTIFICATION_CACHE_FILE) or []
max_cache_id = 0
for notification in data:
+4 -2
View File
@@ -31,11 +31,13 @@ class GoogleLens(Service):
super().__init__(**kwargs)
def capture_region(self, dest_path):
from utils.functions import find_binary
# Check for dependencies
if run_command(["which", "grim"]).returncode != 0:
if not find_binary("grim"):
raise RuntimeError("grim not found - please install it")
if run_command(["which", "slurp"]).returncode != 0:
if not find_binary("slurp"):
raise RuntimeError("slurp not found - please install it")
try:
+1 -1
View File
@@ -561,7 +561,7 @@ def close_window(address: str):
def launch_app(command_line: str):
from globalmenu.launch import launch_command
from window.globalmenu.launch import launch_command
launch_command(command_line)
+1 -1
View File
@@ -3,7 +3,7 @@ from pathlib import Path
from fabric.core.service import Property, Service, Signal
from fabric.utils import logger
from utils.utils import EvdevLEDMonitor
from utils.gtk_utils import EvdevLEDMonitor
# Discover NumLock LED device
numlock_leds = list(Path("/sys/class/leds").glob("input*::numlock"))
+3 -2
View File
@@ -47,10 +47,11 @@ class TodoService(Service):
def _load_todos(self):
"""Load todos from JSON file"""
from utils.functions import read_json_file
try:
if self._file_path.exists():
with open(self._file_path, encoding="utf-8") as f:
self._todos = json.load(f)
self._todos = read_json_file(str(self._file_path)) or []
else:
self._todos = []
except Exception as e:
-4
View File
@@ -51,10 +51,6 @@ def create_thumbnail(
return False
def generate_colors_from_wallpaper(image_path: str) -> bool:
return bool(exec_shell_command_async(f'matugen image "{image_path}"'))
class WallpaperService(Service):
@Signal
def wallpaper_ready(self, image_path: str, thumbnail_path: str) -> None: ...