By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

 __init__.py

View raw Download
text/x-script.python • 989 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
import izvor_utils as izvor
9
10
_ = gettext.gettext
11
12
13
logging.basicConfig(level=logging.DEBUG)
14
15
16
config_template = {
17
"terminal": "gnome-terminal",
18
"shell": "bash -c"
19
}
20
21
22
class Provider(izvor.Provider):
23
def __init__(self, config: dict):
24
self.config = config
25
self.name = _("Terminal")
26
self.icon = "utilities-terminal"
27
self.description = _("Run search queries as commands in a terminal.")
28
29
async def search(self, query: str):
30
terminal_app = self.config["terminal"]
31
shell = self.config["shell"]
32
33
def execute():
34
izvor.launch_command(f"{terminal_app} -- {shell} '{query}'", shell=True)
35
36
yield {
37
"name": _("Run"),
38
"description": query,
39
"image": ("logo", "utilities-terminal"),
40
"execute": execute
41
}
42