How fabric-development/fabric works
Project type and purpose
• Fabric is a Python-based Desktop Widgets System. It’s a library + CLI tool that lets users write desktop widgets in Python, supports X11/Wayland, and exposes services (audio, bluetooth, notifications, system tray, Hyprland integration) through a signal-driven core.
• The README calls it “Ricing, Made Easy,” a high-level widget framework—so it’s neither a full-stack web app nor a microservice; it’s a desktop UI toolkit with a runtime orchestrator.
File structure
• Top-level packaging:
• setup.py, pyproject.toml, requirements.txt for PyPI packaging
• default.nix, flake.nix, scripts/ for reproducible Nix builds
• Core library under src / fabric:
• fabric/__main__.py – CLI entrypoint
• fabric/core/ – orchestrator: Application, Fabricator, Service base
• fabric/utils/ – helper functions
• Services layer under fabric/*/service.py:
• audio, bluetooth, notifications, system_tray, hyprland
• DBus definitions under fabric/dbus_assets – XML interfaces
• Examples directory holds sample configs showcasing user-facing code
• tests/ for unit-style tests of individual services
README for additional insights
• Emphasis on signal-based workflow (no polling)
• Support for both display servers (X11/Wayland)
• High typing/DevEX, low resource usage
Main components & interactions
a. Components
• CLI / Entrypoint (fabric/__main__.py)
• Core Orchestrator
– Application (initialization)
– Fabricator (service/widget registry)
• Services
– AudioService, BluetoothService, NotificationService, SystemTrayService, HyprlandService
• DBus Layer
– XML assets → GDBus interfaces → Service implementations
• Widget Library
– GTK widgets (fabric.widgets.*)
• External Systems
– X11/Wayland compositor
– System D-Bus daemon
– OS subsystems: PulseAudio/ALSA, BlueZ, Desktop Notifications
• User Config / Examples
b. Relationships & data flows
– Entrypoint launches Application → instantiates Fabricator
– Fabricator loads services (reads XML introspection, instantiates each Service)
– Services register on the D-Bus and listen to OS events (audio level, Bluetooth status, notifications)
– Widget instances subscribe to service signals via core APIs
– Widgets translate signals into GTK UI updates
– User config code instantiates specific widgets via Python import
– Under the hood GTK event loop drives updates; events propagate back to Application
c. Architectural patterns & design principles
– Inversion of Control via Fabricator registry
– Signal/slot (observer) pattern for service → widget updates
– Modular service plugin pattern (each service lives in its own subpackage)
– Separation of concerns: services vs. UI vs. core orchestration
– Declarative user code (examples) separate from library code
d. Key technologies & frameworks
– Python 3.9+
– PyGObject / GTK4 for widget rendering
– GDBus (via PyGI) for D-Bus interfaces
– Nix for reproducible builds
– GObject signals for event wiring