Skip to content

Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.

Linux: tell the user when no file manager can open a folder, honor the desktop's Documents folder

Bowen Xue450d64c36f91
diff --git a/freevideo_engine/image_gen/service.py b/freevideo_engine/image_gen/service.py
index 3ff148f..0c4b7a7 100644
--- a/freevideo_engine/image_gen/service.py
+++ b/freevideo_engine/image_gen/service.py
@@ -353,9 +353,9 @@ class Service:
if failure:
raise failure[0]
else:
- from .. import processes
- processes.popen(['xdg-open', folder], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
- stderr=subprocess.DEVNULL, start_new_session=True)
+ from ..windows_ux import open_folder
+ if not open_folder(folder):
+ raise OSError('No file manager is available to open the folder.')
return dict(opened=True)
def close_segment_worker(self):
diff --git a/freevideo_engine/launcher_copy.py b/freevideo_engine/launcher_copy.py
index 65e54d4..86447b6 100644
--- a/freevideo_engine/launcher_copy.py
+++ b/freevideo_engine/launcher_copy.py
@@ -9,6 +9,8 @@ from .model_status import NAMES
ACTION_COPY = {
'download_missing': ('The download folder no longer exists. Export the list again.',
'下载目录已不存在,请重新导出清单'),
+ 'folder_open_failed': ('This system has no file manager to open the folder. Open it from your own file manager.',
+ '此系统没有可用的文件管理器来打开该文件夹,请在自己的文件管理器中打开'),
'installation_missing': ('There is no installation information yet. Complete installation first.',
'还没有安装信息,请先完成安装'),
'installation_unavailable': ('The saved ComfyUI folder could not be opened. It may have been moved or renamed, or its drive may be disconnected. Choose its current location below, or install ComfyUI.',
diff --git a/freevideo_engine/launcher_settings.py b/freevideo_engine/launcher_settings.py
index c502e7d..c597f43 100644
--- a/freevideo_engine/launcher_settings.py
+++ b/freevideo_engine/launcher_settings.py
@@ -2,6 +2,7 @@
from contextlib import ExitStack, contextmanager
import json
import os
+import re
from pathlib import Path
import shutil
import sys
@@ -139,9 +140,34 @@ def documents_directory():
function.restype = ctypes.c_long
if function(None, 5, None, 0, buffer) == 0 and buffer.value:
return Path(buffer.value)
+ if os.name != 'nt':
+ configured = xdg_documents_directory()
+ if configured:
+ return configured
return Path.home() / 'Documents'
+def xdg_documents_directory():
+ """The Documents folder the desktop chose (localized or moved), from the XDG user-dirs file."""
+ value = os.environ.get('XDG_DOCUMENTS_DIR')
+ if not value:
+ base = Path(os.environ.get('XDG_CONFIG_HOME') or Path.home() / '.config')
+ try:
+ text = (base / 'user-dirs.dirs').read_text(encoding='utf-8')
+ except (OSError, UnicodeError):
+ return None
+ match = re.search(r'^\s*XDG_DOCUMENTS_DIR\s*=\s*"([^"\n]+)"', text, re.M)
+ value = match.group(1) if match else None
+ if not value:
+ return None
+ value = value.replace('$HOME', str(Path.home()))
+ path = Path(value)
+ # An unset folder is written as $HOME itself; that is not a Documents folder.
+ if not path.is_absolute() or path == Path.home():
+ return None
+ return path
+
+
class Store:
def __init__(self, legacy_root, documents=None):
self.local = Path(legacy_root) / 'comfy-launcher.json'
diff --git a/freevideo_engine/modern_launcher.py b/freevideo_engine/modern_launcher.py
index 60a0512..e781524 100644
--- a/freevideo_engine/modern_launcher.py
+++ b/freevideo_engine/modern_launcher.py
@@ -314,6 +314,12 @@ def create_ui(session, *, show=True):
if folder and Path(folder).is_dir():
if session.action_notice == 'download_missing':
session.action_notice = ''
+ if sys.platform.startswith('linux'):
+ from .windows_ux import open_folder
+ if not open_folder(Path(folder).resolve()):
+ session.action_notice = 'folder_open_failed'
+ self.refresh()
+ return
self.invoke(QDesktopServices.openUrl, QUrl.fromLocalFile(str(Path(folder).resolve())))
else:
session.action_notice = 'download_missing'
diff --git a/freevideo_engine/windows_ux.py b/freevideo_engine/windows_ux.py
index 0a0b5f4..d7a1b7e 100644
--- a/freevideo_engine/windows_ux.py
+++ b/freevideo_engine/windows_ux.py
@@ -15,6 +15,31 @@ def taskbar_identity():
function('FlashML.FreeVideo.Launcher')
+def folder_opener():
+ """The command that shows a folder in the file manager, or None when the system has none."""
+ import shutil
+ for name, extra in (('xdg-open', []), ('gio', ['open'])):
+ found = shutil.which(name)
+ if found:
+ return [found] + extra
+ return None
+
+
+def open_folder(folder):
+ """Show a folder in the file manager on Linux; False when no opener exists or it cannot start."""
+ import subprocess
+ from .linux_bundle import child_environment
+ command = folder_opener()
+ if not command:
+ return False
+ try:
+ subprocess.Popen(command + [str(folder)], env=child_environment(), stdin=subprocess.DEVNULL,
+ stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, start_new_session=True)
+ except OSError:
+ return False
+ return True
+
+
def open_browser(url):
"""Use Windows' URL association directly and retain its actionable errors."""
with external_python():