diff options
-rw-r--r-- | __main__.py | 2 | ||||
-rw-r--r-- | config.yaml | 4 | ||||
-rw-r--r-- | modules/config.py | 2 | ||||
-rw-r--r-- | modules/intents/process.py | 6 | ||||
-rw-r--r-- | modules/intents/sway.py | 6 | ||||
-rw-r--r-- | sentences/_common.yaml | 3 | ||||
-rw-r--r-- | sentences/sway_HesLock.yaml | 8 |
7 files changed, 25 insertions, 6 deletions
diff --git a/__main__.py b/__main__.py index 8818205..008ceb4 100644 --- a/__main__.py +++ b/__main__.py @@ -51,7 +51,7 @@ def main(): } print(result_dict) handler = getattr(globals()[result_dict["domain"]], result_dict["intent"]) - handler(result_dict) + handler(result_dict, config) else: print("<no match>") except KeyboardInterrupt: diff --git a/config.yaml b/config.yaml index bf1b7be..858eb31 100644 --- a/config.yaml +++ b/config.yaml @@ -1,2 +1,4 @@ intents_dir: sentences -applications_dir: /usr/bin
\ No newline at end of file +applications_dir: /usr/bin + +lock: swaylock
\ No newline at end of file diff --git a/modules/config.py b/modules/config.py index 602ec8d..609e4d1 100644 --- a/modules/config.py +++ b/modules/config.py @@ -8,6 +8,8 @@ class Config: self.intents_dir = "" self.applications_dir = "" + self.lock = "" + def update(self, **entries): self.__dict__.update(entries) diff --git a/modules/intents/process.py b/modules/intents/process.py index bc834b6..0bed441 100644 --- a/modules/intents/process.py +++ b/modules/intents/process.py @@ -1,9 +1,11 @@ import os from typing import Dict from .sway import HesNavigate +from ..config import Config -def HesExecuteProcess(data: Dict): + +def HesExecuteProcess(data: Dict, config: Config): if "workspace" in data: - HesNavigate(data) + HesNavigate(data, config) os.popen(data["process"].strip()) diff --git a/modules/intents/sway.py b/modules/intents/sway.py index 5ab1b25..1773363 100644 --- a/modules/intents/sway.py +++ b/modules/intents/sway.py @@ -1,5 +1,9 @@ import os from typing import Dict +from ..config import Config -def HesNavigate(data: Dict): +def HesNavigate(data: Dict, config: Config): os.popen(f"swaymsg workspace {data["workspace"]}") + +def HesLock(data: Dict, config: Config): + os.popen(config.lock)
\ No newline at end of file diff --git a/sentences/_common.yaml b/sentences/_common.yaml index 7c22012..1d5422d 100644 --- a/sentences/_common.yaml +++ b/sentences/_common.yaml @@ -50,8 +50,9 @@ lists: out: 10 expansion_rules: + the_my: "[(the|my) ]" workspace: "(workspace {workspace}|{workspace_word:workspace} workspace)" - in_workspace: "(in|on|at) [the ]<workspace>" + in_workspace: "(in|on|at) <the_my><workspace>" skip_words: - "please" diff --git a/sentences/sway_HesLock.yaml b/sentences/sway_HesLock.yaml new file mode 100644 index 0000000..a246f83 --- /dev/null +++ b/sentences/sway_HesLock.yaml @@ -0,0 +1,8 @@ +language: "en" +intents: + HesLock: + data: + - sentences: + - "lock[ <the_my>(screen|computer)]" + slots: + domain: "sway"
\ No newline at end of file |