Windows support

This commit is contained in:
sarah committed 2026-10-09 14:21:42 +02:00
1 parent 9757518d8e
commit 8eb9943a30
14 files changed
+92 -17

No files matched your search

+7 -4
View File
@@ -12,7 +12,7 @@ from typing import Callable, Optional
import flet as ft
from Core import AppConfig, ChildEnvironment, ChipButton, Note, NotificationStyle, Palette
from Core import AppConfig, ChildEnvironment, ChipButton, IsWindows, Note, NotificationStyle, Palette
from Library import ConfValue
@@ -72,7 +72,7 @@ class App:
else to the default app."""
from Query import VideoExtensions
Command = ["xdg-open", str(TargetPath)]
Command = None if IsWindows else ["xdg-open", str(TargetPath)] # Windows: os.startfile below
if TargetPath.suffix.lower() in VideoExtensions:
Player = str(ConfValue("Media", "VideoPlayer", "") or "").strip()
if Player and shutil.which(Player.split()[0]):
@@ -80,8 +80,11 @@ class App:
elif Player:
self.Notify(f"Video player '{Player}' isn't installed; using the default app.", "warning")
try:
subprocess.Popen(Command, env=ChildEnvironment(), start_new_session=True,
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if Command is None:
os.startfile(str(TargetPath)) # the default app
else:
subprocess.Popen(Command, env=ChildEnvironment(), start_new_session=True,
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
except OSError as Error:
self.Notify(f"Couldn't open {TargetPath.name}: {Error}", "error")