diff --git a/Sources/StableBar/WidgetSettings.swift b/Sources/StableBar/WidgetSettings.swift index e79a058f..976fb627 100644 --- a/Sources/StableBar/WidgetSettings.swift +++ b/Sources/StableBar/WidgetSettings.swift @@ -146,7 +146,7 @@ struct WidgetClockFormat { /// battery, whose icon is its battery block, `volume` for sound, `cpu`, `memory` or both, in /// order, for system, and `disk` for disk. enum WidgetMetricDisplay: String, CaseIterable { - case standard, changes, icon, value, meter, graph, custom + case standard, changes, icon, value, meter, labelValueMeter, graph, custom var title: String { switch self { @@ -155,6 +155,7 @@ enum WidgetMetricDisplay: String, CaseIterable { case .icon: "Icon only" case .value: "Value only" case .meter: "Meter and value" + case .labelValueMeter: "Label, value and meter" case .graph: "Graph and value" case .custom: "Custom layout" } @@ -182,6 +183,13 @@ enum WidgetMetricDisplay: String, CaseIterable { case .icon where sources == ["percent"]: return .null case .standard where sources == ["disk"]: return .null case .custom: return nil + case .labelValueMeter: + // A plain row on top, like the other choices: editing merges a new layout into the old one, so a top-level + // style here would stay behind on the next choice. + let columns = sources.map(metricColumn) + let content = columns.count == 1 ? columns[0] + : .object(["type": .string("row"), "style": .object(["spacing": .number(14)]), "children": .array(columns)]) + return .object(["type": .string("row"), "children": .array([content])]) default: return .object(["type": .string("row"), "children": .array(sources.flatMap(blocks))]) } } @@ -192,11 +200,7 @@ enum WidgetMetricDisplay: String, CaseIterable { case "memory": .object(["type": .string("symbol"), "name": .string("memorychip")]) default: .object(["type": .string("symbol"), "source": .string("icon")]) } - let text: ConfigurationValue = source == "memory" - ? .object(["type": .string("row"), "style": .object(["spacing": .number(0)]), "children": .array([ - .object(["type": .string("field"), "field": .string("memory")]), .object(["type": .string("text"), "text": .string("%")]) - ])]) - : .object(["type": .string("field"), "field": .string("text")]) + let text = Self.valueBlock(for: source) switch self { case .icon: return [icon] case .value: return [text] @@ -212,6 +216,38 @@ enum WidgetMetricDisplay: String, CaseIterable { } } + private static func valueBlock(for source: String) -> ConfigurationValue { + source == "memory" + ? .object(["type": .string("row"), "style": .object(["spacing": .number(0)]), "children": .array([ + .object(["type": .string("field"), "field": .string("memory")]), .object(["type": .string("text"), "text": .string("%")]) + ])]) + : .object(["type": .string("field"), "field": .string("text")]) + } + + /// A label and value over a meter. The widths are minimums: 100% fits 37 points in Built-in's and Fern's fonts, and a + /// theme with a larger or bolder font, such as Catppuccin's 13 pt medium, widens the column instead of cutting it. + private func metricColumn(for source: String) -> ConfigurationValue { + let label = ["percent": "BAT", "volume": "VOL", "cpu": "CPU", "memory": "MEM", "disk": "DISK"][source] ?? source.uppercased() + var value = Self.valueBlock(for: source) + if case var .object(properties) = value { + var style: [String: ConfigurationValue] = [:] + if case let .object(existing)? = properties["style"] { style = existing } + style["minWidth"] = .number(37) + properties["style"] = .object(style) + properties["alignment"] = .string("trailing") + value = .object(properties) + } + return .object(["type": .string("column"), "style": .object(["spacing": .number(1), "minWidth": .number(73)]), "children": .array([ + .object(["type": .string("row"), "style": .object(["spacing": .number(0)]), "children": .array([ + .object(["type": .string("text"), "text": .string(label), "role": .string("key"), "alignment": .string("leading"), + "style": .object(["fontWeight": .string("medium"), "minWidth": .number(36)])]), value + ])]), + .object(["type": .string("column"), "style": .object(["paddingTop": .number(2)]), "children": .array([ + .object(["type": .string("progress"), "source": .string(source), "height": .number(4), "role": .string("meter")]) + ])]) + ])]) + } + static func current(_ layout: ConfigurationValue?, sources: [String]) -> Self { if layout == nil || layout == .null { return choices(for: sources[0])[0] } guard case let .object(properties) = layout, properties["type"] == .string("row") else { return .custom } diff --git a/Tests/StableBarTests/BatteryTests.swift b/Tests/StableBarTests/BatteryTests.swift index e92761af..8d7014e8 100644 --- a/Tests/StableBarTests/BatteryTests.swift +++ b/Tests/StableBarTests/BatteryTests.swift @@ -131,7 +131,7 @@ private func battery(_ extra: [String: Any] = [:]) -> [String: Any] { } @Test func batteryDisplayStartsWithTheBatteryAloneAndUsesItAsTheIcon() { - #expect(WidgetMetricDisplay.choices(for: "percent") == [.icon, .standard, .value, .meter, .graph, .custom]) + #expect(WidgetMetricDisplay.choices(for: "percent") == [.icon, .standard, .value, .meter, .labelValueMeter, .graph, .custom]) #expect(WidgetMetricDisplay.icon.layout(for: ["percent"]) == .null) #expect(WidgetMetricDisplay.current(nil, sources: ["percent"]) == .icon) let battery: ConfigurationValue = .object(["type": .string("battery")]) diff --git a/Tests/StableBarTests/DiskTests.swift b/Tests/StableBarTests/DiskTests.swift index 8de12822..d3af40ae 100644 --- a/Tests/StableBarTests/DiskTests.swift +++ b/Tests/StableBarTests/DiskTests.swift @@ -84,7 +84,7 @@ func diskStateIsStrictlyAboveItsThreshold(available: Int64, state: String) { } @Test func diskDisplayOffersMeterAndValueButNoGraph() throws { - #expect(WidgetMetricDisplay.choices(for: "disk") == [.standard, .icon, .value, .meter, .custom]) + #expect(WidgetMetricDisplay.choices(for: "disk") == [.standard, .icon, .value, .meter, .labelValueMeter, .custom]) #expect(WidgetMetricDisplay.standard.layout(for: ["disk"]) == .null) #expect(WidgetMetricDisplay.current(nil, sources: ["disk"]) == .standard) for choice in WidgetMetricDisplay.choices(for: "disk") where choice != .custom { diff --git a/Tests/StableBarTests/MetricDisplayTests.swift b/Tests/StableBarTests/MetricDisplayTests.swift new file mode 100644 index 00000000..7fad7e6e --- /dev/null +++ b/Tests/StableBarTests/MetricDisplayTests.swift @@ -0,0 +1,128 @@ +import Foundation +import Testing +@testable import StableBar + +@Test(arguments: ["percent", "volume", "cpu", "memory", "disk"]) +func labeledMetricColumnsRoundTripAndKeepTheExistingDefaults(source: String) throws { + let choices = WidgetMetricDisplay.choices(for: source) + let meter = try #require(choices.firstIndex(of: .meter)) + #expect(choices[meter + 1] == .labelValueMeter) + let layout = try #require(WidgetMetricDisplay.labelValueMeter.layout(for: [source])) + #expect(WidgetMetricDisplay.current(layout, sources: [source]) == .labelValueMeter) + let row = try layout.decoded(PopupBlock.self) + guard case let .row(top) = row.content, top.count == 1, case let .column(children) = top[0].content else { + Issue.record("Expected a metric column in a plain row"); return + } + #expect(row.style == WidgetStyle()) + let block = top[0] + #expect(block.style.minWidth == 73) + guard case let .row(header) = children[0].content, case let .text(label) = header[0].content else { + Issue.record("Expected a label and value header"); return + } + #expect(label == ["percent": "BAT", "volume": "VOL", "cpu": "CPU", "memory": "MEM", "disk": "DISK"][source]) + #expect(header[0].role == .key) + #expect(header[1].alignment == .trailing) + #expect(header[1].style.minWidth == 37) + guard case let .column(meter) = children[1].content, + case let .progress(metric, height, _) = meter[0].content else { Issue.record("Expected a meter"); return } + #expect(metric == source) + #expect(height == 4) + #expect(meter[0].role == .meter) + #expect(children[1].style.paddingTop == 2) + #expect(WidgetMetricDisplay.current(nil, sources: [source]) != .labelValueMeter) +} + +@Test func labeledSystemMetricsKeepTheirOrderAndCustomSizingStaysCustom() throws { + for metrics in WidgetSystemMetrics.allCases { + let layout = try #require(WidgetMetricDisplay.labelValueMeter.layout(for: metrics.sources)) + #expect(WidgetSystemMetrics.current(layout) == metrics) + #expect(WidgetMetricDisplay.current(layout, sources: metrics.sources) == .labelValueMeter) + if metrics.sources.count == 2 { + let block = try layout.decoded(PopupBlock.self) + guard case let .row(top) = block.content else { Issue.record("Expected a row"); continue } + #expect(top.first?.style.spacing == 14) + } + guard case var .object(changed) = layout, case var .array(children) = changed["children"], + case var .object(content) = children[0] else { continue } + content["style"] = .object(["spacing": .number(20)]) + children[0] = .object(content) + changed["children"] = .array(children) + #expect(WidgetMetricDisplay.current(.object(changed), sources: metrics.sources) == .custom) + } +} + +@Test @MainActor func aMetricDisplayEditStaysInItsProfileAndCanBeUndone() throws { + let fixture = try ThemeGalleryFixture(#"{"widgets":[{"id":"disk","type":"disk","position":"right","onClick":"open-disk"}],"profiles":[{"name":"fern","configuration":{}}]}"#) + defer { fixture.close() } + let store = try fixture.store() + defer { store.stop() } + let editor = ConfigurationEditor(store: store) + editor.editBar(for: "fern") + let before = try fixture.document() + editor.set(["layout": try #require(WidgetMetricDisplay.labelValueMeter.layout(for: ["disk"]))], for: "disk") + try editor.history.flush() + #expect(editor.error == nil) + #expect(store.configuration?.widgets.first?.position == .right) + #expect(store.configuration?.widgets.first?.onClick == "open-disk") + #expect(WidgetMetricDisplay.current(editor.properties(for: "disk")["layout"], sources: ["disk"]) == .labelValueMeter) + let document = try fixture.document() + let widgets = try #require(document["widgets"]).decoded([[String: ConfigurationValue]].self) + #expect(widgets[0]["layout"] == nil) + editor.undo() + #expect(try fixture.document() == before) +} + +@Test(arguments: [false, true]) @MainActor +func switchingAwayFromLabelValueAndMeterLeavesNothingBehind(inProfile: Bool) throws { + let fixture = try ThemeGalleryFixture(#"{"widgets":[{"id":"disk","type":"disk","position":"right"},{"id":"system","type":"system","position":"right"}],"profiles":[{"name":"fern","configuration":{}}]}"#) + defer { fixture.close() } + let store = try fixture.store() + defer { store.stop() } + let editor = ConfigurationEditor(store: store) + if inProfile { editor.editBar(for: "fern") } + for (id, sources) in [("disk", ["disk"]), ("system", ["memory", "cpu"])] { + for choice in WidgetMetricDisplay.choices(for: sources[0]) where choice != .labelValueMeter && choice != .custom { + editor.set(["layout": try #require(WidgetMetricDisplay.labelValueMeter.layout(for: sources))], for: id) + // Saved first: Settings merges an edit of the same paths into the pending one, which never reaches the file. + try editor.history.flush() + editor.set(["layout": try #require(choice.layout(for: sources))], for: id) + try editor.history.flush() + #expect(editor.error == nil) + let layout = editor.properties(for: id)["layout"] + #expect(WidgetMetricDisplay.current(layout, sources: sources) == choice, "\(id) \(choice)") + if case .object = choice.layout(for: sources) { #expect(layout == choice.layout(for: sources), "\(id) \(choice)") } + } + } +} + +@Test func aStyledRowKeepsItsChoiceAcrossLabelValueAndMeter() throws { + for sources in [["disk"], ["cpu", "memory"]] { + for choice in [WidgetMetricDisplay.labelValueMeter, .meter] { + guard case var .object(layout) = choice.layout(for: sources) else { Issue.record("Expected a layout"); continue } + layout["style"] = .object(["paddingHorizontal": .number(4)]) + #expect(WidgetMetricDisplay.current(.object(layout), sources: sources) == choice) + } + } +} + +@Test func labeledSystemColumnsWarnEachMetricApart() throws { + for sources in [["cpu", "memory"], ["memory", "cpu"]] { + let configuration = try ConfigurationValue.object([ + "providers": .object(["system": .object(["type": .string("system")])]), + "widgets": .array([.object(["id": .string("system"), "type": .string("system"), "position": .string("right"), + "details": .bool(true), "layout": try #require(WidgetMetricDisplay.labelValueMeter.layout(for: sources))])]) + ]).decoded(Configuration.self) + let widget = configuration.widgets[0] + guard case let .row(top)? = widget.layout?.content, case let .row(columns)? = top.first?.content else { + Issue.record("Expected two columns in a row"); continue + } + #expect(columns.count == 2) + for (cpu, memory) in [(0.95, 0.5), (0.5, 0.95)] { + let output = ScriptOutput(text: "\(Int(cpu * 100))%", icon: "cpu", fields: ["pressure": "normal", "thermal": "nominal"], + values: ["cpu": cpu, "memory": memory]) + let states = widgetDataStates(output, widget: widget, providers: configuration.providers) + let expected = sources.map { ($0 == "cpu" ? cpu : memory) > 0.9 ? "warning" : nil } + #expect(columns.map { StyleStates(data: states.widget, parts: states.parts).scoped(to: $0).data } == expected, "\(sources) cpu \(cpu)") + } + } +} diff --git a/docs/create-a-widget.md b/docs/create-a-widget.md index b1171c5d..6a9d684b 100644 --- a/docs/create-a-widget.md +++ b/docs/create-a-widget.md @@ -118,7 +118,9 @@ dist/StableBar.app/Contents/MacOS/StableBar --config "$scratch/config.json" A widget without `layout` draws a default layout made of the same blocks: a `row` of its icon (`symbol`) and text (`field`), at least a line of text tall even when it shows only the icon. Its digits all have the same width, so a number that changes, such as a CPU percentage, doesn't resize the widget. Battery draws a [`battery`](popups.md) block, like the battery in the macOS menu bar: its fill follows the charge and turns red at 10 % or less on battery power, a bolt shows it charging, and a plug shows the Mac on its adapter without charging. An orange badge appears when macOS recommends servicing the battery, the condition System Settings shows under Battery Health. Its percentage is in its tooltip, with the time left or until full and “Service recommended” when it applies. A Mac without a battery shows a plug and AC. Sound shows only its speaker icon, whose waves show the volume: none at zero, then one, two or three. The icon keeps the width of three waves, so the widget doesn't change size between levels. After the volume changes, the new volume fades in beside it for a moment, its digits rolling while it keeps changing, then fades out. Muting hides it at once. Hovering it shows a volume slider, with the volume, that changes the volume as you drag: in a tooltip under the widget, or beside the icon with [Open hover controls inline](#controls-on-hover). Inline, on the right of the bar the slider opens to the icon's left, so the icon stays under the pointer; elsewhere it opens to the right. A Sound widget with a `layout` of its own, including a **Display** choice other than its default, has no slider. The bar animates the Sound widget's width as the volume and the inline slider come and go, unless Reduce Motion is on. Other script and provider widgets whose output has a `value` show a 40 × 16 `graph` before them, and active-app widgets show the app's icon instead of a `symbol`. Workspaces and spacers keep their own views. A `layout` replaces the default layout, so block options work on built-in widgets too, for example an app name that scrolls when it doesn't fit: `"layout": { "type": "field", "field": "text", "scrollSpeed": 30, "style": { "maxWidth": 120 } }`. -For battery, sound, system and disk, **Settings → Bar → Content → Display** offers icon and value, icon only, value only, meter and value, or graph and value. Battery starts with icon only, its default, and its icon in every choice is its battery; sound starts with icon, value on change, its default, and system with graph and value. Disk starts with icon and value, and has no graph, since it keeps no history. For system, **Shows** chooses **CPU**, its default, **Memory**, **CPU and memory** or **Memory and CPU**; each gets its own symbol and value, drawn as Display says, and memory's graph draws `series.memory`. This also works with named battery/audio/system/disk providers and package widgets. Choices use the existing `layout` configuration and support Undo; a hand-written layout stays marked **Custom layout** until you choose another display. +For battery, sound, system and disk, **Settings → Bar → Content → Display** offers icon and value, icon only, value only, meter and value, label, value and meter, or graph and value. Battery starts with icon only, its default, and its icon in every choice is its battery; sound starts with icon, value on change, its default, and system with graph and value. Disk starts with icon and value, and has no graph, since it keeps no history. For system, **Shows** chooses **CPU**, its default, **Memory**, **CPU and memory** or **Memory and CPU**; each gets its own symbol and value, drawn as Display says, and memory's graph draws `series.memory`. This also works with named battery/audio/system/disk providers and package widgets. Choices use the existing `layout` configuration and support Undo; a hand-written layout stays marked **Custom layout** until you choose another display. + +**Label, value and meter** puts a short label and a right-aligned percentage on one line, above a progress line. The label uses the `key` role and the line the `meter` role, so a theme styles both, and the column widens when a theme's font needs more room for 100%. System keeps CPU and memory in the selected order, each in its own column. This is a widget layout choice, so it stays selected when you change themes. `overlay` uses the same blocks, aligned to the widget's bottom edge. It occupies no space and does not intercept clicks. This supports an underline, playback progress or a graph underneath the label. diff --git a/scenes/labeled-metric-built-in.json b/scenes/labeled-metric-built-in.json new file mode 100644 index 00000000..e07fbabc --- /dev/null +++ b/scenes/labeled-metric-built-in.json @@ -0,0 +1,430 @@ +{ + "$schema": "../scene.schema.json", + "configuration": { + "theme": {"id": "built-in"}, + "widgets": [ + { + "id": "system-9", + "type": "provider", + "position": "left", + "layout": { + "type": "row", + "children": [ + { + "type": "row", + "style": {"spacing": 14}, + "children": [ + { + "type": "column", + "style": {"spacing": 1, "minWidth": 73}, + "children": [ + { + "type": "row", + "style": {"spacing": 0}, + "children": [ + { + "type": "text", + "text": "CPU", + "role": "key", + "alignment": "leading", + "style": {"fontWeight": "medium", "minWidth": 36} + }, + {"type": "field", "field": "text", "alignment": "trailing", "style": {"minWidth": 37}} + ] + }, + { + "type": "column", + "style": {"paddingTop": 2}, + "children": [{"type": "progress", "source": "cpu", "height": 4, "role": "meter"}] + } + ] + }, + { + "type": "column", + "style": {"spacing": 1, "minWidth": 73}, + "children": [ + { + "type": "row", + "style": {"spacing": 0}, + "children": [ + { + "type": "text", + "text": "MEM", + "role": "key", + "alignment": "leading", + "style": {"fontWeight": "medium", "minWidth": 36} + }, + { + "type": "row", + "style": {"spacing": 0, "minWidth": 37}, + "children": [{"type": "field", "field": "memory"}, {"type": "text", "text": "%"}], + "alignment": "trailing" + } + ] + }, + { + "type": "column", + "style": {"paddingTop": 2}, + "children": [{"type": "progress", "source": "memory", "height": 4, "role": "meter"}] + } + ] + } + ] + } + ] + }, + "provider": "system-9" + }, + { + "id": "disk-9", + "type": "provider", + "position": "left", + "layout": { + "type": "row", + "children": [ + { + "type": "column", + "style": {"spacing": 1, "minWidth": 73}, + "children": [ + { + "type": "row", + "style": {"spacing": 0}, + "children": [ + { + "type": "text", + "text": "DISK", + "role": "key", + "alignment": "leading", + "style": {"fontWeight": "medium", "minWidth": 36} + }, + {"type": "field", "field": "text", "alignment": "trailing", "style": {"minWidth": 37}} + ] + }, + { + "type": "column", + "style": {"paddingTop": 2}, + "children": [{"type": "progress", "source": "disk", "height": 4, "role": "meter"}] + } + ] + } + ] + }, + "provider": "disk-9" + }, + { + "id": "battery-9", + "type": "provider", + "position": "left", + "layout": { + "type": "row", + "children": [ + { + "type": "column", + "style": {"spacing": 1, "minWidth": 73}, + "children": [ + { + "type": "row", + "style": {"spacing": 0}, + "children": [ + { + "type": "text", + "text": "BAT", + "role": "key", + "alignment": "leading", + "style": {"fontWeight": "medium", "minWidth": 36} + }, + {"type": "field", "field": "text", "alignment": "trailing", "style": {"minWidth": 37}} + ] + }, + { + "type": "column", + "style": {"paddingTop": 2}, + "children": [{"type": "progress", "source": "percent", "height": 4, "role": "meter"}] + } + ] + } + ] + }, + "provider": "battery-9" + }, + { + "id": "audio-9", + "type": "provider", + "position": "left", + "layout": { + "type": "row", + "children": [ + { + "type": "column", + "style": {"spacing": 1, "minWidth": 73}, + "children": [ + { + "type": "row", + "style": {"spacing": 0}, + "children": [ + { + "type": "text", + "text": "VOL", + "role": "key", + "alignment": "leading", + "style": {"fontWeight": "medium", "minWidth": 36} + }, + {"type": "field", "field": "text", "alignment": "trailing", "style": {"minWidth": 37}} + ] + }, + { + "type": "column", + "style": {"paddingTop": 2}, + "children": [{"type": "progress", "source": "volume", "height": 4, "role": "meter"}] + } + ] + } + ] + }, + "provider": "audio-9" + }, + { + "id": "system-100", + "type": "provider", + "position": "left", + "layout": { + "type": "row", + "children": [ + { + "type": "row", + "style": {"spacing": 14}, + "children": [ + { + "type": "column", + "style": {"spacing": 1, "minWidth": 73}, + "children": [ + { + "type": "row", + "style": {"spacing": 0}, + "children": [ + { + "type": "text", + "text": "CPU", + "role": "key", + "alignment": "leading", + "style": {"fontWeight": "medium", "minWidth": 36} + }, + {"type": "field", "field": "text", "alignment": "trailing", "style": {"minWidth": 37}} + ] + }, + { + "type": "column", + "style": {"paddingTop": 2}, + "children": [{"type": "progress", "source": "cpu", "height": 4, "role": "meter"}] + } + ] + }, + { + "type": "column", + "style": {"spacing": 1, "minWidth": 73}, + "children": [ + { + "type": "row", + "style": {"spacing": 0}, + "children": [ + { + "type": "text", + "text": "MEM", + "role": "key", + "alignment": "leading", + "style": {"fontWeight": "medium", "minWidth": 36} + }, + { + "type": "row", + "style": {"spacing": 0, "minWidth": 37}, + "children": [{"type": "field", "field": "memory"}, {"type": "text", "text": "%"}], + "alignment": "trailing" + } + ] + }, + { + "type": "column", + "style": {"paddingTop": 2}, + "children": [{"type": "progress", "source": "memory", "height": 4, "role": "meter"}] + } + ] + } + ] + } + ] + }, + "provider": "system-100" + }, + { + "id": "disk-100", + "type": "provider", + "position": "left", + "layout": { + "type": "row", + "children": [ + { + "type": "column", + "style": {"spacing": 1, "minWidth": 73}, + "children": [ + { + "type": "row", + "style": {"spacing": 0}, + "children": [ + { + "type": "text", + "text": "DISK", + "role": "key", + "alignment": "leading", + "style": {"fontWeight": "medium", "minWidth": 36} + }, + {"type": "field", "field": "text", "alignment": "trailing", "style": {"minWidth": 37}} + ] + }, + { + "type": "column", + "style": {"paddingTop": 2}, + "children": [{"type": "progress", "source": "disk", "height": 4, "role": "meter"}] + } + ] + } + ] + }, + "provider": "disk-100" + }, + { + "id": "battery-100", + "type": "provider", + "position": "left", + "layout": { + "type": "row", + "children": [ + { + "type": "column", + "style": {"spacing": 1, "minWidth": 73}, + "children": [ + { + "type": "row", + "style": {"spacing": 0}, + "children": [ + { + "type": "text", + "text": "BAT", + "role": "key", + "alignment": "leading", + "style": {"fontWeight": "medium", "minWidth": 36} + }, + {"type": "field", "field": "text", "alignment": "trailing", "style": {"minWidth": 37}} + ] + }, + { + "type": "column", + "style": {"paddingTop": 2}, + "children": [{"type": "progress", "source": "percent", "height": 4, "role": "meter"}] + } + ] + } + ] + }, + "provider": "battery-100" + }, + { + "id": "audio-100", + "type": "provider", + "position": "left", + "layout": { + "type": "row", + "children": [ + { + "type": "column", + "style": {"spacing": 1, "minWidth": 73}, + "children": [ + { + "type": "row", + "style": {"spacing": 0}, + "children": [ + { + "type": "text", + "text": "VOL", + "role": "key", + "alignment": "leading", + "style": {"fontWeight": "medium", "minWidth": 36} + }, + {"type": "field", "field": "text", "alignment": "trailing", "style": {"minWidth": 37}} + ] + }, + { + "type": "column", + "style": {"paddingTop": 2}, + "children": [{"type": "progress", "source": "volume", "height": 4, "role": "meter"}] + } + ] + } + ] + }, + "provider": "audio-100" + } + ], + "providers": { + "system-9": {"type": "system"}, + "disk-9": {"type": "disk"}, + "battery-9": {"type": "battery"}, + "audio-9": {"type": "audio"}, + "system-100": {"type": "system"}, + "disk-100": {"type": "disk"}, + "battery-100": {"type": "battery"}, + "audio-100": {"type": "audio"} + } + }, + "outputs": { + "system-9": { + "text": "9%", + "value": 0.09, + "values": {"cpu": 0.09, "memory": 0.09}, + "fields": {"memory": "9"} + }, + "disk-9": { + "text": "9%", + "value": 0.09, + "values": {"disk": 0.09}, + "fields": {"memory": "9"} + }, + "battery-9": { + "text": "9%", + "value": 0.09, + "values": {"percent": 0.09}, + "fields": {"memory": "9"} + }, + "audio-9": { + "text": "9%", + "value": 0.09, + "values": {"volume": 0.09}, + "fields": {"memory": "9"} + }, + "system-100": { + "text": "100%", + "value": 1.0, + "values": {"cpu": 1.0, "memory": 1.0}, + "fields": {"memory": "100"} + }, + "disk-100": { + "text": "100%", + "value": 1.0, + "values": {"disk": 1.0}, + "fields": {"memory": "100"} + }, + "battery-100": { + "text": "100%", + "value": 1.0, + "values": {"percent": 1.0}, + "fields": {"memory": "100"} + }, + "audio-100": { + "text": "100%", + "value": 1.0, + "values": {"volume": 1.0}, + "fields": {"memory": "100"} + } + }, + "draw": "bar", + "width": 1280 +} diff --git a/scenes/labeled-metric-catppuccin.json b/scenes/labeled-metric-catppuccin.json new file mode 100644 index 00000000..1750fe88 --- /dev/null +++ b/scenes/labeled-metric-catppuccin.json @@ -0,0 +1,430 @@ +{ + "$schema": "../scene.schema.json", + "configuration": { + "theme": {"id": "catppuccin"}, + "widgets": [ + { + "id": "system-9", + "type": "provider", + "position": "left", + "layout": { + "type": "row", + "children": [ + { + "type": "row", + "style": {"spacing": 14}, + "children": [ + { + "type": "column", + "style": {"spacing": 1, "minWidth": 73}, + "children": [ + { + "type": "row", + "style": {"spacing": 0}, + "children": [ + { + "type": "text", + "text": "CPU", + "role": "key", + "alignment": "leading", + "style": {"fontWeight": "medium", "minWidth": 36} + }, + {"type": "field", "field": "text", "alignment": "trailing", "style": {"minWidth": 37}} + ] + }, + { + "type": "column", + "style": {"paddingTop": 2}, + "children": [{"type": "progress", "source": "cpu", "height": 4, "role": "meter"}] + } + ] + }, + { + "type": "column", + "style": {"spacing": 1, "minWidth": 73}, + "children": [ + { + "type": "row", + "style": {"spacing": 0}, + "children": [ + { + "type": "text", + "text": "MEM", + "role": "key", + "alignment": "leading", + "style": {"fontWeight": "medium", "minWidth": 36} + }, + { + "type": "row", + "style": {"spacing": 0, "minWidth": 37}, + "children": [{"type": "field", "field": "memory"}, {"type": "text", "text": "%"}], + "alignment": "trailing" + } + ] + }, + { + "type": "column", + "style": {"paddingTop": 2}, + "children": [{"type": "progress", "source": "memory", "height": 4, "role": "meter"}] + } + ] + } + ] + } + ] + }, + "provider": "system-9" + }, + { + "id": "disk-9", + "type": "provider", + "position": "left", + "layout": { + "type": "row", + "children": [ + { + "type": "column", + "style": {"spacing": 1, "minWidth": 73}, + "children": [ + { + "type": "row", + "style": {"spacing": 0}, + "children": [ + { + "type": "text", + "text": "DISK", + "role": "key", + "alignment": "leading", + "style": {"fontWeight": "medium", "minWidth": 36} + }, + {"type": "field", "field": "text", "alignment": "trailing", "style": {"minWidth": 37}} + ] + }, + { + "type": "column", + "style": {"paddingTop": 2}, + "children": [{"type": "progress", "source": "disk", "height": 4, "role": "meter"}] + } + ] + } + ] + }, + "provider": "disk-9" + }, + { + "id": "battery-9", + "type": "provider", + "position": "left", + "layout": { + "type": "row", + "children": [ + { + "type": "column", + "style": {"spacing": 1, "minWidth": 73}, + "children": [ + { + "type": "row", + "style": {"spacing": 0}, + "children": [ + { + "type": "text", + "text": "BAT", + "role": "key", + "alignment": "leading", + "style": {"fontWeight": "medium", "minWidth": 36} + }, + {"type": "field", "field": "text", "alignment": "trailing", "style": {"minWidth": 37}} + ] + }, + { + "type": "column", + "style": {"paddingTop": 2}, + "children": [{"type": "progress", "source": "percent", "height": 4, "role": "meter"}] + } + ] + } + ] + }, + "provider": "battery-9" + }, + { + "id": "audio-9", + "type": "provider", + "position": "left", + "layout": { + "type": "row", + "children": [ + { + "type": "column", + "style": {"spacing": 1, "minWidth": 73}, + "children": [ + { + "type": "row", + "style": {"spacing": 0}, + "children": [ + { + "type": "text", + "text": "VOL", + "role": "key", + "alignment": "leading", + "style": {"fontWeight": "medium", "minWidth": 36} + }, + {"type": "field", "field": "text", "alignment": "trailing", "style": {"minWidth": 37}} + ] + }, + { + "type": "column", + "style": {"paddingTop": 2}, + "children": [{"type": "progress", "source": "volume", "height": 4, "role": "meter"}] + } + ] + } + ] + }, + "provider": "audio-9" + }, + { + "id": "system-100", + "type": "provider", + "position": "left", + "layout": { + "type": "row", + "children": [ + { + "type": "row", + "style": {"spacing": 14}, + "children": [ + { + "type": "column", + "style": {"spacing": 1, "minWidth": 73}, + "children": [ + { + "type": "row", + "style": {"spacing": 0}, + "children": [ + { + "type": "text", + "text": "CPU", + "role": "key", + "alignment": "leading", + "style": {"fontWeight": "medium", "minWidth": 36} + }, + {"type": "field", "field": "text", "alignment": "trailing", "style": {"minWidth": 37}} + ] + }, + { + "type": "column", + "style": {"paddingTop": 2}, + "children": [{"type": "progress", "source": "cpu", "height": 4, "role": "meter"}] + } + ] + }, + { + "type": "column", + "style": {"spacing": 1, "minWidth": 73}, + "children": [ + { + "type": "row", + "style": {"spacing": 0}, + "children": [ + { + "type": "text", + "text": "MEM", + "role": "key", + "alignment": "leading", + "style": {"fontWeight": "medium", "minWidth": 36} + }, + { + "type": "row", + "style": {"spacing": 0, "minWidth": 37}, + "children": [{"type": "field", "field": "memory"}, {"type": "text", "text": "%"}], + "alignment": "trailing" + } + ] + }, + { + "type": "column", + "style": {"paddingTop": 2}, + "children": [{"type": "progress", "source": "memory", "height": 4, "role": "meter"}] + } + ] + } + ] + } + ] + }, + "provider": "system-100" + }, + { + "id": "disk-100", + "type": "provider", + "position": "left", + "layout": { + "type": "row", + "children": [ + { + "type": "column", + "style": {"spacing": 1, "minWidth": 73}, + "children": [ + { + "type": "row", + "style": {"spacing": 0}, + "children": [ + { + "type": "text", + "text": "DISK", + "role": "key", + "alignment": "leading", + "style": {"fontWeight": "medium", "minWidth": 36} + }, + {"type": "field", "field": "text", "alignment": "trailing", "style": {"minWidth": 37}} + ] + }, + { + "type": "column", + "style": {"paddingTop": 2}, + "children": [{"type": "progress", "source": "disk", "height": 4, "role": "meter"}] + } + ] + } + ] + }, + "provider": "disk-100" + }, + { + "id": "battery-100", + "type": "provider", + "position": "left", + "layout": { + "type": "row", + "children": [ + { + "type": "column", + "style": {"spacing": 1, "minWidth": 73}, + "children": [ + { + "type": "row", + "style": {"spacing": 0}, + "children": [ + { + "type": "text", + "text": "BAT", + "role": "key", + "alignment": "leading", + "style": {"fontWeight": "medium", "minWidth": 36} + }, + {"type": "field", "field": "text", "alignment": "trailing", "style": {"minWidth": 37}} + ] + }, + { + "type": "column", + "style": {"paddingTop": 2}, + "children": [{"type": "progress", "source": "percent", "height": 4, "role": "meter"}] + } + ] + } + ] + }, + "provider": "battery-100" + }, + { + "id": "audio-100", + "type": "provider", + "position": "left", + "layout": { + "type": "row", + "children": [ + { + "type": "column", + "style": {"spacing": 1, "minWidth": 73}, + "children": [ + { + "type": "row", + "style": {"spacing": 0}, + "children": [ + { + "type": "text", + "text": "VOL", + "role": "key", + "alignment": "leading", + "style": {"fontWeight": "medium", "minWidth": 36} + }, + {"type": "field", "field": "text", "alignment": "trailing", "style": {"minWidth": 37}} + ] + }, + { + "type": "column", + "style": {"paddingTop": 2}, + "children": [{"type": "progress", "source": "volume", "height": 4, "role": "meter"}] + } + ] + } + ] + }, + "provider": "audio-100" + } + ], + "providers": { + "system-9": {"type": "system"}, + "disk-9": {"type": "disk"}, + "battery-9": {"type": "battery"}, + "audio-9": {"type": "audio"}, + "system-100": {"type": "system"}, + "disk-100": {"type": "disk"}, + "battery-100": {"type": "battery"}, + "audio-100": {"type": "audio"} + } + }, + "outputs": { + "system-9": { + "text": "9%", + "value": 0.09, + "values": {"cpu": 0.09, "memory": 0.09}, + "fields": {"memory": "9"} + }, + "disk-9": { + "text": "9%", + "value": 0.09, + "values": {"disk": 0.09}, + "fields": {"memory": "9"} + }, + "battery-9": { + "text": "9%", + "value": 0.09, + "values": {"percent": 0.09}, + "fields": {"memory": "9"} + }, + "audio-9": { + "text": "9%", + "value": 0.09, + "values": {"volume": 0.09}, + "fields": {"memory": "9"} + }, + "system-100": { + "text": "100%", + "value": 1.0, + "values": {"cpu": 1.0, "memory": 1.0}, + "fields": {"memory": "100"} + }, + "disk-100": { + "text": "100%", + "value": 1.0, + "values": {"disk": 1.0}, + "fields": {"memory": "100"} + }, + "battery-100": { + "text": "100%", + "value": 1.0, + "values": {"percent": 1.0}, + "fields": {"memory": "100"} + }, + "audio-100": { + "text": "100%", + "value": 1.0, + "values": {"volume": 1.0}, + "fields": {"memory": "100"} + } + }, + "draw": "bar", + "width": 1280 +} diff --git a/scenes/settings-labeled-metric.json b/scenes/settings-labeled-metric.json new file mode 100644 index 00000000..8f0e0572 --- /dev/null +++ b/scenes/settings-labeled-metric.json @@ -0,0 +1,109 @@ +{ + "$schema": "../scene.schema.json", + "configuration": { + "theme": {"id": "built-in"}, + "widgets": [ + { + "id": "disk-100", + "type": "provider", + "position": "left", + "layout": { + "type": "row", + "children": [ + { + "type": "column", + "style": {"spacing": 1, "minWidth": 73}, + "children": [ + { + "type": "row", + "style": {"spacing": 0}, + "children": [ + { + "type": "text", + "text": "DISK", + "role": "key", + "alignment": "leading", + "style": {"fontWeight": "medium", "minWidth": 36} + }, + {"type": "field", "field": "text", "alignment": "trailing", "style": {"minWidth": 37}} + ] + }, + { + "type": "column", + "style": {"paddingTop": 2}, + "children": [{"type": "progress", "source": "disk", "height": 4, "role": "meter"}] + } + ] + } + ] + }, + "provider": "disk-100" + } + ], + "providers": { + "system-9": {"type": "system"}, + "disk-9": {"type": "disk"}, + "battery-9": {"type": "battery"}, + "audio-9": {"type": "audio"}, + "system-100": {"type": "system"}, + "disk-100": {"type": "disk"}, + "battery-100": {"type": "battery"}, + "audio-100": {"type": "audio"} + } + }, + "outputs": { + "system-9": { + "text": "9%", + "value": 0.09, + "values": {"cpu": 0.09, "memory": 0.09}, + "fields": {"memory": "9"} + }, + "disk-9": { + "text": "9%", + "value": 0.09, + "values": {"disk": 0.09}, + "fields": {"memory": "9"} + }, + "battery-9": { + "text": "9%", + "value": 0.09, + "values": {"percent": 0.09}, + "fields": {"memory": "9"} + }, + "audio-9": { + "text": "9%", + "value": 0.09, + "values": {"volume": 0.09}, + "fields": {"memory": "9"} + }, + "system-100": { + "text": "100%", + "value": 1.0, + "values": {"cpu": 1.0, "memory": 1.0}, + "fields": {"memory": "100"} + }, + "disk-100": { + "text": "100%", + "value": 1.0, + "values": {"disk": 1.0}, + "fields": {"memory": "100"} + }, + "battery-100": { + "text": "100%", + "value": 1.0, + "values": {"percent": 1.0}, + "fields": {"memory": "100"} + }, + "audio-100": { + "text": "100%", + "value": 1.0, + "values": {"volume": 1.0}, + "fields": {"memory": "100"} + } + }, + "draw": "settings", + "width": 680, + "widget": "disk-100", + "tab": "content", + "height": 640 +}