From 8715ebafe8f2a9e8b19d3018bd2659e6063c5291 Mon Sep 17 00:00:00 2001 From: Aditya Gupta Date: Fri, 6 Mar 2026 13:24:50 +0530 Subject: [PATCH] first commit --- .gitignore | 10 ++++++++++ .python-version | 1 + README.md | 0 backends/spectacle.py | 16 ++++++++++++++++ main.py | 15 +++++++++++++++ pyproject.toml | 7 +++++++ screenshot_backend.py | 26 ++++++++++++++++++++++++++ uv.lock | 8 ++++++++ 8 files changed, 83 insertions(+) create mode 100644 .gitignore create mode 100644 .python-version create mode 100644 README.md create mode 100644 backends/spectacle.py create mode 100644 main.py create mode 100644 pyproject.toml create mode 100644 screenshot_backend.py create mode 100644 uv.lock diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..505a3b1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +# Python-generated files +__pycache__/ +*.py[oc] +build/ +dist/ +wheels/ +*.egg-info + +# Virtual environments +.venv diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..e4fba21 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.12 diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/backends/spectacle.py b/backends/spectacle.py new file mode 100644 index 0000000..1dfb7dc --- /dev/null +++ b/backends/spectacle.py @@ -0,0 +1,16 @@ +import os +import subprocess +from screenshot_backend import register_backend, ScreenshotBackend + + +@register_backend +class SpectacleBackend(ScreenshotBackend): + def supports(self) -> bool: + return "KDE" in os.environ.get("XDG_CURRENT_DESKTOP", "") + + def active_window(self) -> str: + path = "hgot.png" + print("Running") + subprocess.run(["spectacle", "-a", "-b", "-n", "-o", path]) + + return path diff --git a/main.py b/main.py new file mode 100644 index 0000000..b7c5fbf --- /dev/null +++ b/main.py @@ -0,0 +1,15 @@ +import subprocess +from screenshot_backend import get_backend +from backends.spectacle import SpectacleBackend + + +def main(): + print("Hello from wydt!") + + backend = get_backend() + path = backend.active_window() + print(path) + + +if __name__ == "__main__": + main() diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..938ced2 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,7 @@ +[project] +name = "wydt" +version = "0.1.0" +description = "watcha doin' there? Your own digital invigilator making sure you're not distracted" +readme = "README.md" +requires-python = ">=3.12" +dependencies = [] diff --git a/screenshot_backend.py b/screenshot_backend.py new file mode 100644 index 0000000..5613874 --- /dev/null +++ b/screenshot_backend.py @@ -0,0 +1,26 @@ +from abc import ABC, abstractmethod + + +class ScreenshotBackend(ABC): + @abstractmethod + def supports(self) -> bool: + pass + + @abstractmethod + def active_window(self) -> str: + pass + + +_backends = [] + + +def register_backend(cls): + _backends.append(cls()) + return cls + + +def get_backend() -> ScreenshotBackend: + for backend in _backends: + if backend.supports(): + return backend + raise RuntimeError("No screenshot backend available") diff --git a/uv.lock b/uv.lock new file mode 100644 index 0000000..d1e4482 --- /dev/null +++ b/uv.lock @@ -0,0 +1,8 @@ +version = 1 +revision = 3 +requires-python = ">=3.12" + +[[package]] +name = "wydt" +version = "0.1.0" +source = { virtual = "." }