diff options
Diffstat (limited to 'src/subcommands')
| -rw-r--r-- | src/subcommands/clipboard.py | 10 | ||||
| -rw-r--r-- | src/subcommands/emoji.py | 10 | ||||
| -rw-r--r-- | src/subcommands/pip.py | 10 | ||||
| -rw-r--r-- | src/subcommands/record.py | 10 | ||||
| -rw-r--r-- | src/subcommands/scheme.py | 10 | ||||
| -rw-r--r-- | src/subcommands/screenshot.py | 10 | ||||
| -rw-r--r-- | src/subcommands/shell.py | 40 | ||||
| -rw-r--r-- | src/subcommands/toggle.py | 10 | ||||
| -rw-r--r-- | src/subcommands/variant.py | 10 | ||||
| -rw-r--r-- | src/subcommands/wallpaper.py | 10 | ||||
| -rw-r--r-- | src/subcommands/wsaction.py | 10 |
11 files changed, 118 insertions, 22 deletions
diff --git a/src/subcommands/clipboard.py b/src/subcommands/clipboard.py index a94f3d0..37f9a2b 100644 --- a/src/subcommands/clipboard.py +++ b/src/subcommands/clipboard.py @@ -1,5 +1,11 @@ from argparse import Namespace -def run(args: Namespace) -> None: - pass +class Command: + args: Namespace + + def __init__(self, args: Namespace) -> None: + self.args = args + + def run(self) -> None: + pass diff --git a/src/subcommands/emoji.py b/src/subcommands/emoji.py index a94f3d0..37f9a2b 100644 --- a/src/subcommands/emoji.py +++ b/src/subcommands/emoji.py @@ -1,5 +1,11 @@ from argparse import Namespace -def run(args: Namespace) -> None: - pass +class Command: + args: Namespace + + def __init__(self, args: Namespace) -> None: + self.args = args + + def run(self) -> None: + pass diff --git a/src/subcommands/pip.py b/src/subcommands/pip.py index a94f3d0..37f9a2b 100644 --- a/src/subcommands/pip.py +++ b/src/subcommands/pip.py @@ -1,5 +1,11 @@ from argparse import Namespace -def run(args: Namespace) -> None: - pass +class Command: + args: Namespace + + def __init__(self, args: Namespace) -> None: + self.args = args + + def run(self) -> None: + pass diff --git a/src/subcommands/record.py b/src/subcommands/record.py index a94f3d0..37f9a2b 100644 --- a/src/subcommands/record.py +++ b/src/subcommands/record.py @@ -1,5 +1,11 @@ from argparse import Namespace -def run(args: Namespace) -> None: - pass +class Command: + args: Namespace + + def __init__(self, args: Namespace) -> None: + self.args = args + + def run(self) -> None: + pass diff --git a/src/subcommands/scheme.py b/src/subcommands/scheme.py index a94f3d0..37f9a2b 100644 --- a/src/subcommands/scheme.py +++ b/src/subcommands/scheme.py @@ -1,5 +1,11 @@ from argparse import Namespace -def run(args: Namespace) -> None: - pass +class Command: + args: Namespace + + def __init__(self, args: Namespace) -> None: + self.args = args + + def run(self) -> None: + pass diff --git a/src/subcommands/screenshot.py b/src/subcommands/screenshot.py index a94f3d0..37f9a2b 100644 --- a/src/subcommands/screenshot.py +++ b/src/subcommands/screenshot.py @@ -1,5 +1,11 @@ from argparse import Namespace -def run(args: Namespace) -> None: - pass +class Command: + args: Namespace + + def __init__(self, args: Namespace) -> None: + self.args = args + + def run(self) -> None: + pass diff --git a/src/subcommands/shell.py b/src/subcommands/shell.py index a94f3d0..6802dc8 100644 --- a/src/subcommands/shell.py +++ b/src/subcommands/shell.py @@ -1,5 +1,41 @@ +import subprocess from argparse import Namespace +import data -def run(args: Namespace) -> None: - pass + +class Command: + args: Namespace + + def __init__(self, args: Namespace) -> None: + self.args = args + + def run(self) -> None: + if self.args.show: + # Print the ipc + self.print_ipc() + elif self.args.log: + # Print the log + self.print_log() + elif self.args.message: + # Send a message + self.message(*self.args.message) + else: + # Start the shell + self.shell() + + def shell(self, *args: list[str]) -> str: + return subprocess.check_output(["qs", "-p", data.c_data_dir / "shell", *args], text=True) + + def print_ipc(self) -> None: + print(self.shell("ipc", "show"), end="") + + def print_log(self) -> None: + log = self.shell("log") + # FIXME: remove when logging rules are added/warning is removed + for line in log.splitlines(): + if "QProcess: Destroyed while process" not in line: + print(line) + + def message(self, *args: list[str]) -> None: + print(self.shell("ipc", "call", *args), end="") diff --git a/src/subcommands/toggle.py b/src/subcommands/toggle.py index a94f3d0..37f9a2b 100644 --- a/src/subcommands/toggle.py +++ b/src/subcommands/toggle.py @@ -1,5 +1,11 @@ from argparse import Namespace -def run(args: Namespace) -> None: - pass +class Command: + args: Namespace + + def __init__(self, args: Namespace) -> None: + self.args = args + + def run(self) -> None: + pass diff --git a/src/subcommands/variant.py b/src/subcommands/variant.py index a94f3d0..37f9a2b 100644 --- a/src/subcommands/variant.py +++ b/src/subcommands/variant.py @@ -1,5 +1,11 @@ from argparse import Namespace -def run(args: Namespace) -> None: - pass +class Command: + args: Namespace + + def __init__(self, args: Namespace) -> None: + self.args = args + + def run(self) -> None: + pass diff --git a/src/subcommands/wallpaper.py b/src/subcommands/wallpaper.py index a94f3d0..37f9a2b 100644 --- a/src/subcommands/wallpaper.py +++ b/src/subcommands/wallpaper.py @@ -1,5 +1,11 @@ from argparse import Namespace -def run(args: Namespace) -> None: - pass +class Command: + args: Namespace + + def __init__(self, args: Namespace) -> None: + self.args = args + + def run(self) -> None: + pass diff --git a/src/subcommands/wsaction.py b/src/subcommands/wsaction.py index a94f3d0..37f9a2b 100644 --- a/src/subcommands/wsaction.py +++ b/src/subcommands/wsaction.py @@ -1,5 +1,11 @@ from argparse import Namespace -def run(args: Namespace) -> None: - pass +class Command: + args: Namespace + + def __init__(self, args: Namespace) -> None: + self.args = args + + def run(self) -> None: + pass |