Important information: Google announced that, from September 2026, Android devices will require ALL apps to be signed by Google, effectively leading to an iOS situation. Value your right to a computer that does what you want; do not tolerate this monopolistic practice! Contact me if you don't understand why it is bad. Click to learn more.

 __init__.py

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