fix: format

This commit is contained in:
2 * r + 2 * t
2026-03-09 21:25:33 +11:00
parent 6e59149fbf
commit cc155cf432
5 changed files with 40 additions and 37 deletions
+1 -1
View File
@@ -1,4 +1,3 @@
from pathlib import Path
import json
import re
import shutil
@@ -6,6 +5,7 @@ import subprocess
import time
from argparse import Namespace
from datetime import datetime
from pathlib import Path
from caelestia.utils.notify import close_notification, notify
from caelestia.utils.paths import recording_notif_path, recording_path, recordings_dir, user_config_path
+4 -1
View File
@@ -140,7 +140,10 @@ class Command:
monitor_x = monitor.get("x")
monitor_y = monitor.get("y")
if not all(isinstance(x, (int, float)) for x in [monitor_height, monitor_width, monitor_scale, monitor_x, monitor_y]):
if not all(
isinstance(x, (int, float))
for x in [monitor_height, monitor_width, monitor_scale, monitor_x, monitor_y]
):
return
monitor_height = monitor_height / monitor_scale
+2
View File
@@ -12,9 +12,11 @@ def log_exception(func):
Used by the `apply_()` functions so that an exception, when applying
a theme, does not prevent the other themes from being applied.
"""
def wrapper(*args, **kwargs):
try:
func(*args, **kwargs)
except Exception as e:
log_message(f'Error during execution of "{func.__name__}()": {str(e)}')
return wrapper
+10 -12
View File
@@ -1,11 +1,10 @@
import fcntl
import json
import re
import subprocess
from pathlib import Path
import tempfile
import shutil
import fcntl
import sys
import subprocess
import tempfile
from pathlib import Path
from caelestia.utils.colour import get_dynamic_colours
from caelestia.utils.logging import log_exception
@@ -117,6 +116,7 @@ def write_file(path: Path, content: str) -> None:
f.flush()
shutil.move(f.name, path)
@log_exception
def apply_terms(sequences: str) -> None:
state = c_state_dir / "sequences.txt"
@@ -129,6 +129,7 @@ def apply_terms(sequences: str) -> None:
try:
# Use non-blocking write with timeout to prevent hangs
import os
fd = os.open(str(pt), os.O_WRONLY | os.O_NONBLOCK | os.O_NOCTTY)
try:
os.write(fd, sequences.encode())
@@ -155,6 +156,7 @@ def apply_discord(scss: str) -> None:
for client in "Equicord", "Vencord", "BetterDiscord", "equibop", "vesktop", "legcord":
write_file(config_dir / client / "themes/caelestia.theme.css", conf)
@log_exception
def apply_pandora(colours: dict[str, str], mode: str) -> None:
template = gen_replace(colours, templates_dir / "pandora.json", hash=True)
@@ -197,11 +199,7 @@ def apply_htop(colours: dict[str, str]) -> None:
def sync_papirus_colors(hex_color: str) -> None:
"""Sync Papirus folder icon colors using hue/saturation analysis"""
try:
result = subprocess.run(
["which", "papirus-folders"],
capture_output=True,
check=False
)
result = subprocess.run(["which", "papirus-folders"], capture_output=True, check=False)
if result.returncode != 0:
return
except Exception:
@@ -247,7 +245,7 @@ def sync_papirus_colors(hex_color: str) -> None:
["sudo", "-n", "papirus-folders", "-C", color, "-u"],
stderr=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
start_new_session=True
start_new_session=True,
)
except Exception:
pass
@@ -380,7 +378,7 @@ def apply_colours(colours: dict[str, str], mode: str) -> None:
c_state_dir.mkdir(parents=True, exist_ok=True)
try:
with open(lock_file, 'w') as lock_fd:
with open(lock_file, "w") as lock_fd:
try:
fcntl.flock(lock_fd.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
except BlockingIOError:
+1 -1
View File
@@ -125,6 +125,7 @@ def get_colours_for_wall(wall: Path | str, no_smart: bool) -> None:
"colours": get_colours_for_image(get_thumb(wall, cache), scheme),
}
def convert_gif(wall: Path) -> Path:
cache = wallpapers_cache_dir / compute_hash(wall)
output_path = cache / "first_frame.png"
@@ -143,7 +144,6 @@ def convert_gif(wall: Path) -> Path:
return output_path
def set_wallpaper(wall: Path | str, no_smart: bool) -> None:
# Make path absolute
wall = Path(wall).resolve()