widget_core.node).
graph TD
A[Node.js App] --> B[DesktopWidget Class]
B --> C[WidgetRegistry]
B --> D[AutostartManager]
B --> E[Native Module C++]
E --> F{Platform}
F -->|Linux| G[WebKitGTK + GTK3]
F -->|macOS| H[WKWebView + Cocoa]
F -->|Windows| I[WebView2 + Win32]
G --> J[Desktop Widget Window]
H --> J
I --> J
interactive: true to allow
mouse clicks and keyboard input directly on the desktop background.process, require, and other sensitive
Node.js globals.http:, https:, and valid file: protocols are allowed
for loading content.shell, eval, or exec.import { DesktopWidget } from 'widget-core';
const clockHTML = `
00:00:00
`;
const widget = new DesktopWidget("", {
html: clockHTML,
width: 300,
height: 100,
x: 50,
y: 50,
scroll: false,
interactive: false // Clocks usually don't need input
});
// Make it stay after reboot
await widget.makePersistent(widget.options);
// Stop all running widgets across the system
const stopped = DesktopWidget.stopAll();
// Get list of all registered widgets
const widgets = DesktopWidget.listWidgets();
widgets.forEach(w => console.log(ID: ${w.id}, URL: ${w.url}, Active: ${w.active}));
WidgetOptions
| Property | Type | Description |
|---|---|---|
width |
number |
Width in pixels. |
height |
number |
Height in pixels. |
x |
number |
X coordinate from top-left. |
y |
number |
Y coordinate from top-left. |
opacity |
number |
Window opacity (0.0 to 1.0). Default: 1.0. |
interactive |
boolean |
If true, clicks pass
through to the widget. Default: false. |
html |
string |
Raw HTML/CSS source code to load. |
scroll |
boolean |
If false, overflow: hidden is
applied. Default: true. |
blur |
boolean |
Platform-specific background blur effect. |
makePersistent(options): Promise
: Saves to disk and enables autostart.
activate(): boolean:
Enables autostart and launches the process.deactivate(): boolean:
Disables autostart and kills the process.launchStandalone():
boolean: Spawns a background runner.js process for the
widget.libwebkit2gtk-4.0-dev or libwebkit2gtk-4.1-dev..desktop files in ~/.config/autostart/..plist files in ~/Library/LaunchAgents/.HKCU\Software\Microsoft\Windows\CurrentVersion\Run
registry key.
Install dependencies
npm install
Build native module & TypeScript
npm run build
Run tests
npm test
interactive: true in the
options.~/.config/widget-core/widgets.json
exists and the autostart entry is correct.Author: Osman Beyhan
โค๏ธ Make via MDtoWeb