Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Notable user-visible changes are recorded here. ScriptWidget follows semantic ve
- Add bounded sleep, activity-ring and workout summaries, a Health Overview template and editable Web sample data.
- Fix native Promise callback ownership so completed and abandoned executions release their JavaScript VM and snapshot.
- Serialize native runtime subscription, result delivery and cancellation to prevent intermittent empty results and reference-lifetime crashes.
- Fix bundled templates whose text was cut off or pushed out of the widget, most visibly with the wider font of Android, Windows and Linux: Month Calendar (long month names, six-week months), the Daily Command Center, Family Command Board, Travel Day and Wellness dashboards, World Clock Faces and Year in Dots at the extra-large size, and fifteen smaller templates.
- Continue expanded personal-data APIs, authenticated services/music and visual editing on the same release branch; M3–M5 remain in progress.

## Unreleased
Expand Down
10 changes: 5 additions & 5 deletions Gallery/index.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"generatedAt": "2026-11-16T16:22:21.698Z",
"generatedAt": "2026-11-18T13:33:48.300Z",
"items": [
{
"author": "ScriptWidget Community",
Expand Down Expand Up @@ -1025,9 +1025,9 @@
"featured": true,
"files": [
{
"bytes": 3444,
"bytes": 3480,
"path": "main.jsx",
"sha256": "c28b645408169b2b794684c015fe2587de62710aaa071f4c0e0e251606b215b3",
"sha256": "8cd4403948dc83ed6cd955821657695a69bac3c0f62a672bec3735c676b8a2ab",
"url": "https://raw.githubusercontent.com/everettjf/scriptwidget/main/Gallery/widgets/music-playback/main.jsx"
},
{
Expand Down Expand Up @@ -1061,9 +1061,9 @@
"featured": true,
"files": [
{
"bytes": 603,
"bytes": 605,
"path": "main.jsx",
"sha256": "196ad38a141b5111a253c0687c96736cd1c296dc7d6ecb862ea1d0d57950debc",
"sha256": "4c9a60320892baf0870a9d882bdaec1da568961e04fbfaeb8042588a4c6b0519",
"url": "https://raw.githubusercontent.com/everettjf/scriptwidget/main/Gallery/widgets/layout-starter/main.jsx"
},
{
Expand Down
2 changes: 1 addition & 1 deletion Gallery/widgets/layout-starter/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $render(
<text font="caption" color="#657b96">A fresh start</text>
</hstack>
<spacer/>
<text font="title2" fontWeight="semibold" color="#263e60">Make today yours</text>
<text font="headline" fontWeight="semibold" color="#263e60">Make today yours</text>
<text font="caption" color="#657b96">A little space for your ideas.</text>
</vstack>
);
4 changes: 2 additions & 2 deletions Gallery/widgets/music-playback/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ if (family === "accessoryInline") {
$render(<vstack alignment="leading" spacing="2"><text font="headline">{title}</text><text font="caption2">{`${status} · ${playback ? playback.artist || "Music app" : "Open ScriptWidget"}`}</text></vstack>);
} else {
$render(<vstack frame="max" alignment="leading" spacing={compact || family === "medium" ? "8" : "16"} padding="16" background={background}>
<hstack spacing="8"><image systemName={symbol} font="title2" color={primary}/><text font="caption" color={secondary}>{status}</text><spacer/><text font="caption2" color={secondary}>Music</text></hstack>
<hstack spacing="8"><image systemName={symbol} font="title2" color={primary}/><text font="caption" color={secondary}>{compact && !playback ? "Setup" : status}</text><spacer/><text font="caption2" color={secondary}>Music</text></hstack>
<spacer/>
<text font={compact ? "headline" : "title2"} fontWeight="semibold" color={primary}>{title}</text>
<text font={compact ? "subheadline" : "title2"} fontWeight="semibold" color={primary}>{title}</text>
<text font="caption" color={secondary}>{subtitle}</text>
{progress !== null && <vstack spacing="4"><progress value={String(progress)} color={primary}/><hstack><text font="caption2" color={secondary}>{time(playback.position)}</text><spacer/><text font="caption2" color={secondary}>{time(playback.duration)}</text></hstack></vstack>}
{!compact && family !== "medium" && <><spacer/><text font="caption2" color={secondary}>A playback snapshot. Refresh to update.</text></>}
Expand Down
12 changes: 6 additions & 6 deletions Linux/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Linux/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resolver = "3"
members = ["crates/sw-quickjs", "crates/sw-core", "crates/sw-render", "crates/sw-cli", "crates/sw-host", "crates/sw-studio"]

[workspace.package]
version = "0.1.2"
version = "0.1.3"
edition = "2024"
license = "Apache-2.0"
publish = false
Expand Down
9 changes: 5 additions & 4 deletions Linux/crates/sw-cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,14 +641,15 @@ const size = $getenv("widget-size");

$render(
<vstack frame="max" alignment="leading" spacing="8" padding="16" background="#1d4ed8">
<hstack frame="max">
<hstack>
<icon systemName="wand.and.stars" size="22" color="#60a5fa"/>
<spacer/>
<badge text={size} color="#93c5fd"/>
</hstack>
<spacer/>
<text font="title2" weight="bold" color="white">Your next idea</text>
<text font="caption" color="#94a3b8">Start editing main.jsx to make it yours.</text>
<vstack frame="max,bottomLeading" alignment="leading" spacing="8">
<text font={size === "small" ? "headline" : "title2"} weight="bold" color="white">Your next idea</text>
<text font="caption" color="#94a3b8">Start editing main.jsx to make it yours.</text>
</vstack>
</vstack>
);
"##;
Expand Down
54 changes: 54 additions & 0 deletions Linux/crates/sw-render/examples/layout_tree.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//! Lays out canonical element trees and writes the recorded elements as JSON,
//! without painting: what `Linux/scripts/find-truncated-text.mjs` reads to
//! find text that did not fit.
//!
//! cargo run --release -p sw-render --example layout_tree -- [assets directory] < jobs
//!
//! Each line of standard input is one job, its fields separated by tabs:
//! `<tree.json> <family> <now, in milliseconds since 1970, or -> <package folder or -> <out.json>`.
//! One line is printed for each job: `ok` or `failed: <reason>`. The assets
//! directory is the one `node Linux/scripts/build-shared-js.mjs` writes
//! (default: `Linux/assets/scriptwidget`). A tree is what a package execution
//! returns; this example does not run packages.

use std::io::BufRead;
use std::path::PathBuf;
use std::process::ExitCode;
use std::sync::Arc;

use sw_core::{DiskPackageFiles, PackageFiles, SharedScripts};
use sw_render::{RenderRequest, WidgetRenderer};

fn lay_out(renderer: &WidgetRenderer, line: &str) -> Result<(), String> {
let [tree_file, family, now, package, output] = line.split('\t').collect::<Vec<_>>()[..] else {
return Err("a job is <tree.json> <family> <now or -> <package folder or -> <out.json>, separated by tabs".into());
};
let tree = std::fs::read_to_string(tree_file).map_err(|error| format!("{tree_file}: {error}"))?;
let mut request = RenderRequest::for_family(tree, family, 1.0).ok_or_else(|| format!("{family} is not a widget family"))?;
if now != "-" {
request.now_milliseconds = Some(now.parse().map_err(|_| format!("{now} is not a time"))?);
}
if package != "-" {
request.files = Some(Arc::new(DiskPackageFiles::new(PathBuf::from(package))) as Arc<dyn PackageFiles>);
}
let layout = renderer.layout(request).map_err(|error| error.to_string())?;
std::fs::write(output, layout).map_err(|error| format!("{output}: {error}"))
}

fn main() -> ExitCode {
let assets = std::env::args().nth(1).map_or_else(|| PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../assets/scriptwidget"), PathBuf::from);
let renderer = match SharedScripts::new(assets).map_err(|error| error.to_string()).and_then(|scripts| WidgetRenderer::new(Arc::new(scripts)).map_err(|error| error.to_string())) {
Ok(renderer) => renderer,
Err(message) => {
eprintln!("{message}");
return ExitCode::FAILURE;
}
};
for line in std::io::stdin().lock().lines().map_while(Result::ok).filter(|line| !line.is_empty()) {
match lay_out(&renderer, &line) {
Ok(()) => println!("ok"),
Err(message) => println!("failed: {}", message.replace('\n', " ")),
}
}
ExitCode::SUCCESS
}
4 changes: 2 additions & 2 deletions Linux/omarchy-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ Read from the environment of the shell process with `Quickshell.env`, for develo
The contract is section 4.8 of [`docs/linux/plan.md`](../../docs/linux/plan.md). The plugin runs `scriptwidget watch` and reads one JSON event per line.

- **Widgets.** Each `widget` event becomes one layer-shell window, namespace `scriptwidget`, on the bottom layer (above the wallpaper, below every window), on the screen the event names or the first screen. It is transparent, reserves no space and never takes the keyboard.
- **Taps.** The input region of a widget window is exactly its tap regions. A click in a region runs `scriptwidget tap <id> <n>`; a click anywhere else on the widget goes to whatever is below it. Where regions overlap, the one named last wins.
- **Taps and the menu.** A widget window takes the pointer over its whole area. A left click in a tap region runs `scriptwidget tap <id> <n>` (where regions overlap, the one named last wins); a left click elsewhere on the widget does nothing. A right click anywhere on the widget opens its menu: `resize-small`, `resize-medium`, `resize-large`, `resize-extraLarge`, `edit`, `refresh` and `remove` run `scriptwidget menu <id> <word>`, and "Move widgets…" / "Done moving" runs `scriptwidget arrange`.
- **Show on top** (`mode.peek`). The same windows move to the overlay layer and back.
- **Arrange** (`mode.arrange`). The widget windows are replaced by one window per screen, namespace `scriptwidget-arrange`, that shows the same pictures with an outline. A widget can be dragged; letting go runs `scriptwidget move <id> <screen> <x> <y>`. Within 40 px of an edge of the usable area a widget snaps to 16 px from it. The usable area is the screen without the bar and without the Omarchy dock: the plugin asks Hyprland (`hyprctl -j layers`) where the `omarchy-dock` layer is each time arrange mode starts and each time a drag starts. A right click opens a menu that runs `scriptwidget menu <id> <word>` with `resize-small`, `resize-medium`, `resize-large`, `resize-extraLarge`, `edit`, `refresh` or `remove`.
- **Arrange** (`mode.arrange`). The widget windows are replaced by one window per screen, namespace `scriptwidget-arrange`, that shows the same pictures with an outline. A widget can be dragged; letting go runs `scriptwidget move <id> <screen> <x> <y>`. Within 40 px of an edge of the usable area a widget snaps to 16 px from it. The usable area is the screen without the bar and without the Omarchy dock: the plugin asks Hyprland (`hyprctl -j layers`) where the `omarchy-dock` layer is each time arrange mode starts and each time a drag starts. A right click opens the same menu as outside arrange mode.
- **Frames.** A widget with `frames` cycles through them. The cycle stops while a fullscreen window is on the workspace in front of the widget (and "show on top" is off), while arranging, and while the service is not running. It does not stop when ordinary windows cover the widget or when the session is locked: Quickshell has no cheap signal for either.
- **Reports.** After every `hello`, and when they change: `scriptwidget screen <name> <scale> <width> <height>` for each screen (the scale Hyprland reports; logical size) and `scriptwidget theme <dark|light>`, judged from the brightness of the theme's background color.
- **Bar entry.** Left click opens the management window. Right click opens a card with "Show widgets on top" and "Arrange widgets", which run `scriptwidget peek` and `scriptwidget arrange` and show the state the last `mode` event gave.
Expand Down
39 changes: 35 additions & 4 deletions Linux/omarchy-plugin/Service.qml
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,11 @@ Item {
} else if (event.event === "remove") {
if (validId(event.id)) drop([event.id])
} else if (event.event === "mode") {
var arranging = arrange
arrange = event.arrange === true
peek = event.peek === true
if (!arrange) closeMenu()
// A menu opened in arrange mode goes with it; one opened outside it stays.
if (arranging && !arrange) closeMenu()
} else if (event.event === "bye") {
// The pictures stay; the retry below finds the service again.
greeted = false
Expand Down Expand Up @@ -365,7 +367,7 @@ Item {
}

function openMenu(id, screen, x, y) {
if (!arrange || !widgets[id]) return
if (!widgets[id]) return
menuScreen = screen
menuX = x
menuY = y
Expand Down Expand Up @@ -504,8 +506,8 @@ Item {
}
}

// The menu of a widget in arrange mode: one window over the whole screen,
// so a click anywhere else closes it.
// The menu of a widget, opened by a right click on it (in arrange mode or
// not): one window over the whole screen, so a click anywhere else closes it.
PanelWindow {
id: menu

Expand Down Expand Up @@ -575,6 +577,35 @@ Item {
}
}
}

// Not a word for the service: switches arrange mode, where widgets are dragged.
Rectangle {
id: arrangeRow
width: rows.width
height: Commons.Style.spacing.popupRowHeight
radius: Math.max(0, card.radius - Commons.Style.spacing.sm)
color: arrangeHover.containsMouse ? Commons.Style.hoverFill : "transparent"

Text {
anchors.verticalCenter: parent.verticalCenter
x: Commons.Style.spacing.controlPaddingX
width: parent.width - 2 * x
textFormat: Text.PlainText
text: strings.t(root.arrange ? "menu.arrange.done" : "menu.arrange")
color: Commons.Color.popups.text
font.family: Commons.Style.font.family
font.pixelSize: Commons.Style.font.body
elide: Text.ElideRight
}

MouseArea {
id: arrangeHover
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: { root.closeMenu(); root.toggleArrange() }
}
}
}
}
}
Expand Down
69 changes: 34 additions & 35 deletions Linux/omarchy-plugin/WidgetWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ PanelWindow {
// does not come up on the display it is given next. Hiding it for a moment
// and showing it again does bring it up there.
property bool moving: false
onScreenChanged: { moving = true; remap.restart() }
// The trigger is the set of displays changing, not this window's own
// "screen changed": the shell reports that one also while it is showing the
// window, and reacting to it hid the window again. With a display added or
// removed, every widget window is shown again, also one that stays where it is.
Connections {
target: Quickshell
function onScreensChanged() { if (!panel.moving) { panel.moving = true; remap.restart() } }
}
Timer { id: remap; interval: 200; onTriggered: panel.moving = false }
anchors { top: true; left: true }
margins { left: widget.x; top: widget.y }
Expand Down Expand Up @@ -60,33 +67,10 @@ PanelWindow {
}
Timer { id: layerSync; interval: 350; onTriggered: panel.syncLayer() }

// The input region: the tap regions and nothing else.
mask: Region { regions: panel.tapRegions }

property list<Region> tapRegions

function collectRegions() {
var found = []
for (var index = 0; index < regionMaker.count; index++) {
var region = regionMaker.objectAt(index)
if (region) found.push(region)
}
tapRegions = found
}

Instantiator {
id: regionMaker
model: panel.widget.regions
delegate: Region {
required property var modelData
x: modelData.x
y: modelData.y
width: modelData.width
height: modelData.height
}
onObjectAdded: panel.collectRegions()
onObjectRemoved: panel.collectRegions()
}
// The whole widget takes the pointer: a left click on a tap region is a tap,
// and a right click anywhere on it opens the widget's menu. (Earlier only
// the tap regions took input and the menu existed in arrange mode alone,
// which made a widget look as if it ignored the mouse.)

onFramesChanged: if (frame >= frames.length) frame = 0

Expand All @@ -103,19 +87,34 @@ PanelWindow {
}

MouseArea {
id: pointer
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton | Qt.RightButton
hoverEnabled: true
cursorShape: overRegion ? Qt.PointingHandCursor : Qt.ArrowCursor

onClicked: function (mouse) {
// Where regions overlap, the one named last is on top.
property bool overRegion: false

// The tap region at a point, or null. Where regions overlap, the one named last is on top.
function regionAt(x, y) {
var regions = panel.widget.regions
for (var index = regions.length - 1; index >= 0; index--) {
var region = regions[index]
if (mouse.x >= region.x && mouse.x < region.x + region.width && mouse.y >= region.y && mouse.y < region.y + region.height) {
panel.service.tap(panel.modelData, region.n)
return
}
if (x >= region.x && x < region.x + region.width && y >= region.y && y < region.y + region.height) return region
}
return null
}

onPositionChanged: function (mouse) { overRegion = regionAt(mouse.x, mouse.y) !== null }
onExited: overRegion = false

onClicked: function (mouse) {
if (mouse.button === Qt.RightButton) {
panel.service.openMenu(panel.modelData, panel.screen, panel.widget.x + mouse.x, panel.widget.y + mouse.y)
return
}
var region = regionAt(mouse.x, mouse.y)
if (region) panel.service.tap(panel.modelData, region.n)
}
}
}
4 changes: 3 additions & 1 deletion Linux/omarchy-plugin/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@
"menu.resize-extraLarge": "Extra large",
"menu.edit": "Edit",
"menu.refresh": "Refresh",
"menu.remove": "Remove"
"menu.remove": "Remove",
"menu.arrange": "Move widgets…",
"menu.arrange.done": "Done moving"
}
4 changes: 3 additions & 1 deletion Linux/omarchy-plugin/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@
"menu.resize-extraLarge": "特大",
"menu.edit": "编辑",
"menu.refresh": "刷新",
"menu.remove": "移除"
"menu.remove": "移除",
"menu.arrange": "移动小组件…",
"menu.arrange.done": "完成移动"
}
Loading
Loading