Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ def _in_flatpak() -> bool:


_TERMINALS = [
# Ptyxis is the default terminal on Fedora 41+ / modern GNOME. Same
# `-- bash -c <cmd>` convention as gnome-terminal. Listed first so it
# wins on GNOME boxes where it's the only terminal installed.
("ptyxis", ["ptyxis", "--", "bash", "-c"]),
("gnome-terminal", ["gnome-terminal", "--", "bash", "-c"]),
("konsole", ["konsole", "-e", "bash", "-c"]),
("xfce4-terminal", ["xfce4-terminal", "-e"]),
Expand Down
38 changes: 38 additions & 0 deletions plugins_repo/run_in_terminal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""Run a selected shell command in a terminal.

The classifier tags shell-command-looking selections as
``ContentType.COMMAND`` (e.g. ``wpctl set-volume @DEFAULT_AUDIO_SINK@ 50%``),
but nothing acted on them - this plugin adds the missing "Run in terminal"
button for exactly that content type.

The heavy lifting lives in ``actions.run_in_terminal``: it finds an available
terminal emulator, optionally shows a confirmation dialog
(``terminal_confirm_run``, default on), echoes the command, runs it, and keeps
the terminal open afterwards (``terminal_keep_open``, default on). Launch is
done with a real argv list (never ``shell=True`` at construction), and the
confirmation dialog is the guard against running a malicious-looking selection
by accident.
"""
from __future__ import annotations

import actions
from classifier import ContentType
from plugin_base import Plugin


def _run(text: str) -> None:
actions.run_in_terminal(text)


def register(register_plugin) -> None:
register_plugin(Plugin(
name="run-in-terminal",
icon="utilities-terminal-symbolic",
tooltip="Run in terminal",
handler=_run,
content_types=(ContentType.COMMAND,),
# Lower than the transform/utility plugins so it sits toward the
# end of the bar - it's a deliberate, occasional action, not a
# first-reach one.
priority=30,
))