Skip to content

Doubao-powered voice input for Linux, Wayland and Omarchy

feat(packaging): add store packages and stabilize Linux CI (#79)

Leyangc9d8092fc58c
diff --git a/.github/workflows/midscene-omarchy-4.0.3.yml b/.github/workflows/midscene-omarchy-4.0.3.yml
index b8a92fa..660b4c8 100644
--- a/.github/workflows/midscene-omarchy-4.0.3.yml
+++ b/.github/workflows/midscene-omarchy-4.0.3.yml
@@ -57,8 +57,10 @@ permissions:
packages: read
concurrency:
- group: midscene-model-e2e-${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+ # These workflows use the same model credentials and token quota. Keep a
+ # running visual suite alive and queue the newest suite across branches.
+ group: midscene-model-e2e
+ cancel-in-progress: false
jobs:
omarchy-e2e:
diff --git a/.github/workflows/midscene-ubuntu-22.04.yml b/.github/workflows/midscene-ubuntu-22.04.yml
index 9570dad..30167c4 100644
--- a/.github/workflows/midscene-ubuntu-22.04.yml
+++ b/.github/workflows/midscene-ubuntu-22.04.yml
@@ -27,8 +27,10 @@ permissions:
contents: read
concurrency:
- group: midscene-model-e2e-${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+ # These workflows use the same model credentials and token quota. Keep a
+ # running visual suite alive and queue the newest suite across branches.
+ group: midscene-model-e2e
+ cancel-in-progress: false
jobs:
ubuntu-e2e:
diff --git a/.github/workflows/store-packages.yml b/.github/workflows/store-packages.yml
new file mode 100644
index 0000000..7413f26
--- /dev/null
+++ b/.github/workflows/store-packages.yml
@@ -0,0 +1,82 @@
+name: Linux store packages
+on:
+ workflow_dispatch:
+ pull_request:
+ paths: ['packaging/**', 'src/**', '.github/workflows/store-packages.yml']
+permissions:
+ contents: read
+jobs:
+ rpm:
+ name: RPM / Fedora 44
+ runs-on: ubuntu-latest
+ timeout-minutes: 30
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
+ with:
+ persist-credentials: false
+ - name: Stage product source
+ run: python3 packaging/build-store.py rpm --output "$RUNNER_TEMP/rpm"
+ - name: Build, install and remove on Fedora
+ run: |
+ docker run --rm -v "$RUNNER_TEMP/rpm:/build" fedora:44 bash -euxc '
+ dnf install -y desktop-file-utils rpm-build python3-devel gtk4 webkitgtk6.0 python3-gobject python3-cairo python3-websockets python3-evdev pipewire-utils wl-clipboard
+ rpmbuild --define "_topdir /build" -bb /build/SPECS/doubao-say.spec
+ dnf install -y /build/RPMS/noarch/*.rpm
+ python3 -c "import gi, websockets, evdev; gi.require_version(\"Gtk\", \"4.0\"); gi.require_version(\"WebKit\", \"6.0\"); from gi.repository import Gtk, WebKit"
+ test -x /usr/bin/doubao-say
+ python3 -c "import doubao_input; from importlib.resources import files; assert files(doubao_input).joinpath(\"resources/logo.png\").is_file()"
+ desktop-file-validate /usr/share/applications/md.lifeos.DoubaoSay.desktop
+ env -u PYTHONPATH python3 -c "import doubao_input; from doubao_input.settings import install_desktop; import tempfile, os; os.environ[\"XDG_DATA_HOME\"] = tempfile.mkdtemp(); path = install_desktop(portal=True); assert path.parent.parent == __import__(\"pathlib\").Path(\"/usr/share\"); assert \"Exec=doubao-say\" in path.read_text(); assert \"NoDisplay=true\" not in path.read_text()"
+ rpm -ql doubao-say | grep "/NOTICE$"
+ rpm -V doubao-say
+ dnf remove -y doubao-say
+ test ! -e /usr/bin/doubao-say
+ '
+ - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
+ with:
+ name: store-rpm
+ path: |
+ ${{ runner.temp }}/rpm/RPMS/noarch/*.rpm
+ ${{ runner.temp }}/rpm/SOURCE.json
+ if-no-files-found: error
+ flatpak:
+ name: Flatpak / GNOME 49
+ runs-on: ubuntu-latest
+ timeout-minutes: 60
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
+ with:
+ persist-credentials: false
+ - name: Install Flatpak builder and runtime
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y flatpak flatpak-builder xvfb xdotool
+ sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
+ flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
+ flatpak install --user --noninteractive flathub org.gnome.Sdk//49 org.gnome.Platform//49
+ - name: Build bundle with pinned dependencies
+ run: |
+ version=$(python3 packaging/build-store.py flatpak --output "$RUNNER_TEMP/flatpak")
+ cd "$RUNNER_TEMP/flatpak"
+ flatpak-builder --user --force-clean --repo=repo build md.lifeos.DoubaoSay.json
+ flatpak build-bundle repo "doubao-say-${version}-linux-x86_64.flatpak" md.lifeos.DoubaoSay --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo
+ - name: Install, inspect sandbox and remove bundle
+ run: |
+ flatpak install --user --noninteractive "$RUNNER_TEMP"/flatpak/*.flatpak
+ dbus-run-session -- flatpak run --command=sh md.lifeos.DoubaoSay -ec '
+ test -x /app/bin/doubao-say
+ test -x /app/bin/pw-record
+ test -s /app/share/licenses/doubao-say/NOTICE
+ PYTHONPATH=/app/share/doubao-say python3 -c "from doubao_input.doubao.host_tools import has_tool; assert not has_tool(\"doubao-say-missing-tool-ci\")"
+ PYTHONPATH=/app/share/doubao-say python3 -c "import gi, websockets, evdev; gi.require_version(\"Gtk\", \"4.0\"); gi.require_version(\"WebKit\", \"6.0\"); gi.require_version(\"Gtk4LayerShell\", \"1.0\"); from gi.repository import Gtk, WebKit, Gtk4LayerShell"
+ '
+ xvfb-run -a dbus-run-session -- python3 packaging/store/smoke-launch.py -- flatpak run --env=GDK_BACKEND=x11 md.lifeos.DoubaoSay
+ flatpak info --user --show-permissions md.lifeos.DoubaoSay
+ flatpak uninstall --user --noninteractive md.lifeos.DoubaoSay
+ - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
+ with:
+ name: store-flatpak
+ path: |
+ ${{ runner.temp }}/flatpak/*.flatpak
+ ${{ runner.temp }}/flatpak/SOURCE.json
+ if-no-files-found: error
diff --git a/packaging/build-store.py b/packaging/build-store.py
new file mode 100644
index 0000000..3daad70
--- /dev/null
+++ b/packaging/build-store.py
@@ -0,0 +1,45 @@
+"""Stage only product files for native RPM and Flatpak builders."""
+import argparse
+import json
+from pathlib import Path
+import shutil
+import subprocess
+import tarfile
+import tomllib
+
+ROOT = Path(__file__).resolve().parent.parent
+
+
+def main():
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument('kind', choices=('rpm', 'flatpak'))
+ parser.add_argument('--output', type=Path, required=True)
+ args = parser.parse_args()
+ output = args.output.resolve()
+ if output.exists():
+ raise SystemExit('Output must be a new directory')
+ version = tomllib.loads((ROOT / 'pyproject.toml').read_text())['project']['version']
+ output.mkdir(parents=True)
+ source = output / ('source' if args.kind == 'flatpak' else f'doubao-say-{version}')
+ source.mkdir()
+ # Never copy Git metadata, credentials, ignored build products, or caches.
+ shutil.copytree(ROOT / 'src', source / 'src', ignore=shutil.ignore_patterns('__pycache__', '*.pyc'))
+ shutil.copytree(ROOT / 'packaging/store', source / 'packaging/store')
+ for name in ('README.md', 'LICENSE', 'NOTICE', 'pyproject.toml'):
+ shutil.copy2(ROOT / name, source / name)
+ revision = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=ROOT, text=True).strip()
+ (output / 'SOURCE.json').write_text(json.dumps({'version': version, 'commit': revision}, indent=2) + '\n')
+ if args.kind == 'rpm':
+ for name in ('SOURCES', 'SPECS', 'BUILD', 'BUILDROOT', 'RPMS', 'SRPMS'):
+ (output / name).mkdir()
+ with tarfile.open(output / 'SOURCES' / f'doubao-say-{version}.tar.gz', 'w:gz') as archive:
+ archive.add(source, arcname=source.name)
+ spec = (ROOT / 'packaging/store/doubao-say.spec').read_text().replace('@VERSION@', version)
+ (output / 'SPECS/doubao-say.spec').write_text(spec)
+ else:
+ shutil.copy2(ROOT / 'packaging/store/md.lifeos.DoubaoSay.json', output)
+ print(version)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/packaging/store/README.md b/packaging/store/README.md
new file mode 100644
index 0000000..3fe31ea
--- /dev/null
+++ b/packaging/store/README.md
@@ -0,0 +1,54 @@
+# Linux store packages
+
+RPM and Flatpak builders complement the existing archive installer. Packages use
+`md.lifeos.DoubaoSay` for desktop integration and do not enable a background
+service, change input-group membership, or install udev rules.
+
+## RPM (Fedora 44)
+
+```sh
+python3 packaging/build-store.py rpm --output /tmp/doubao-rpm
+rpmbuild --define '_topdir /tmp/doubao-rpm' -bb /tmp/doubao-rpm/SPECS/doubao-say.spec
+sudo dnf install /tmp/doubao-rpm/RPMS/noarch/doubao-say-*.rpm
+```
+
+Use DNF so system dependencies are resolved. This package is tested on Fedora
+44; an RPM filename alone does not establish compatibility with other RPM-based
+distributions. GNOME uses the GlobalShortcuts permission dialog. Other desktops
+may need the input permissions described in `packaging/INSTALL.md`.
+
+## Flatpak (GNOME 49 runtime)
+
+```sh
+flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
+flatpak install --user flathub org.gnome.Sdk//49 org.gnome.Platform//49
+python3 packaging/build-store.py flatpak --output /tmp/doubao-flatpak
+cd /tmp/doubao-flatpak
+flatpak-builder --user --repo=repo build md.lifeos.DoubaoSay.json
+flatpak build-bundle repo doubao-say.flatpak md.lifeos.DoubaoSay --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo
+flatpak install --user ./doubao-say.flatpak
+flatpak run md.lifeos.DoubaoSay
+```
+
+**This is a desktop-integration Flatpak, not an isolated offline application.**
+It requests device access and `org.freedesktop.Flatpak` host-command access:
+`flatpak-spawn --host` runs the host's PipeWire, clipboard and input helpers.
+Install `pw-record`/`pw-dump` (PipeWire utilities) on the host. Wayland clipboard
+integration needs `wl-copy`/`wl-paste`; native X11 automatic paste needs
+`xdotool` and `xclip`. Hyprland integration additionally uses `hyprctl`.
+Host input permissions still apply; granting Flatpak permissions does not grant
+access to protected input devices. Credentials and application state use the
+Flatpak's private XDG directories. Recognition requires an online provider.
+
+The bundle is intended for direct installation and evaluation. It is not listed
+on Flathub, and its host-command permission has not been approved by Flathub or
+any third-party app store.
+
+## Verification and provenance
+
+`Linux store packages` CI builds both formats, installs each in Linux, verifies
+GTK/WebKit and Python imports plus desktop resources, then uninstalls it.
+`SOURCE.json` identifies the application version and build commit. These gates
+verify packaging and runtime dependencies; they do not claim a real microphone,
+login, global shortcut or cross-application paste test. Those require a desktop
+acceptance run before describing a store listing as supported.
diff --git a/packaging/store/doubao-say.spec b/packaging/store/doubao-say.spec
new file mode 100644
index 0000000..9ba4dd1
--- /dev/null
+++ b/packaging/store/doubao-say.spec
@@ -0,0 +1,56 @@
+Name: doubao-say
+Version: @VERSION@
+Release: 1%{?dist}
+Summary: Voice input for Linux desktops
+License: MIT
+URL: https://doubao-say.lifeos.md/
+Source0: doubao-say-%{version}.tar.gz
+BuildArch: noarch
+BuildRequires: python3-devel
+Requires: python(abi) = %{python3_version}
+Requires: python3 >= 3.11
+Requires: python3-gobject
+Requires: python3-cairo
+Requires: python3-websockets
+Requires: python3-evdev
+Requires: gtk4
+Requires: webkitgtk6.0
+Requires: pipewire-utils
+Requires: wl-clipboard
+Recommends: python3-sounddevice
+Recommends: xdotool
+Recommends: xclip
+Recommends: wmctrl
+Recommends: gtk4-layer-shell
+
+%description
+GTK4 desktop voice input with configurable shortcuts and online recognition.
+Uses Doubao web sign-in or the user's Volcengine/Deepgram API credentials.
+No services are started and no input-group memberships are modified on install.
+
+%prep
+%setup -q
+
+%build
+
+%install
+mkdir -p %{buildroot}%{python3_sitelib} %{buildroot}%{_bindir}
+cp -a src/doubao_input %{buildroot}%{python3_sitelib}/
+find %{buildroot}%{python3_sitelib}/doubao_input -name __pycache__ -type d -exec rm -rf {} +
+cat > %{buildroot}%{_bindir}/doubao-say <<'LAUNCHER'
+#!/bin/sh
+exec /usr/bin/python3 -m doubao_input "$@"
+LAUNCHER
+chmod 755 %{buildroot}%{_bindir}/doubao-say
+install -Dm644 packaging/store/md.lifeos.DoubaoSay.desktop %{buildroot}%{_datadir}/applications/md.lifeos.DoubaoSay.desktop
+install -Dm644 packaging/store/md.lifeos.DoubaoSay.metainfo.xml %{buildroot}%{_datadir}/metainfo/md.lifeos.DoubaoSay.metainfo.xml
+install -Dm644 src/doubao_input/resources/logo-128.png %{buildroot}%{_datadir}/icons/hicolor/128x128/apps/md.lifeos.DoubaoSay.png
+
+%files
+%license LICENSE NOTICE
+%doc README.md
+%{_bindir}/doubao-say
+%{python3_sitelib}/doubao_input/
+%{_datadir}/applications/md.lifeos.DoubaoSay.desktop
+%{_datadir}/metainfo/md.lifeos.DoubaoSay.metainfo.xml
+%{_datadir}/icons/hicolor/128x128/apps/md.lifeos.DoubaoSay.png
diff --git a/packaging/store/host-tool.sh b/packaging/store/host-tool.sh
new file mode 100644
index 0000000..f96a7fb
--- /dev/null
+++ b/packaging/store/host-tool.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+# Desktop integration intentionally runs the corresponding host tool.
+exec flatpak-spawn --host "$(basename "$0")" "$@"
diff --git a/packaging/store/launch.sh b/packaging/store/launch.sh
new file mode 100644
index 0000000..566de1c
--- /dev/null
+++ b/packaging/store/launch.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+export PYTHONPATH="@PREFIX@/share/doubao-say${PYTHONPATH:+:$PYTHONPATH}"
+exec python3 -m doubao_input "$@"
diff --git a/packaging/store/md.lifeos.DoubaoSay.desktop b/packaging/store/md.lifeos.DoubaoSay.desktop
new file mode 100644
index 0000000..4b51697
--- /dev/null
+++ b/packaging/store/md.lifeos.DoubaoSay.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Type=Application
+Name=Doubao Say
+Name[zh_CN]=豆包说
+Comment=Speak with a configurable shortcut and insert the transcript
+Exec=doubao-say
+Icon=md.lifeos.DoubaoSay
+Terminal=false
+Categories=Utility;TextTools;AudioVideo;
+StartupNotify=false
diff --git a/packaging/store/md.lifeos.DoubaoSay.json b/packaging/store/md.lifeos.DoubaoSay.json
new file mode 100644
index 0000000..1683709
--- /dev/null
+++ b/packaging/store/md.lifeos.DoubaoSay.json
@@ -0,0 +1,140 @@
+{
+ "app-id": "md.lifeos.DoubaoSay",
+ "runtime": "org.gnome.Platform",
+ "runtime-version": "49",
+ "sdk": "org.gnome.Sdk",
+ "command": "doubao-say",
+ "finish-args": [
+ "--share=network",
+ "--share=ipc",
+ "--socket=wayland",
+ "--socket=fallback-x11",
+ "--device=all",
+ "--talk-name=org.freedesktop.Flatpak"
+ ],
+ "modules": [
+ {
+ "name": "gtk4-layer-shell",
+ "buildsystem": "meson",
+ "config-opts": [
+ "-Ddocs=false",
+ "-Dexamples=false",
+ "-Dtests=false",
+ "-Dvapi=false",
+ "--libdir=lib"
+ ],
+ "sources": [
+ {
+ "type": "archive",
+ "url": "https://github.com/wmww/gtk4-layer-shell/archive/536ff516ed68b9bb34afc4c07f942a54b2b4b03f.tar.gz",
+ "sha256": "f4c4fd455f5605c7b93b305b6be28990f0f7170968fb2714bf362477f918c4bc"
+ }
+ ],
+ "post-install": [
+ "install -Dm644 /run/build/gtk4-layer-shell/LICENSE /app/share/licenses/gtk4-layer-shell/LICENSE"
+ ]
+ },
+ {
+ "name": "python-pycparser",
+ "buildsystem": "simple",
+ "build-commands": [
+ "pip3 install --no-index --no-deps --no-build-isolation --prefix=/app ."
+ ],
+ "sources": [
+ {
+ "type": "archive",
+ "url": "https://files.pythonhosted.org/packages/1b/7d/92392ff7815c21062bea51aa7b87d45576f649f16458d78b7cf94b9ab2e6/pycparser-3.0.tar.gz",
+ "sha256": "600f49d217304a5902ac3c37e1281c9fe94e4d0489de643a9504c5cdfdfc6b29"
+ }
+ ]
+ },
+ {
+ "name": "python-cffi",
+ "buildsystem": "simple",
+ "build-commands": [
+ "pip3 install --no-index --no-deps --no-build-isolation --prefix=/app ."
+ ],
+ "sources": [
+ {
+ "type": "archive",
+ "url": "https://files.pythonhosted.org/packages/9e/ef/008a1939e372c06329a3fce4279c02f328488f3526744906eeec3da7ad5f/cffi-2.1.1.tar.gz",
+ "sha256": "dd31f52ea1086513bb9df30f8fcee9b8918323ae067a3d5b78bc826a000712be"
+ }
+ ]
+ },
+ {
+ "name": "python-sounddevice",
+ "buildsystem": "simple",
+ "build-commands": [
+ "pip3 install --no-index --no-deps --no-build-isolation --prefix=/app ."
+ ],
+ "sources": [
+ {
+ "type": "archive",
+ "url": "https://files.pythonhosted.org/packages/ec/db/0c890e2d9aab9ba284021efc02e1d3aebfecab1b611762d7434602209bcf/sounddevice-0.5.6.tar.gz",
+ "sha256": "8ec9fbfde2e32f020b167e348f3ab3bac6625a5f15af524d790108ac7147a410"
+ }
+ ]
+ },
+ {
+ "name": "python-websockets",
+ "buildsystem": "simple",
+ "build-commands": [
+ "pip3 install --no-index --no-deps --no-build-isolation --prefix=/app ."
+ ],
+ "sources": [
+ {
+ "type": "archive",
+ "url": "https://files.pythonhosted.org/packages/18/72/fba934cb3dff7a85d811820efffcd141ddd52b5a2a01637f64551373ff4d/websockets-17.1.tar.gz",
+ "sha256": "acfea4c20bf54384883ea33b1240fc1db4f52e190823a4e2b334bc3e8bfca96a"
+ }
+ ]
+ },
+ {
+ "name": "python-evdev",
+ "buildsystem": "simple",
+ "build-commands": [
+ "pip3 install --no-index --no-deps --no-build-isolation --prefix=/app ."
+ ],
+ "sources": [
+ {
+ "type": "archive",
+ "url": "https://files.pythonhosted.org/packages/2e/07/eb30593524303d1367f0dc00c1c66582c994dba412a47751e34bad9fa29b/evdev-2.0.0.tar.gz",
+ "sha256": "442fb3f4c8dfc9e61e901133c356220c02d663eca8f34722e0cecdd637eba504"
+ }
+ ]
+ },
+ {
+ "name": "doubao-say",
+ "buildsystem": "simple",
+ "build-commands": [
+ "mkdir -p /app/share/doubao-say /app/bin",
+ "cp -a src/doubao_input /app/share/doubao-say/",
+ "sed \"s|@PREFIX@|/app|g\" packaging/store/launch.sh > /app/bin/doubao-say",
+ "chmod 755 /app/bin/doubao-say",
+ "install -Dm644 packaging/store/md.lifeos.DoubaoSay.desktop /app/share/applications/md.lifeos.DoubaoSay.desktop",
+ "install -Dm644 packaging/store/md.lifeos.DoubaoSay.metainfo.xml /app/share/metainfo/md.lifeos.DoubaoSay.metainfo.xml",
+ "install -Dm644 src/doubao_input/resources/logo-128.png /app/share/icons/hicolor/128x128/apps/md.lifeos.DoubaoSay.png",
+ "install -Dm755 packaging/store/host-tool.sh /app/bin/pw-record",
+ "install -Dm755 packaging/store/host-tool.sh /app/bin/pw-dump",
+ "install -Dm755 packaging/store/host-tool.sh /app/bin/wl-copy",
+ "install -Dm755 packaging/store/host-tool.sh /app/bin/wl-paste",
+ "install -Dm755 packaging/store/host-tool.sh /app/bin/xdotool",
+ "install -Dm755 packaging/store/host-tool.sh /app/bin/xclip",
+ "install -Dm755 packaging/store/host-tool.sh /app/bin/xprop",
+ "install -Dm755 packaging/store/host-tool.sh /app/bin/wmctrl",
+ "install -Dm755 packaging/store/host-tool.sh /app/bin/hyprctl",
+ "install -Dm755 packaging/store/host-tool.sh /app/bin/wtype",
+ "install -Dm644 LICENSE /app/share/licenses/doubao-say/LICENSE",
+ "install -Dm644 NOTICE /app/share/licenses/doubao-say/NOTICE",
+ "install -Dm644 README.md /app/share/doc/doubao-say/README.md"
+ ],
+ "sources": [
+ {
+ "type": "dir",
+ "path": "source"
+ }
+ ]
+ }
+ ]
+}
diff --git a/packaging/store/md.lifeos.DoubaoSay.metainfo.xml b/packaging/store/md.lifeos.DoubaoSay.metainfo.xml
new file mode 100644
index 0000000..340dfd9
--- /dev/null
+++ b/packaging/store/md.lifeos.DoubaoSay.metainfo.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<component type="desktop-application">
+ <id>md.lifeos.DoubaoSay</id>
+ <name>Doubao Say</name>
+ <summary>Voice input for Linux desktops</summary>
+ <metadata_license>CC0-1.0</metadata_license>
+ <project_license>MIT</project_license>
+ <description><p>Press a configurable shortcut, speak, and insert the transcript into another application. Recognition uses online services: Doubao web sign-in, the official Volcengine API, or Deepgram. API services require your own credentials.</p><p>The Flatpak edition uses host desktop helpers for microphone capture and clipboard integration, and requires permission to run host commands.</p></description>
+ <launchable type="desktop-id">md.lifeos.DoubaoSay.desktop</launchable>
+ <url type="homepage">https://doubao-say.lifeos.md/</url>
+ <url type="bugtracker">https://github.com/quanru/doubao-say/issues</url>
+ <developer id="md.lifeos"><name>Doubao Say contributors</name></developer>
+ <content_rating type="oars-1.1"/>
+</component>
diff --git a/packaging/store/smoke-launch.py b/packaging/store/smoke-launch.py
new file mode 100644
index 0000000..d7f3d89
--- /dev/null
+++ b/packaging/store/smoke-launch.py
@@ -0,0 +1,42 @@
+"""Require a visible app window and a live process before stopping our own app."""
+import os
+import subprocess
+import sys
+import tempfile
+import time
+
+
+def main():
+ command = sys.argv[1:]
+ if command[:1] == ['--']:
+ command = command[1:]
+ env = {**os.environ, 'XDG_SESSION_TYPE': 'x11'}
+ env.pop('WAYLAND_DISPLAY', None)
+ env.pop('HYPRLAND_INSTANCE_SIGNATURE', None)
+ with tempfile.TemporaryFile(mode='w+') as log:
+ process = subprocess.Popen(command, env=env, stdout=log, stderr=log, start_new_session=True)
+ try:
+ deadline = time.monotonic() + 20
+ while time.monotonic() < deadline and process.poll() is None:
+ windows = subprocess.run(['xdotool', 'search', '--onlyvisible', '--name', 'Doubao Say'],
+ stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True)
+ if windows.returncode == 0 and windows.stdout.strip():
+ print('PASS: live application and visible Doubao Say window')
+ return
+ time.sleep(0.5)
+ log.seek(0)
+ raise SystemExit('Application launch failed:\n' + log.read())
+ finally:
+ import signal
+ try:
+ os.killpg(process.pid, signal.SIGTERM)
+ process.wait(timeout=5)
+ except ProcessLookupError:
+ pass
+ except subprocess.TimeoutExpired:
+ os.killpg(process.pid, signal.SIGKILL)
+ process.wait()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/src/doubao_input/doubao/audio_capture.py b/src/doubao_input/doubao/audio_capture.py
index 4eb270b..7e38471 100644
--- a/src/doubao_input/doubao/audio_capture.py
+++ b/src/doubao_input/doubao/audio_capture.py
@@ -16,7 +16,7 @@ import logging
import threading
import os
import select
-import shutil
+from doubao_input.doubao.host_tools import has_tool
import subprocess
from typing import Any
@@ -65,7 +65,7 @@ class AudioCapture:
# The picker returns PipeWire node names on X11 and Wayland. Use the
# matching backend; retain sounddevice when native capture is unavailable.
- if (os.environ.get("WAYLAND_DISPLAY") or is_x11()) and shutil.which("pw-record"):
+ if (os.environ.get("WAYLAND_DISPLAY") or is_x11()) and has_tool("pw-record"):
self._start_pipewire()
return
diff --git a/src/doubao_input/doubao/host_tools.py b/src/doubao_input/doubao/host_tools.py
index 906703f..529df9a 100644
--- a/src/doubao_input/doubao/host_tools.py
+++ b/src/doubao_input/doubao/host_tools.py
@@ -10,6 +10,7 @@ from __future__ import annotations
import os
import shutil
+import subprocess
_FLATPAK_MARKER = "/.flatpak-info"
@@ -33,4 +34,16 @@ def command_candidates(tool: str) -> list[list[str]]:
def has_tool(tool: str) -> bool:
- return bool(command_candidates(tool))
+ if not is_flatpak():
+ return shutil.which(tool) is not None
+ if not shutil.which("flatpak-spawn"):
+ return False
+ try:
+ result = subprocess.run(
+ ["flatpak-spawn", "--host", "sh", "-c", 'command -v "$1" >/dev/null',
+ "doubao-say-probe", tool],
+ stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=2,
+ )
+ return result.returncode == 0
+ except (OSError, subprocess.TimeoutExpired):
+ return False
diff --git a/src/doubao_input/preflight.py b/src/doubao_input/preflight.py
index 0b9b997..4a2da3a 100644
--- a/src/doubao_input/preflight.py
+++ b/src/doubao_input/preflight.py
@@ -2,7 +2,7 @@
import importlib
import os
from pathlib import Path
-import shutil
+from doubao_input.doubao.host_tools import has_tool
from doubao_input.desktop import is_x11
@@ -38,7 +38,7 @@ def check_system():
results[namespace] = False
clipboard_tools = () if is_x11() else ("wl-copy",)
for command in ("pw-record", "pw-dump", *clipboard_tools):
- results[command] = shutil.which(command) is not None
+ results[command] = has_tool(command)
return results
@@ -46,7 +46,7 @@ def check_optional_tools():
"""Report helpers that unlock optional desktop capabilities."""
if not is_x11():
return {}
- return {command: shutil.which(command) is not None
+ return {command: has_tool(command)
for command in ("xdotool", "xclip")}
diff --git a/src/doubao_input/settings.py b/src/doubao_input/settings.py
index d4c2570..7ae3ee3 100644
--- a/src/doubao_input/settings.py
+++ b/src/doubao_input/settings.py
@@ -411,6 +411,14 @@ def install_desktop(*, portal=False):
data = Path(os.environ.get("XDG_DATA_HOME", Path.home() / ".local/share"))
# GNOME GlobalShortcuts requires a valid reverse-DNS application ID.
name = "md.lifeos.DoubaoSay.desktop" if portal else "doubao-say.desktop"
+ if portal:
+ # RPM/Flatpak already export a visible reverse-DNS launcher. A private
+ # NoDisplay entry would shadow it in GNOME's application grid.
+ for directory in os.environ.get("XDG_DATA_DIRS", "/usr/local/share:/usr/share").split(":"):
+ if directory:
+ packaged = Path(directory) / "applications" / name
+ if packaged.is_file():
+ return packaged
path = data / "applications" / name
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(desktop_entry() + ("NoDisplay=true\n" if portal else ""))
diff --git a/tests/contracts/test_marketplace.py b/tests/contracts/test_marketplace.py
index a009097..22dda1c 100644
--- a/tests/contracts/test_marketplace.py
+++ b/tests/contracts/test_marketplace.py
@@ -90,7 +90,7 @@ class MarketplaceTest(unittest.TestCase):
def test_missing_modules_report_failure(self):
with patch.dict("os.environ", {"WAYLAND_DISPLAY": "test"}), \
- patch("doubao_input.preflight.shutil.which", return_value=None), \
+ patch("doubao_input.preflight.has_tool", return_value=None), \
patch("doubao_input.preflight.importlib.import_module", side_effect=ImportError):
results = check_runtime()
self.assertFalse(any(results.values()))
diff --git a/tests/contracts/test_pages_report_history.mjs b/tests/contracts/test_pages_report_history.mjs
index 99a3fcb..238e4a1 100644
--- a/tests/contracts/test_pages_report_history.mjs
+++ b/tests/contracts/test_pages_report_history.mjs
@@ -143,6 +143,8 @@ test('assigns every product case to exactly one balanced shard', async () => {
});
test('keeps visual E2E interactions at task level with proven tap exceptions', async () => {
+ // Run 38241167120 located clipped recommendation text instead of the endpoint
+ // button. Reveal the button before the existing tap/result assertions.
for (const file of [
'onboarding.yaml',
'onboarding-regressions.yaml',
@@ -165,6 +167,7 @@ test('keeps visual E2E interactions at task level with proven tap exceptions', a
'- aiTap: Check microphone · 3 seconds button on the Microphone step',
'- aiTap: Right-arrow Next button in the fixed top navigation',
'- aiScroll:',
+ '- aiScroll:',
'- aiTap: Test endpoint button in the Voice polishing section',
'- aiScroll:',
'- aiTap: Right-arrow Next button in the fixed top navigation',
@@ -192,10 +195,12 @@ test('keeps visual E2E interactions at task level with proven tap exceptions', a
'- aiScroll:',
'- aiScroll:',
'- computer.inputText: { target: The editable text field to the right of Model containing synthetic-model, value: ci-fail-model }',
+ '- aiScroll:',
'- aiTap: Test endpoint button in the Voice polishing section',
'- aiScroll:',
'- aiScroll:',
'- computer.inputText: { target: The editable text field to the right of Model containing ci-fail-model, value: ci-ok-model }',
+ '- aiScroll:',
'- aiTap: Test failed — try again button in the Voice polishing section',
'- aiScroll:',
'- aiTap: Right-arrow Next button in the fixed top navigation',
diff --git a/tests/e2e/cases/onboarding-regressions.yaml b/tests/e2e/cases/onboarding-regressions.yaml
index 864fad3..4f70e4a 100644
--- a/tests/e2e/cases/onboarding-regressions.yaml
+++ b/tests/e2e/cases/onboarding-regressions.yaml
@@ -94,6 +94,11 @@ cases:
- aiScroll:
options: { direction: down, scrollType: singleAction, distance: 500 }
- computer.inputText: { target: The editable text field to the right of Model containing synthetic-model, value: ci-fail-model }
+ - aiScroll:
+ options: { direction: down, scrollType: singleAction, distance: 300 }
+ - aiWaitFor:
+ prompt: The entire Test endpoint button in Voice polishing is visible inside the scrolling panel, above the fixed Vocabulary & history button. The small model recommendation text is not the target.
+ options: { timeoutMs: 30000, checkIntervalMs: 1000 }
- aiTap: Test endpoint button in the Voice polishing section
- aiScroll:
options: { direction: down, scrollType: singleAction, distance: 300 }
@@ -103,6 +108,11 @@ cases:
- aiScroll:
options: { direction: up, scrollType: singleAction, distance: 300 }
- computer.inputText: { target: The editable text field to the right of Model containing ci-fail-model, value: ci-ok-model }
+ - aiScroll:
+ options: { direction: down, scrollType: singleAction, distance: 300 }
+ - aiWaitFor:
+ prompt: The entire Test failed — try again button is visible in Voice polishing, above the fixed Vocabulary & history button.
+ options: { timeoutMs: 30000, checkIntervalMs: 1000 }
- aiTap: Test failed — try again button in the Voice polishing section
- aiScroll:
options: { direction: down, scrollType: singleAction, distance: 300 }
diff --git a/tests/e2e/cases/onboarding.yaml b/tests/e2e/cases/onboarding.yaml
index a8388fa..222df24 100644
--- a/tests/e2e/cases/onboarding.yaml
+++ b/tests/e2e/cases/onboarding.yaml
@@ -26,6 +26,11 @@ cases:
- aiWaitFor:
prompt: The Trigger key page visibly recommends a small, fast Voice polishing model with thinking off, names DeepSeek Flash and Gemini 2.5 Flash-Lite, and warns that large reasoning models may exceed five seconds and fall back to the original text.
options: { timeoutMs: 30000, checkIntervalMs: 1000 }
+ - aiScroll:
+ options: { direction: down, scrollType: singleAction, distance: 300 }
+ - aiWaitFor:
+ prompt: The entire Test endpoint button in Voice polishing is visible inside the scrolling panel, above the fixed Vocabulary & history button. The small model recommendation text is not the target.
+ options: { timeoutMs: 30000, checkIntervalMs: 1000 }
- aiTap: Test endpoint button in the Voice polishing section
- aiScroll:
options: { direction: down, scrollType: singleAction, distance: 300 }
diff --git a/tests/unit/test_audio_capture.py b/tests/unit/test_audio_capture.py
index 0fb74b3..640e050 100644
--- a/tests/unit/test_audio_capture.py
+++ b/tests/unit/test_audio_capture.py
@@ -14,7 +14,7 @@ class AudioCallbacksTest(unittest.TestCase):
capture, callback = AudioCapture(), Mock()
capture.device = "alsa_input.test-source"
with patch.dict(os.environ, {"DISPLAY": ":99", "XDG_SESSION_TYPE": "x11"}, clear=True), \
- patch("doubao_input.doubao.audio_capture.shutil.which", return_value="pw-record" if available else None), \
+ patch("doubao_input.doubao.audio_capture.has_tool", return_value="pw-record" if available else None), \
patch("doubao_input.doubao.audio_capture.subprocess.Popen") as spawn, \
patch("doubao_input.doubao.audio_capture.threading.Thread"), \
patch("doubao_input.doubao.audio_capture._load_sounddevice") as sounddevice:
@@ -134,7 +134,7 @@ class AudioCallbacksTest(unittest.TestCase):
samples = (b"\x00\x40\x00\xc0" * 2)
capture._audio_callback(samples, 4, None, None)
with patch.dict("os.environ", {"WAYLAND_DISPLAY": "test"}), \
- patch("doubao_input.doubao.audio_capture.shutil.which", return_value="pw-record"), \
+ patch("doubao_input.doubao.audio_capture.has_tool", return_value="pw-record"), \
patch.object(capture, "_start_pipewire", side_effect=emit_first_block):
capture.start(audio, on_rms=override)
override.assert_called_once_with(0.5)
@@ -146,7 +146,7 @@ class AudioCallbacksTest(unittest.TestCase):
def test_pipewire_is_preferred_on_x11(self):
capture = AudioCapture()
with patch.dict("os.environ", {"DISPLAY": ":0"}, clear=True), \
- patch("doubao_input.doubao.audio_capture.shutil.which",
+ patch("doubao_input.doubao.audio_capture.has_tool",
return_value="/usr/bin/pw-record"), \
patch.object(capture, "_start_pipewire") as start_pipewire, \
patch("doubao_input.doubao.audio_capture._load_sounddevice") as sounddevice:
diff --git a/tests/unit/test_desktop.py b/tests/unit/test_desktop.py
index 36dac64..4bbd424 100644
--- a/tests/unit/test_desktop.py
+++ b/tests/unit/test_desktop.py
@@ -46,7 +46,7 @@ class DesktopTest(TestCase):
"pw-record", "pw-dump", *(('xdotool', 'xclip') if x11 else ('wl-copy',))) else None
with patch("gi.require_version", side_effect=require), \
patch.object(preflight.importlib, "import_module"), \
- patch.object(preflight.shutil, "which", side_effect=available):
+ patch.object(preflight, "has_tool", side_effect=available):
results = preflight.check_system()
self.assertTrue(all(results.values()), results)
self.assertIn("GdkX11" if x11 else "Gtk4LayerShell", results)
@@ -63,7 +63,7 @@ class DesktopTest(TestCase):
with patch.dict(os.environ, SESSIONS[0][0], clear=True), \
patch("gi.require_version"), \
patch.object(preflight.importlib, "import_module"), \
- patch.object(preflight.shutil, "which", side_effect=lambda tool: None if tool == "xdotool" else tool):
+ patch.object(preflight, "has_tool", side_effect=lambda tool: None if tool == "xdotool" else tool):
self.assertNotIn("xdotool", preflight.check_system())
self.assertFalse(preflight.check_optional_tools()["xdotool"])
with patch.object(preflight, "check_runtime", return_value={"required": True}), \
diff --git a/tests/unit/test_runtime_edges.py b/tests/unit/test_runtime_edges.py
index 47ddf52..fc7d4af 100644
--- a/tests/unit/test_runtime_edges.py
+++ b/tests/unit/test_runtime_edges.py
@@ -94,7 +94,8 @@ class HostIntegrationTest(TestCase):
def test_flatpak_command_candidates(self):
with patch("os.path.exists", return_value=True), \
- patch("shutil.which", side_effect=lambda tool: f"/bin/{tool}"):
+ patch("shutil.which", side_effect=lambda tool: f"/bin/{tool}"), \
+ patch("subprocess.run", return_value=subprocess.CompletedProcess([], 0)):
self.assertEqual(host_tools.command_candidates("wl-copy"), [
["wl-copy"], ["flatpak-spawn", "--host", "wl-copy"]])
self.assertTrue(host_tools.has_tool("wl-copy"))
@@ -102,6 +103,17 @@ class HostIntegrationTest(TestCase):
self.assertFalse(host_tools.is_flatpak())
self.assertEqual(host_tools.command_candidates("missing"), [])
+ def test_flatpak_wrappers_do_not_hide_missing_host_tools(self):
+ with patch.object(host_tools, "is_flatpak", return_value=True), \
+ patch("shutil.which", return_value="/app/bin/pw-record"), \
+ patch("subprocess.run", return_value=subprocess.CompletedProcess([], 1)) as probe:
+ self.assertFalse(host_tools.has_tool("pw-record"))
+ self.assertEqual(probe.call_args.args[0][-1], "pw-record")
+ with patch.object(host_tools, "is_flatpak", return_value=True), \
+ patch("shutil.which", return_value="/usr/bin/flatpak-spawn"), \
+ patch("subprocess.run", side_effect=subprocess.TimeoutExpired("probe", 2)):
+ self.assertFalse(host_tools.has_tool("pw-record"))
+
def test_focused_target_accepts_only_valid_external_address(self):
with patch.dict("os.environ", {"HYPRLAND_INSTANCE_SIGNATURE": "test"}), \
patch("subprocess.check_output", return_value=b'{"class":"zed","address":"0xabc"}'):
diff --git a/tests/unit/test_settings.py b/tests/unit/test_settings.py
index 67140f2..61f361d 100644
--- a/tests/unit/test_settings.py
+++ b/tests/unit/test_settings.py
@@ -14,6 +14,19 @@ from doubao_input.settings import (DEFAULT_POLISH_PROMPT_EN, DEFAULT_POLISH_PROM
class SettingsTest(unittest.TestCase):
+ def test_portal_keeps_packaged_launcher_visible(self):
+ with tempfile.TemporaryDirectory() as root:
+ package = Path(root) / "system/applications/md.lifeos.DoubaoSay.desktop"
+ package.parent.mkdir(parents=True)
+ content = "[Desktop Entry]\nName=Doubao Say\nExec=doubao-say\n"
+ package.write_text(content)
+ private = Path(root) / "user"
+ with patch.dict("os.environ", {"XDG_DATA_HOME": str(private),
+ "XDG_DATA_DIRS": str(package.parent.parent)}):
+ self.assertEqual(install_desktop(portal=True), package)
+ self.assertEqual(package.read_text(), content)
+ self.assertFalse((private / "applications/md.lifeos.DoubaoSay.desktop").exists())
+
def test_homophone_prompt_migration_preserves_user_edits(self):
with tempfile.TemporaryDirectory() as root, patch.dict("os.environ", {"XDG_CONFIG_HOME": root}):
path = Path(root) / "doubao-say/settings.json"