refactor(src/utils): remove unused imports and functions

This commit is contained in:
sankalp committed 2026-07-09 15:45:39 +05:45
1 parent bb3a92416f
commit f9bef457ca
2 files changed
-65

No files matched your search

-41
View File
@@ -1,7 +1,5 @@
import ctypes import ctypes
import html import html
import json
import os
import subprocess import subprocess
import threading import threading
from typing import Dict, NamedTuple, Optional, TypeVar from typing import Dict, NamedTuple, Optional, TypeVar
@@ -60,38 +58,6 @@ def thread(target, *args, **kwargs) -> threading.Thread:
return th return th
def run_in_thread(func):
"""
Decorator to run the decorated function in a thread.
"""
def wrapper(*args, **kwargs):
return thread(func, *args, **kwargs)
return wrapper
def write_json_file(data: Dict, path: str):
try:
with open(path, "w") as f:
json.dump(data, f, indent=4, ensure_ascii=False)
except Exception as e:
logger.warning(f"Failed to write json: {e}")
def read_json_file(file_path: str) -> Optional[Dict]:
if not os.path.exists(file_path):
logger.error(f"JSON file {file_path} does not exist.")
return None
with open(file_path, "r") as file:
try:
return json.load(file)
except json.JSONDecodeError as e:
logger.error(f"Failed to read JSON file {file_path}: {e}")
return None
def get_wifi_icon_for_strength(strength: int) -> str: def get_wifi_icon_for_strength(strength: int) -> str:
""" """
Get the appropriate WiFi icon based on signal strength. Get the appropriate WiFi icon based on signal strength.
@@ -228,13 +194,6 @@ def find_process_pid(process_name: str, timeout: float | None = None) -> list[st
return [] return []
def toggle_command(command: str, full_command: str):
if is_process_running(command):
kill_process(command)
else:
spawn_detached(full_command.split(" "))
# --- Binary lookup --- # --- Binary lookup ---
-24
View File
@@ -2,32 +2,8 @@ from pathlib import Path
from typing import Literal from typing import Literal
from fabric.utils import Gdk, bulk_connect, exec_shell_command_async from fabric.utils import Gdk, bulk_connect, exec_shell_command_async
from fabric.widgets.scale import Scale
from fabric.widgets.svg import Svg from fabric.widgets.svg import Svg
from shared.widgets.animator import Animator
class AnimatedScale(Scale):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.animator = None
def animate_value(self, value: float):
if not self.animator:
self.animator = Animator(
bezier_curve=(0.34, 1.56, 0.64, 1.0),
duration=0.8,
min_value=self.min_value,
max_value=self.value,
tick_widget=self,
notify_value=lambda p, *_: self.set_value(p.value),
)
self.animator.pause()
self.animator.min_value = self.value
self.animator.max_value = value
self.animator.play()
# Function to set up cursor hover # Function to set up cursor hover
def setup_cursor_hover( def setup_cursor_hover(