Files
CosairRGBforCachy/k65studio/autostart.py
T
MrBlakeandClaude Opus 5.5 7e276912da K65 Studio: Linux control app for the Corsair K65 PLUS Wireless
Bragi protocol over hidraw, device service with heartbeat and
notifications, PySide6 UI with animated preview, profiles, tray,
autostart, udev rule and installer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 21:02:59 +02:00

40 lines
1.1 KiB
Python

"""XDG autostart entry for starting minimized at login."""
from __future__ import annotations
import os
import shutil
import sys
from pathlib import Path
AUTOSTART_FILE = Path(os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config")) / "autostart" / "k65studio.desktop"
def _exec_line() -> str:
launcher = shutil.which("k65studio")
if launcher:
return f"{launcher} --minimized"
project = Path(__file__).resolve().parent.parent
return f"sh -c 'cd \"{project}\" && exec \"{sys.executable}\" -m k65studio --minimized'"
def is_enabled() -> bool:
return AUTOSTART_FILE.exists()
def set_enabled(enabled: bool) -> None:
if not enabled:
AUTOSTART_FILE.unlink(missing_ok=True)
return
AUTOSTART_FILE.parent.mkdir(parents=True, exist_ok=True)
AUTOSTART_FILE.write_text(
"[Desktop Entry]\n"
"Type=Application\n"
"Name=K65 Studio\n"
"Comment=Corsair K65 PLUS Wireless Beleuchtung und Einstellungen\n"
f"Exec={_exec_line()}\n"
"Icon=k65studio\n"
"X-GNOME-Autostart-enabled=true\n"
"X-KDE-autostart-after=panel\n"
)