zapret-kvn/xray_fluent/startup.py
XrayFluent Dev 626bb17b1e feat: TUN VPN mode via tun2socks, UI improvements, settings overhaul
Major changes:
- TUN mode: tun2socks + xray SOCKS architecture (replaced sing-box)
- Hot-swap: node switching keeps TUN alive, only restarts xray
- Traffic graph: live QPainter chart on dashboard with detail dialog
- Settings: stock qfluentwidgets cards (SpinBox, ColorPicker, PushSettingCard)
- Navigation: fixed icon/text overlap in expanded menu
- Ctrl+V import, copy link from context menu
- System proxy cleanup on exit (atexit safety net)
- Build: data/ backup/restore during PyInstaller rebuild
- Log throttling in TUN mode to prevent UI freeze

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 23:01:50 +03:00

35 lines
1.1 KiB
Python

from __future__ import annotations
from pathlib import Path
import sys
if sys.platform == "win32":
import winreg
RUN_KEY = r"Software\Microsoft\Windows\CurrentVersion\Run"
def set_startup_enabled(app_name: str, enabled: bool, command: str) -> None:
if sys.platform != "win32":
return
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, RUN_KEY, 0, winreg.KEY_SET_VALUE) as key:
if enabled:
winreg.SetValueEx(key, app_name, 0, winreg.REG_SZ, command)
else:
try:
winreg.DeleteValue(key, app_name)
except FileNotFoundError:
pass
def build_startup_command() -> str:
if getattr(sys, "frozen", False):
exe = Path(sys.executable).resolve()
return f'"{exe}" --minimized'
base_dir = Path(__file__).resolve().parents[1]
script = base_dir / "main.py"
venv_pythonw = base_dir / ".venv" / "Scripts" / "pythonw.exe"
python_exe = venv_pythonw if venv_pythonw.exists() else Path(sys.executable).resolve()
return f'"{python_exe}" "{script}" --minimized'