Hello, desktop
The shortest working example
Section titled “The shortest working example”from uda import Uda
with Uda() as uda: print("主题:", uda.theme) uda.notify("你好,桌面", "这是通过 UDA 发出的第一条系统通知。")Leaving the with block releases every resource this object holds — wake locks, tray icons, menus — automatically.
From Node.js:
const { Uda } = require('./uda');
const uda = new Uda();console.log(uda.theme);uda.notify('你好,桌面', '这是通过 UDA 发出的第一条系统通知。');uda.dispose();Line by line
Section titled “Line by line”| Fragment | What it does |
|---|---|
Uda() |
Loads the shared library and declares the prototypes for every export. Library resolution: explicit argument → UDA_LIBRARY → the target directory reported by cargo metadata |
uda.theme |
Attribute-style read, returning "dark" / "light" / "unknown" |
uda.notify(...) |
Method-style call, returning the id the notification server assigned |
with / release_all() |
The resource-release convention, described below |
The release convention
Section titled “The release convention”Three kinds of object hold system resources in the Python SDK:
with Uda() as uda: with uda.wakelock(reason="视频播放") as lock: # released on exit ...
icon = uda.create_tray_icon("我的应用") # destroyed manually try: icon.wait() finally: icon.destroy() # unregistered from the trayUda,WakeLockare context managers — leaving the block releases them.TrayIconandTrayMenuare destroyed explicitly; dropping theUdathat created them releases them too.- Every release path is idempotent, so calling it twice is safe.
In Rust, TrayIcon implements Drop and the wake lock is an RAII guard, so release is automatic in the same way.
What to explore next
Section titled “What to explore next”| Guide | Shows |
|---|---|
| Appearance | reading the colour scheme and the accent colour, with live-follow |
| Wallpaper | fill modes, dark/light pairing, multi-monitor |
| Notifications | icons, urgency, action buttons, and the Windows identity rules |
| System tray | a full icon and context menu, with the threading model |
| Media | what is playing, and how to drive it |
| Wake locks | keeping the display or the system awake |
| Session & power | the six actions, their capability bits, and confirming before acting |
Or go straight to the C-ABI reference to bind from another language.
Something went wrong?
Section titled “Something went wrong?”Troubleshooting covers every symptom in order — starting with “why does everything report unsupported”, which almost always means the session has no graphical session bus.
