From: Danilo M. Date: Sun, 3 May 2026 13:35:46 +0000 (+0200) Subject: feat: add typora_args config field for Wayland launch flags X-Git-Tag: v1.2~4 X-Git-Url: https://git.danix.xyz/?a=commitdiff_plain;h=273915dafd51c0ef7aa1ac3f74cb6192497b9b09;p=publisher.git feat: add typora_args config field for Wayland launch flags Allows passing extra CLI args (e.g. --ozone-platform=wayland) to Typora at launch without baking them into the binary path. Co-Authored-By: Claude Sonnet 4.6 --- diff --git a/core/config.py b/core/config.py index 76ea3ba..68a8b87 100644 --- a/core/config.py +++ b/core/config.py @@ -10,6 +10,7 @@ class Config: blog_repo: str = "" transart_script: str = "/home/danix/bin/transart.py" typora_bin: str = "typora" + typora_args: str = "" font_size: int = 10 def is_complete(self) -> bool: @@ -21,6 +22,7 @@ class Config: doc.add("blog_repo", self.blog_repo) doc.add("transart_script", self.transart_script) doc.add("typora_bin", self.typora_bin) + doc.add("typora_args", self.typora_args) doc.add("font_size", self.font_size) path.write_text(tomlkit.dumps(doc)) @@ -34,5 +36,6 @@ class Config: blog_repo=str(data.get("blog_repo", defaults.blog_repo)), transart_script=str(data.get("transart_script", defaults.transart_script)), typora_bin=str(data.get("typora_bin", defaults.typora_bin)), + typora_args=str(data.get("typora_args", defaults.typora_args)), font_size=int(data.get("font_size", defaults.font_size)), ) diff --git a/ui/main_window.py b/ui/main_window.py index cc3326f..b29ff57 100644 --- a/ui/main_window.py +++ b/ui/main_window.py @@ -89,6 +89,7 @@ class MainWindow(QMainWindow): self._translation_view = TranslationView( self.config.transart_script, self.config.typora_bin, + self.config.typora_args, parent=self, ) self._translation_view.push_master.connect(lambda: self._do_git_push("master")) @@ -208,7 +209,8 @@ class MainWindow(QMainWindow): self._stack.setCurrentIndex(self._page_detail) def _do_open_typora(self, article: Article): - subprocess.Popen([self.config.typora_bin, str(article.path)]) + _args = self.config.typora_args.split() if self.config.typora_args else [] + subprocess.Popen([self.config.typora_bin, *_args, str(article.path)]) def _do_open_frontmatter(self, article: Article): from ui.frontmatter_editor import FrontmatterEditor @@ -221,7 +223,8 @@ class MainWindow(QMainWindow): dlg = NewArticleDialog(Path(self.config.blog_repo), self) if dlg.exec() and dlg.created_path: self._refresh_articles() - subprocess.Popen([self.config.typora_bin, str(dlg.created_path)]) + _args = self.config.typora_args.split() if self.config.typora_args else [] + subprocess.Popen([self.config.typora_bin, *_args, str(dlg.created_path)]) def _do_translate(self, article: Article): self._translation_view.start_translation(article) diff --git a/ui/setup_dialog.py b/ui/setup_dialog.py index 4a8c6b7..d99696e 100644 --- a/ui/setup_dialog.py +++ b/ui/setup_dialog.py @@ -33,6 +33,9 @@ class SetupDialog(QDialog): self._typora = QLineEdit(self._config.typora_bin) form.addRow("Typora bin:", self._typora) + self._typora_args = QLineEdit(self._config.typora_args) + form.addRow("Typora args:", self._typora_args) + layout.addLayout(form) btns = QHBoxLayout() @@ -51,5 +54,6 @@ class SetupDialog(QDialog): self._config.blog_repo = self._blog_repo.text().strip() self._config.transart_script = self._transart.text().strip() self._config.typora_bin = self._typora.text().strip() + self._config.typora_args = self._typora_args.text().strip() self._config.save() self.accept() diff --git a/ui/translation_view.py b/ui/translation_view.py index 6ce53dd..cf72ce5 100644 --- a/ui/translation_view.py +++ b/ui/translation_view.py @@ -18,10 +18,11 @@ class TranslationView(QWidget): push_master = pyqtSignal() publish = pyqtSignal() - def __init__(self, transart_script: str, typora_bin: str, parent=None): + def __init__(self, transart_script: str, typora_bin: str, typora_args: str = "", parent=None): super().__init__(parent) self._transart_script = transart_script self._typora_bin = typora_bin + self._typora_args = typora_args self._article: Article | None = None self._worker: TranslationWorker | None = None self._output_path: str = "" @@ -106,7 +107,8 @@ class TranslationView(QWidget): def _open_typora(self): if self._output_path: - subprocess.Popen([self._typora_bin, self._output_path]) + _args = self._typora_args.split() if self._typora_args else [] + subprocess.Popen([self._typora_bin, *_args, self._output_path]) def _retry(self): if self._article: