__init__.py
Python script, ASCII text executable
1import asyncio 2from xdg import DesktopEntry 3from pathlib import Path 4import subprocess 5import logging 6from gi.repository import Gio, GLib 7import gettext 8import izvor_utils as izvor 9 10_ = gettext.gettext 11 12 13logging.basicConfig(level=logging.DEBUG) 14 15 16config_template = { 17"terminal": "gnome-terminal", 18"shell": "bash -c" 19} 20 21 22class Provider(izvor.Provider): 23def __init__(self, config: dict): 24self.config = config 25self.name = _("Terminal") 26self.icon = "utilities-terminal" 27self.description = _("Run search queries as commands in a terminal.") 28 29async def search(self, query: str): 30terminal_app = self.config["terminal"] 31shell = self.config["shell"] 32 33def execute(): 34izvor.launch_command(f"{terminal_app} -- {shell} '{query}'", shell=True) 35 36yield { 37"name": _("Run"), 38"description": query, 39"image": ("logo", "utilities-terminal"), 40"execute": execute 41} 42