Launch Linux GUI apps from inside any AI agent terminal session.
Works with Hermes Agent, Claude Code, Codex, and OpenClaw.
AI agent terminal tools block shell backgrounding (&, nohup, disown, setsid). You can't just run kate file.py & — the tool rejects it or hangs.
Use Python's subprocess.Popen with start_new_session=True via the agent's code execution tool:
import subprocess, os
env = os.environ.copy()
env.setdefault("DISPLAY", ":0")
p = subprocess.Popen(
["kate", "/path/to/file"],
env=env,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
start_new_session=True,
)
print(f"Launched PID: {p.pid}")This fully detaches the child process from the agent's session. The GUI app opens, the agent gets its terminal back immediately.
hermes skill install launch-gui
# or clone this repo into ~/.hermes/skills/launch-gui/Copy SKILL.md into your agent's skill/instruction directory, or just bookmark the technique above — it's a one-liner.
| App | Command | Desktop |
|---|---|---|
| Kate | kate file1 file2 |
KDE |
| Dolphin | dolphin /path |
KDE |
| Konsole | konsole --workdir /path |
KDE |
| Firefox | firefox URL |
Any |
| VS Code | code /path |
Any |
| Okular | okular file.pdf |
KDE |
| Gwenview | gwenview /path |
KDE |
| gedit | gedit file |
GNOME |
| Nautilus | nautilus /path |
GNOME |
Works with any app that accepts a command-line launch.
- DISPLAY must be set — defaults to
:0. If the app doesn't appear, checkecho $DISPLAY. - Wayland: also set
WAYLAND_DISPLAYandXDG_RUNTIME_DIR. - SSH: requires X forwarding (
ssh -X) or a local session. - Firefox: if already running, opens a new tab and the subprocess exits immediately — that's normal.
- Hermes: the
terminal()tool blocks all backgrounding. Always useexecute_codewithsubprocess.Popen.
MIT