-
-
Notifications
You must be signed in to change notification settings - Fork 6
Integrations Python
coe0718 edited this page May 23, 2026
·
3 revisions
Use Deskbrid from Python applications.
pip install deskbridOr install from source:
git clone https://github.com/coe0718/deskbrid
cd deskbrid/clients/python
pip install -e .from deskbrid import Deskbrid
# Connect to daemon
client = Deskbrid()
# List windows
windows = client.list_windows()
for w in windows:
print(f"{w.app_id}: {w.title}")
# Focus VS Code
client.focus_window(app_id="code")
# Type something
client.type_text("Hello from Python!")from deskbrid import AsyncDeskbrid
import asyncio
async def main():
async with AsyncDeskbrid() as client:
windows = await client.list_windows()
print(f"Found {len(windows)} windows")
asyncio.run(main())Blocking synchronous client:
from deskbrid import SyncDeskbrid
client = SyncDeskbrid()
windows = client.list_windows() # Blocks until responseAsync context manager:
from deskbrid import AsyncDeskbrid
async with AsyncDeskbrid() as client:
windows = await client.list_windows()The main Deskbrid class provides both:
client = Deskbrid()
# Sync methods (blocking)
windows = client.list_windows()
client.type_text("sync text")
# Internal async client for mixing modes
async def some_async_func():
async with client._client() as async_client:
await async_client.type_text("async text")client.list_windows() # List all windows
client.focus_window(app_id="code") # Focus by app ID
client.focus_window(title="Terminal") # Focus by title
client.activate_or_launch("firefox") # Launch or focus
client.tile_window(window_id, preset="left")client.type_text("Hello!")
client.send_keys(["Ctrl_L", "c"])
client.mouse_click(x=100, y=200)
client.mouse_move(x=500, y=300)
client.mouse_scroll(dy=3)content = client.clipboard_read() # Returns ClipboardContent
client.clipboard_write("New text")
history = client.clipboard_history(limit=10)path = client.screenshot() # Returns screenshot path
result = client.screenshot_ocr() # Returns dict with text
diff = client.screenshot_diff("/before.png", "/after.png")info = client.info() # Returns DaemonInfo
battery = client.system_battery()
client.system_power("suspend")players = client.mpris_list()
client.mpris_control("play")
client.mpris_control("next")result = client.terminal_create()
term_id = result["terminal_id"]
client.terminal_write(term_id, "ls -la\n")
output = client.terminal_read(term_id)
client.terminal_kill(term_id)from deskbrid.errors import DeskbridError
try:
client.focus_window(app_id="nonexistent")
except DeskbridError as e:
print(f"Error: {e.code} - {e.message}")from deskbrid import Deskbrid
# Custom socket path
client = Deskbrid(socket_path="/tmp/custom.sock")
# With timeout
client = Deskbrid(timeout=30.0)# Each client has its own connection
client1 = Deskbrid()
client2 = Deskbrid()
# Use different clients for different tasks concurrentlyfrom langchain.tools import tool
from deskbrid import Deskbrid
client = Deskbrid()
@tool
def type_text_tool(text: str) -> str:
"""Type text into the focused window."""
client.type_text(text)
return f"Typed: {text}"from llama_index.core.tools import FunctionTool
from deskbrid import Deskbrid
client = Deskbrid()
def take_screenshot() -> str:
"""Take a screenshot and return the path."""
result = client.screenshot()
return result.path
screenshot_tool = FunctionTool.from_defaults(
fn=take_screenshot,
name="take_screenshot",
description="Take a screenshot of the desktop"
)- Accessibility
- Apps
- Audio
- Backlight (LED driver)
- Bluetooth
- Clipboard
- Color Picker
- Desktop Portal
- Desktop Settings
- Files
- Hotkeys
- Input
- Keyboard Layouts
- Media (MPRIS)
- Monitors
- Network
- Notifications
- Print (CUPS)
- Screenshots
- Screen Recording
- Screencast
- Self-Update
- System
- System Tray
- Systemd Units & Timers
- Terminals (PTY)
- Windows & Workspaces