Freie Hand (A3): Medien-/Lautstärke-Steuerung für den PC
- executor.py: /media (play_pause/next/prev/stop) + /volume (up/down/mute, steps 1-25) via pyautogui Media-Keys — wirkt wie Multimedia-Tastatur - mcp_pc.py: Tools pc_media + pc_volume für Hermes Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -108,6 +108,42 @@ async def press_keys(req: dict):
|
||||
raise HTTPException(500, str(e))
|
||||
|
||||
|
||||
# ── Medien & Lautstärke (A3: Lucy steuert den PC per Sprache) ──────────────
|
||||
# Media-Keys wirken auf den AKTIVEN Player (Spotify, YouTube, VLC …) — genau wie
|
||||
# die Tasten auf einer Multimedia-Tastatur. Lautstärke = System-Master (2 % je Schritt).
|
||||
MEDIA_KEYS = {"play_pause": "playpause", "next": "nexttrack", "prev": "prevtrack", "stop": "stop"}
|
||||
VOLUME_KEYS = {"up": "volumeup", "down": "volumedown", "mute": "volumemute"}
|
||||
|
||||
|
||||
@app.post("/media", dependencies=[Depends(require_auth)])
|
||||
async def media_control(req: dict):
|
||||
action = (req.get("action") or "").strip().lower()
|
||||
key = MEDIA_KEYS.get(action)
|
||||
if not key:
|
||||
raise HTTPException(400, f"Unbekannte Aktion '{action}'. Erlaubt: {', '.join(MEDIA_KEYS)}")
|
||||
try:
|
||||
import pyautogui
|
||||
pyautogui.press(key)
|
||||
return {"ok": True, "action": action}
|
||||
except Exception as e:
|
||||
raise HTTPException(500, str(e))
|
||||
|
||||
|
||||
@app.post("/volume", dependencies=[Depends(require_auth)])
|
||||
async def volume_control(req: dict):
|
||||
action = (req.get("action") or "").strip().lower()
|
||||
key = VOLUME_KEYS.get(action)
|
||||
if not key:
|
||||
raise HTTPException(400, f"Unbekannte Aktion '{action}'. Erlaubt: {', '.join(VOLUME_KEYS)}")
|
||||
steps = 1 if action == "mute" else max(1, min(25, int(req.get("steps", 5))))
|
||||
try:
|
||||
import pyautogui
|
||||
pyautogui.press(key, presses=steps, interval=0.02)
|
||||
return {"ok": True, "action": action, "steps": steps}
|
||||
except Exception as e:
|
||||
raise HTTPException(500, str(e))
|
||||
|
||||
|
||||
# ── Apps / Browser ─────────────────────────────────────────────────────────
|
||||
|
||||
@app.post("/open", dependencies=[Depends(require_auth)])
|
||||
|
||||
Reference in New Issue
Block a user