first commit

This commit is contained in:
2026-03-06 13:24:50 +05:30
commit 8715ebafe8
8 changed files with 83 additions and 0 deletions

10
.gitignore vendored Normal file
View File

@@ -0,0 +1,10 @@
# Python-generated files
__pycache__/
*.py[oc]
build/
dist/
wheels/
*.egg-info
# Virtual environments
.venv

1
.python-version Normal file
View File

@@ -0,0 +1 @@
3.12

0
README.md Normal file
View File

16
backends/spectacle.py Normal file
View File

@@ -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

15
main.py Normal file
View File

@@ -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()

7
pyproject.toml Normal file
View File

@@ -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 = []

26
screenshot_backend.py Normal file
View File

@@ -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")

8
uv.lock generated Normal file
View File

@@ -0,0 +1,8 @@
version = 1
revision = 3
requires-python = ">=3.12"
[[package]]
name = "wydt"
version = "0.1.0"
source = { virtual = "." }