diff options
author | Botond Hende <nettingman@gmail.com> | 2024-11-27 23:59:07 +0100 |
---|---|---|
committer | Botond Hende <nettingman@gmail.com> | 2024-11-27 23:59:07 +0100 |
commit | cb40a2ff74a8165cb59357c423f83219a01631bc (patch) | |
tree | b672312dd0ab0e4a6de9d96224e78e6523133b13 | |
parent | 61549211126ff8abc347e9a100b120773dfc2d62 (diff) |
-rw-r--r-- | __main__.py | 9 | ||||
-rw-r--r-- | modules/responses/libnotify.py | 4 | ||||
-rw-r--r-- | modules/responses/responses.py | 16 | ||||
-rw-r--r-- | responses/process_HesExecuteProcess.yaml | 5 |
4 files changed, 17 insertions, 17 deletions
diff --git a/__main__.py b/__main__.py index ab4f59c..0e8a1ec 100644 --- a/__main__.py +++ b/__main__.py @@ -13,12 +13,15 @@ from modules.responses.responses import Responses from .modules.input_handlers.stdin_input import StdinInput from .modules.input_handlers.pipewire_record import PipeWireRecord +from .modules.responses.libnotify import respond + from .modules.intents import * def main(): config = load_config() input_dict = {"intents": {}} + response_dict = {"responses": {}} intent_yaml_path = Path(config.intents_dir) intent_yaml_file_paths = intent_yaml_path.glob("*.yaml") @@ -32,9 +35,9 @@ def main(): response_yaml_file_paths = response_yaml_path.glob("*.yaml") for yaml_file_path in response_yaml_file_paths: with open(yaml_file_path, "r", encoding="utf-8") as yaml_file: - merge_dict(input_dict, yaml.safe_load(yaml_file)) + merge_dict(response_dict, yaml.safe_load(yaml_file)) - responses = Responses.from_dict(input_dict) + responses = Responses.from_dict(response_dict) processes = [] for file in os.listdir(config.applications_dir): @@ -63,6 +66,8 @@ def main(): print(result_dict) handler = getattr(globals()[result_dict["domain"]], result_dict["intent"]) handler(result_dict, config) + if result.response != "default": + respond(responses.responses[result.intent.name].sentence_texts[0]) else: print("<no match>") finally: diff --git a/modules/responses/libnotify.py b/modules/responses/libnotify.py new file mode 100644 index 0000000..2e83101 --- /dev/null +++ b/modules/responses/libnotify.py @@ -0,0 +1,4 @@ +import os + +def respond(text: str) -> None: + os.popen(f'notify-send Hestia "{text}" --app-name=hestia')
\ No newline at end of file diff --git a/modules/responses/responses.py b/modules/responses/responses.py index 1836deb..f89a1fe 100644 --- a/modules/responses/responses.py +++ b/modules/responses/responses.py @@ -2,13 +2,9 @@ from dataclasses import dataclass, field from typing import List, Dict, Any @dataclass(frozen=True) -class ResponseData: - sentence_texts: List[str] - -@dataclass(frozen=True) class Response: name: str - data: List[ResponseData] = field(default_factory=list) + sentence_texts: List[str] @dataclass(frozen=True) class Responses: @@ -25,13 +21,9 @@ class Responses: responses={ response_name: Response( name=response_name, - data=[ - ResponseData( - sentence_texts=data_dict["sentences"], - ) - for data_dict in response_dict["data"] - ], + sentence_texts=response_dict["sentences"] ) for response_name, response_dict in input_dict["responses"].items() }, - )
\ No newline at end of file + ) + diff --git a/responses/process_HesExecuteProcess.yaml b/responses/process_HesExecuteProcess.yaml index 66653c2..31646ff 100644 --- a/responses/process_HesExecuteProcess.yaml +++ b/responses/process_HesExecuteProcess.yaml @@ -1,5 +1,4 @@ responses: HesExecuteProcess: - data: - - sentences: - "Right away."
\ No newline at end of file + sentences: + - "Starting it now."
\ No newline at end of file |