aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/modules')
-rw-r--r--desktop/modules/deckit/Modules.js4
-rw-r--r--desktop/modules/fonts/Fonts.js35
-rw-r--r--desktop/modules/fonts/FontsModule.qml5
-rw-r--r--desktop/modules/fonts/FontsPage.qml71
-rw-r--r--desktop/modules/fonts/README.md10
-rw-r--r--desktop/modules/fonts/test_fonts.js13
-rw-r--r--desktop/modules/island/IslandCalendarModule.qml76
-rw-r--r--desktop/modules/island/IslandClockModule.qml247
-rw-r--r--desktop/modules/island/IslandPillsModule.qml140
-rw-r--r--desktop/modules/perf/Perf.js18
-rw-r--r--desktop/modules/perf/Perf.qml22
-rw-r--r--desktop/modules/perf/PerfPanel.qml30
-rw-r--r--desktop/modules/perf/README.md10
-rwxr-xr-xdesktop/modules/perf/gpu.sh (renamed from desktop/modules/perf/vram.sh)21
-rwxr-xr-xdesktop/modules/perf/test_gpu.sh (renamed from desktop/modules/perf/test_vram.sh)16
-rw-r--r--desktop/modules/perf/test_perf.js9
-rw-r--r--desktop/modules/sound/Player.qml37
17 files changed, 720 insertions, 44 deletions
diff --git a/desktop/modules/deckit/Modules.js b/desktop/modules/deckit/Modules.js
index 7bfbdbc..853f74f 100644
--- a/desktop/modules/deckit/Modules.js
+++ b/desktop/modules/deckit/Modules.js
@@ -14,10 +14,10 @@
// deck-it's [modules] split for the pages: the ones with a tab of their own,
// and the rest, which only feed the Dashboard. A module deck-it adds later
// lands with the Dashboard ones until it is listed here.
-var TABS = ["windows", "obs", "k1c", "assistant"];
+var TABS = ["windows", "obs", "k1c", "assistant", "vm"];
var NAMES = { stats: "System", music: "Music", llm: "LLM usage", tablet: "Tablet",
sbbuilder: "Build VM", actions: "Action icons", windows: "Windows",
- obs: "OBS", k1c: "K1C printer", assistant: "Assistant" };
+ obs: "OBS", k1c: "K1C printer", assistant: "Assistant", vm: "VMs" };
function tabs(all) { return all.filter(m => TABS.includes(m)); }
function parts(all) { return all.filter(m => !TABS.includes(m)); }
diff --git a/desktop/modules/fonts/Fonts.js b/desktop/modules/fonts/Fonts.js
index 5b7d303..d42c784 100644
--- a/desktop/modules/fonts/Fonts.js
+++ b/desktop/modules/fonts/Fonts.js
@@ -12,9 +12,10 @@
// Pure helpers for the fonts page, tested by test_fonts.js under node.
//
-// The model is fonts.json: {base, override}. base is one pixel size for the
-// whole desktop; override maps a system ("qt") or one entry of a section
-// ("rofi:kf-launcher-entry") to its own pixel size. Everything is stored in
+// The model is fonts.json: {base, override, family}. base is one pixel size
+// for the whole desktop; override maps a system ("qt") or one entry of a
+// section ("rofi:kf-launcher-entry") to its own pixel size; family maps a
+// font slot no other config holds (FAMILIES) to an installed family. Everything is stored in
// px and converted where a system wants points: at scale 1 Wayland's logical
// DPI is 96 (gtk-xft-dpi reads 98304, 96 * 1024), so px = pt * 96 / 72.
@@ -30,6 +31,14 @@ const SYSTEMS = [
{ id: "gtk", label: "GTK", unit: "pt", where: "gtk-3.0 and gtk-4.0 settings.ini, .gtkrc-2.0, gsettings", when: "at once for GTK 3 and 4" },
{ id: "kitty", label: "kitty", unit: "pt", where: "kitty.conf, through an include", when: "at once" },
{ id: "groupbar", label: "Hyprland groupbar", unit: "px", where: "keystone.lua, group:groupbar:font_size", when: "at once" },
+ { id: "deckit", label: "deck-it", unit: "px", where: "deck-it's theme.css, from fonts.json", when: "on the tablet within 5 s" },
+];
+
+// deck-it's dim cover clock, sized from deck-it's text as deck.css designs
+// it (8rem, 1.6rem); an override is "deckit:clock" or "deckit:date".
+const DECKIT_CLOCK = [
+ { id: "clock", label: "Clock time", ratio: 8 },
+ { id: "date", label: "Clock date", ratio: 1.6 },
];
// A section is a set of designed sizes that scale together: rofi's fonts,
@@ -40,6 +49,12 @@ const SECTIONS = [
{ id: "hyprlock", label: "hyprlock", unit: "pt", when: "next lock" },
];
+// Font families set here, read by their program from fonts.json itself.
+const FAMILIES = [
+ { id: "deckit-clock", label: "deck-it clock", where: "the time on the tablet's dim cover" },
+ { id: "deckit-date", label: "deck-it date", where: "the date under it" },
+];
+
// A system's or a section's size in px.
function size(m, id) {
const o = m.override[id];
@@ -62,13 +77,21 @@ function withOverride(m, id, px) {
const o = {};
for (const k in m.override) if (k !== id) o[k] = m.override[k];
if (px !== null) o[id] = px;
- return { base: m.base, override: o };
+ return { base: m.base, override: o, family: m.family };
+}
+
+// The model with family id set to name, or unset when name is empty.
+function withFamily(m, id, name) {
+ const f = {};
+ for (const k in m.family) if (k !== id) f[k] = m.family[k];
+ if (name.trim() !== "") f[id] = name.trim();
+ return { base: m.base, override: m.override, family: f };
}
function parseModel(text) {
try {
const j = JSON.parse(text);
- if (typeof j.base === "number") return { base: j.base, override: j.override || {} };
+ if (typeof j.base === "number") return { base: j.base, override: j.override || {}, family: j.family || {} };
} catch (e) {}
return null;
}
@@ -78,7 +101,7 @@ function parseModel(text) {
// from it is an override at its current size. Kept to 0.01px: at 0.1, an
// 11pt body stored as 14.7px scaled rofi's 72pt glyph to 72.2.
function seed(now) {
- const m = { base: 16, override: {} };
+ const m = { base: 16, override: {}, family: {} };
for (const id in now) if (now[id] !== null && Math.abs(now[id] - 16) > 0.05) m.override[id] = Math.round(now[id] * 100) / 100;
return m;
}
diff --git a/desktop/modules/fonts/FontsModule.qml b/desktop/modules/fonts/FontsModule.qml
index 016d85d..76f6ae9 100644
--- a/desktop/modules/fonts/FontsModule.qml
+++ b/desktop/modules/fonts/FontsModule.qml
@@ -33,7 +33,7 @@ Module {
settings: true
group: "Appearance"
dirty: fm.touched
- keywords: ["font", "size", "text", "px", "pt", "qt6ct", "gtk", "kitty", "rofi", "hyprlock", "groupbar", "scale"]
+ keywords: ["font", "size", "text", "px", "pt", "qt6ct", "gtk", "kitty", "rofi", "hyprlock", "groupbar", "scale", "family", "deck-it", "clock", "date", "tablet"]
readonly property string home: Quickshell.env("HOME")
readonly property string config: Quickshell.env("XDG_CONFIG_HOME") || fm.home + "/.config"
@@ -76,7 +76,7 @@ Module {
}
readonly property var saved: { fm.version; return F.parseModel(fm.texts.model ?? "") ?? F.seed(fm.now()); }
- property var draft: ({ base: 16, override: {} })
+ property var draft: ({ base: 16, override: {}, family: {} })
// A reload replaces the draft only while it holds no edits.
onSavedChanged: if (!fm.touched) fm.draft = fm.saved
property bool touched: false
@@ -85,6 +85,7 @@ Module {
function setBase(px) { fm.touched = true; fm.draft = { base: px, override: fm.draft.override }; }
function setOverride(id, px) { fm.touched = true; fm.draft = F.withOverride(fm.draft, id, px); }
+ function setFamily(id, name) { fm.touched = true; fm.draft = F.withFamily(fm.draft, id, name); }
function discard() { fm.touched = false; fm.draft = fm.saved; fm.error = ""; }
function refresh() {
diff --git a/desktop/modules/fonts/FontsPage.qml b/desktop/modules/fonts/FontsPage.qml
index fd2e672..1a58b11 100644
--- a/desktop/modules/fonts/FontsPage.qml
+++ b/desktop/modules/fonts/FontsPage.qml
@@ -11,6 +11,7 @@
import QtQuick
import "../.."
+import "../appearance" as A
import "Fonts.js" as F
// The base size, then a row per system and per section entry: what it is,
@@ -27,9 +28,9 @@ Column {
spacing: 8
- function clamp(px) { return Math.max(page.minPx, Math.min(page.maxPx, px)); }
+ function clamp(px, max) { return Math.max(page.minPx, Math.min(max, px)); }
// A step of 1 in the row's own unit, so a pt row moves by whole points.
- function step(px, unit, d) { return page.clamp(unit === "pt" ? F.toPx(Math.round(F.toPt(px)) + d) : Math.round(px) + d); }
+ function step(px, unit, d, max) { return page.clamp(unit === "pt" ? F.toPx(Math.round(F.toPt(px)) + d) : Math.round(px) + d, max); }
component Small: Text {
color: Theme.subtext
@@ -60,13 +61,14 @@ Column {
property real px: 16
property string unit: "px"
property bool enabled: true
+ property real max: page.maxPx
signal changed(real px)
spacing: 6
opacity: st.enabled ? 1 : 0.45
- Button { text: "−"; enabled: st.enabled; onClicked: st.changed(page.step(st.px, st.unit, -1)) }
+ Button { text: "−"; enabled: st.enabled; onClicked: st.changed(page.step(st.px, st.unit, -1, st.max)) }
Unit { text: F.round(st.px) + " px"; own: st.unit === "px" }
Unit { text: F.round(F.toPt(st.px)) + " pt"; own: st.unit === "pt" }
- Button { text: "+"; enabled: st.enabled; onClicked: st.changed(page.step(st.px, st.unit, 1)) }
+ Button { text: "+"; enabled: st.enabled; onClicked: st.changed(page.step(st.px, st.unit, 1, st.max)) }
}
// A system or a section entry. id is its override key; inherited is the
@@ -79,6 +81,7 @@ Column {
property string unit: "px"
required property real inherited
property string follows: "base"
+ property real max: page.maxPx
readonly property bool own: page.m.override[sr.key] !== undefined
readonly property real px: sr.own ? page.m.override[sr.key] : sr.inherited
objectName: "font:" + sr.key
@@ -116,6 +119,7 @@ Column {
anchors.verticalCenter: parent.verticalCenter
px: sr.px
unit: sr.unit
+ max: sr.max
enabled: sr.own
onChanged: px => page.fonts.setOverride(sr.key, px)
}
@@ -147,7 +151,7 @@ Column {
Heading { text: "Systems" }
Repeater {
- model: F.SYSTEMS.filter(s => s.id !== "groupbar")
+ model: F.SYSTEMS.filter(s => s.id !== "groupbar" && s.id !== "deckit")
SizeRow {
required property var modelData
key: modelData.id
@@ -166,6 +170,26 @@ Column {
inherited: page.m.base
}
+ Heading { text: "deck-it" }
+ SizeRow {
+ key: "deckit"
+ title: "deck-it text"
+ detail: "The tablet page's rem. deck-it reads fonts.json itself; seen on the tablet within 5 s."
+ inherited: page.m.base
+ }
+ Repeater {
+ model: F.DECKIT_CLOCK
+ SizeRow {
+ required property var modelData
+ key: "deckit:" + modelData.id
+ title: modelData.label
+ detail: "On the dim cover, designed at " + modelData.ratio + "× deck-it's text."
+ follows: "deck-it"
+ max: 400
+ inherited: F.size(page.m, "deckit") * modelData.ratio
+ }
+ }
+
// rofi and hyprlock: the section's size, which is its body text, then
// each entry at its designed ratio to the body.
Repeater {
@@ -209,4 +233,41 @@ Column {
}
}
}
+
+ // Families no other config holds; the program reads fonts.json itself.
+ Heading { text: "Families" }
+ Small {
+ x: 8
+ width: parent.width - 16
+ text: "A family installed on this PC, as fc-list names it. Empty keeps the program's own font."
+ }
+ Repeater {
+ model: F.FAMILIES
+ Item {
+ id: fr
+ required property var modelData
+ objectName: "font:" + fr.modelData.id
+ width: page.width
+ height: 48
+ Column {
+ anchors { left: parent.left; leftMargin: 8; right: field.left; rightMargin: 12; verticalCenter: parent.verticalCenter }
+ Text {
+ text: fr.modelData.label
+ color: Theme.text
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2 }
+ }
+ Small { width: parent.width; text: fr.modelData.where }
+ }
+ A.Field {
+ id: field
+ anchors { right: parent.right; rightMargin: 8; verticalCenter: parent.verticalCenter }
+ width: 240
+ value: page.m.family[fr.modelData.id] ?? ""
+ placeholder: "program's font"
+ // Every keystroke, not editingFinished: a click on Save takes no
+ // focus, so a name typed and saved would never reach the draft.
+ onValueChanged: if (value.trim() !== (page.m.family[fr.modelData.id] ?? "")) page.fonts.setFamily(fr.modelData.id, value)
+ }
+ }
+ }
}
diff --git a/desktop/modules/fonts/README.md b/desktop/modules/fonts/README.md
index b887060..c3e2232 100644
--- a/desktop/modules/fonts/README.md
+++ b/desktop/modules/fonts/README.md
@@ -4,7 +4,8 @@ One pixel size for the desktop, in the settings window under Appearance >
Fonts, and an override wherever a system needs its own. Saved as
`~/.config/keystone/fonts.json`:
- { "base": 16, "override": { "qt": 18.67, "rofi:kf-launcher-entry": 22 } }
+ { "base": 16, "override": { "qt": 18.67, "rofi:kf-launcher-entry": 22 },
+ "family": { "deckit-clock": "Some Font" } }
Everything is stored in px. At scale 1 Wayland's logical DPI is 96
(`gtk-xft-dpi` reads 98304, 96 * 1024), so a point is 4/3 of a pixel and
@@ -17,6 +18,7 @@ Everything is stored in px. At scale 1 Wayland's logical DPI is 96
| GTK | gtk-3.0 and gtk-4.0 `settings.ini`, `.gtkrc-2.0`, gsettings `font-name` | pt | at once for GTK 3 and 4 |
| kitty | `~/.config/keystone/kitty-fonts.conf`, included last by `kitty.conf`; SIGUSR1 reloads | pt | at once |
| Hyprland groupbar | `group:groupbar:font_size` line in `keystone.lua` | px | at once |
+| deck-it | reads `fonts.json` itself into its `theme.css`: `deckit`, and the dim cover's `deckit:clock` and `deckit:date` (8 and 1.6 times `deckit` unless set) | px | on the tablet within 5 s |
| rofi | `~/.config/keystone/rofi-fonts.rasi`, imported by udt's `common.rasi` | pt | next open |
| hyprlock | `~/.config/keystone/hyprlock-fonts.conf`, sourced by `hyprlock.conf` | pt | next lock |
@@ -39,7 +41,11 @@ With no `fonts.json`, the page starts from what the files say: base 16 px,
and an override for every system at its current size, so the first save
changes nothing.
-Not handled: font families; the hard-coded `pixelSize` values in the shells
+`family` names a font for a slot no other config holds, read by its
+program from `fonts.json` itself: `deckit-clock` and `deckit-date`, the
+time and the date on deck-it's dim cover. Empty leaves the program's own.
+
+Not handled: the families of the systems above; the hard-coded `pixelSize` values in the shells
(21 of them), which do not follow `Theme.fontSize`; and a `keystone.lua`
save from this page and the Options page at the same moment, which can drop
one line.
diff --git a/desktop/modules/fonts/test_fonts.js b/desktop/modules/fonts/test_fonts.js
index 947bd42..773da64 100644
--- a/desktop/modules/fonts/test_fonts.js
+++ b/desktop/modules/fonts/test_fonts.js
@@ -17,7 +17,7 @@ const fs = require("fs");
const assert = require("assert");
const src = fs.readFileSync(__dirname + "/Fonts.js", "utf8").replace(/^\.pragma library$/m, "");
-const F = new Function(src + "\nreturn { size, entryPx, withOverride, parseModel, seed, qtPt, gtkPt, kittyPt, "
+const F = new Function(src + "\nreturn { DECKIT_CLOCK, size, entryPx, withOverride, withFamily, parseModel, seed, qtPt, gtkPt, kittyPt, "
+ "rofiEntries, hyprlockEntries, setQt, setGtk, gtkFamily, kittyFile, rofiFile, hyprlockFile };")();
const qt = '[Fonts]\nfixed="Inconsolata Nerd Font Mono,14,-1,5,400"\ngeneral="Noto Sans,14,-1,5,400,Regular"\n';
@@ -36,11 +36,16 @@ assert.strictEqual(F.setGtk(gtk2, 12), 'gtk-font-name="Noto Sans, 12"\n');
// The first save changes nothing: what differs from 16px is an override.
const m = F.seed({ quickshell: 16, qt: 14 * 4 / 3, gtk: 10 * 4 / 3, kitty: 20 });
-assert.deepStrictEqual(m, { base: 16, override: { qt: 18.67, gtk: 13.33, kitty: 20 } });
+assert.deepStrictEqual(m, { base: 16, override: { qt: 18.67, gtk: 13.33, kitty: 20 }, family: {} });
assert.strictEqual(F.size(m, "quickshell"), 16);
assert.strictEqual(F.size(F.withOverride(m, "qt", null), "qt"), 16);
assert.strictEqual(F.parseModel("nope"), null);
assert.deepStrictEqual(F.parseModel(JSON.stringify(m)), m);
+// A family survives a size edit; an empty one is dropped.
+const fm = F.withOverride(F.withFamily(m, "deckit-date", " Sedgwick Ave "), "qt", 20);
+assert.deepStrictEqual(fm.family, { "deckit-date": "Sedgwick Ave" });
+assert.deepStrictEqual(F.withFamily(fm, "deckit-date", "").family, {});
+assert.deepStrictEqual(F.parseModel('{"base": 16}').family, {});
const rasi = ['* { font: var(kf-common-font, "Noto Sans 11"); }',
'entry { font: var(kf-launcher-entry, "Noto Sans Bold 15"); }',
@@ -64,4 +69,8 @@ const sr = F.seed({ rofi: 11 * 4 / 3 });
assert.ok(F.rofiFile(sr, [{ name: "kf-a", family: "M", pt: 11 }, { name: "kf-b", family: "M", pt: 72 }]).includes('kf-b: "M 72"'));
assert.strictEqual(F.kittyFile(m).split("\n")[1], "font_size 15");
+// The clock follows deck-it's text at its designed ratio.
+const d = { base: 16, override: { deckit: 20 }, family: {} };
+assert.strictEqual(F.size(d, "deckit") * F.DECKIT_CLOCK[0].ratio, 160);
+
console.log("ok");
diff --git a/desktop/modules/island/IslandCalendarModule.qml b/desktop/modules/island/IslandCalendarModule.qml
new file mode 100644
index 0000000..a029276
--- /dev/null
+++ b/desktop/modules/island/IslandCalendarModule.qml
@@ -0,0 +1,76 @@
+// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+import QtQuick
+import "../.."
+import "../appearance"
+
+// The island bar's settings group, starting with the calendar's.
+Module {
+ id: mod
+ name: "island-calendar"
+ label: "Calendar"
+ // nf-md-calendar, present in Inconsolata Nerd Font.
+ icon: "\u{f00ed}"
+ settings: true
+ group: "Island bar"
+ keywords: ["island", "calendar", "event", "length", "duration", "end time"]
+ searchItems: [{ text: "Default event length", key: "eventMinutes" }]
+
+ // The draft, as typed; dirty while it differs from what is saved.
+ property string draft: String(Prefs.island.eventMinutes)
+ readonly property bool valid: /^\d+$/.test(draft) && +draft >= 5 && +draft <= 1440
+ dirty: draft !== String(Prefs.island.eventMinutes)
+ function refresh() { if (!mod.dirty) mod.draft = String(Prefs.island.eventMinutes); }
+
+ page: Component {
+ Page {
+ title: "Calendar"
+ actions: Component {
+ SaveBar {
+ dirty: mod.dirty; valid: mod.valid
+ error: mod.valid ? "" : "Length is 5 to 1440 minutes."
+ onSave: Prefs.setIsland({ eventMinutes: +mod.draft })
+ onDiscard: mod.draft = String(Prefs.island.eventMinutes)
+ }
+ }
+ Column {
+ objectName: "eventMinutes"
+ width: parent.width
+ spacing: 8
+ Text {
+ width: parent.width
+ wrapMode: Text.WordWrap
+ text: "A new event gets this length, and its end keeps it when the start moves."
+ color: Theme.overlay
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
+ }
+ Row {
+ spacing: 8
+ Text {
+ anchors.verticalCenter: parent.verticalCenter
+ text: "Default event length"
+ color: Theme.subtext
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 3 }
+ }
+ // Read on every change: a click on Save ends no editing.
+ Field { width: 60; value: mod.draft; onValueChanged: mod.draft = value }
+ Text {
+ anchors.verticalCenter: parent.verticalCenter
+ text: "minutes"
+ color: Theme.subtext
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 3 }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/desktop/modules/island/IslandClockModule.qml b/desktop/modules/island/IslandClockModule.qml
new file mode 100644
index 0000000..ef8c204
--- /dev/null
+++ b/desktop/modules/island/IslandClockModule.qml
@@ -0,0 +1,247 @@
+// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+import Quickshell
+import QtQuick
+import "../.."
+import "../appearance"
+import "../../island/calendar/Cal.js" as Cal
+
+// How the island shows time and dates: the clock pill, the calendar's day
+// headings, agenda times and hour picker.
+Module {
+ id: mod
+ name: "island-clock"
+ label: "Date and time"
+ // nf-md-clock_outline, present in Inconsolata Nerd Font.
+ icon: "\u{f0150}"
+ settings: true
+ group: "Island bar"
+ keywords: ["island", "clock", "time", "date", "format", "12-hour", "24-hour", "am", "pm", "day", "month"]
+ searchItems: [{ text: "Clock", key: "h12" }, { text: "Date format", key: "dateFormat" }]
+
+ property bool h12: Prefs.island.h12
+ property string dateFormat: Prefs.island.dateFormat
+ dirty: h12 !== Prefs.island.h12 || dateFormat !== Prefs.island.dateFormat
+ function refresh() { if (!mod.dirty) mod.discard(); }
+ function discard() { mod.h12 = Prefs.island.h12; mod.dateFormat = Prefs.island.dateFormat; }
+
+ page: Component {
+ Page {
+ title: "Date and time"
+ actions: Component {
+ SaveBar {
+ dirty: mod.dirty
+ onSave: Prefs.setIsland({ h12: mod.h12, dateFormat: mod.dateFormat })
+ onDiscard: mod.discard()
+ }
+ }
+ Flow {
+ id: body
+ width: parent.width
+ spacing: 32
+ SystemClock { id: now; precision: SystemClock.Minutes }
+ readonly property string today: Cal.today(now.date)
+ // Two made-up events today, one each side of noon.
+ readonly property var events: [
+ { title: "Standup", allDay: false, start: today + "T09:30", end: today + "T10:00", color: "blue" },
+ { title: "Dinner", allDay: false, start: today + "T20:30", end: today + "T22:00", color: "green" }]
+
+ Column {
+ id: controls
+ width: 3 * 120 + 2 * 12
+ spacing: 6
+
+ Heading { text: "Clock" }
+ Hint { text: "The clock pill, the agenda and the hour picker. Event times can also be typed with am and pm (9.30pm)." }
+ Row {
+ objectName: "h12"
+ spacing: 6
+ Tab { text: "24-hour"; selected: !mod.h12; onClicked: mod.h12 = false }
+ Tab { text: "12-hour"; selected: mod.h12; onClicked: mod.h12 = true }
+ }
+
+ Item { width: 1; height: 14 }
+ Heading { text: "Date" }
+ Hint { text: "The clock pill. The calendar spells the month out, in the same order." }
+ Row {
+ objectName: "dateFormat"
+ spacing: 12
+ Repeater {
+ model: Cal.DATE_GROUPS
+ delegate: Column {
+ required property var modelData
+ width: 120
+ spacing: 2
+ Text {
+ text: modelData.title
+ color: Theme.subtext
+ bottomPadding: 4
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
+ }
+ Repeater {
+ model: modelData.formats
+ delegate: Rectangle {
+ required property string modelData
+ readonly property bool on: mod.dateFormat === modelData
+ width: 120
+ height: 26
+ radius: 6
+ color: on ? Qt.alpha(Theme.accent, 0.25)
+ : pick.containsMouse ? Qt.alpha(Theme.surface, 0.8) : "transparent"
+ border.width: on ? 1 : 0
+ border.color: Qt.alpha(Theme.accent, 0.5)
+ Text {
+ anchors { left: parent.left; leftMargin: 8; verticalCenter: parent.verticalCenter }
+ text: Qt.formatDate(now.date, parent.modelData)
+ color: parent.on ? Theme.text : Theme.subtext
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 3 }
+ }
+ MouseArea {
+ id: pick
+ anchors.fill: parent
+ hoverEnabled: true
+ cursorShape: Qt.PointingHandCursor
+ onClicked: mod.dateFormat = parent.modelData
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Beside the controls when there is room, below them when not.
+ Column {
+ width: Math.max(220, Math.min(400, body.width - controls.width - body.spacing))
+ spacing: 6
+ Heading { text: "Preview" }
+ Hint { text: "With the unsaved choice." }
+ // A mock of the island: the clock pill at rest, and the
+ // calendar panel's heading, agenda and hour picker below it.
+ Rectangle {
+ width: parent.width
+ height: mock.implicitHeight + 32
+ radius: 12
+ color: Qt.alpha(Theme.surface, 0.35)
+
+ Column {
+ id: mock
+ anchors { fill: parent; margins: 16 }
+ spacing: 14
+
+ Rectangle {
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: pillRow.implicitWidth + 28
+ height: 34
+ radius: 17
+ color: Qt.alpha(Theme.base, 0.92)
+ border.width: 1
+ border.color: Qt.alpha(Theme.text, 0.12)
+ Row {
+ id: pillRow
+ anchors.centerIn: parent
+ spacing: 10
+ Text {
+ anchors.verticalCenter: parent.verticalCenter
+ text: Qt.formatDateTime(now.date, Cal.shortDateFmt(mod.dateFormat))
+ color: Theme.subtext
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2 }
+ }
+ Text {
+ anchors.verticalCenter: parent.verticalCenter
+ text: Qt.formatDateTime(now.date, Cal.timeFmt(mod.h12))
+ color: Theme.text
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize; weight: Font.DemiBold }
+ }
+ }
+ }
+
+ Rectangle {
+ width: parent.width
+ height: panelCol.implicitHeight + 24
+ radius: 17
+ color: Qt.alpha(Theme.base, 0.92)
+ border.width: 1
+ border.color: Qt.alpha(Theme.text, 0.12)
+ Column {
+ id: panelCol
+ anchors { fill: parent; margins: 12 }
+ spacing: 6
+ Text {
+ text: Qt.formatDate(now.date, Cal.dayFmt(mod.dateFormat, true))
+ color: Theme.text
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2; bold: true }
+ }
+ Repeater {
+ model: body.events
+ delegate: Row {
+ required property var modelData
+ spacing: 8
+ Rectangle { width: 3; height: 16; radius: 1; color: Theme[modelData.color] }
+ Text {
+ width: mod.h12 ? 92 : 82
+ text: Cal.timeLabel(modelData, body.today, mod.h12)
+ color: Theme.subtext
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 5 }
+ }
+ Text {
+ text: modelData.title
+ color: Theme.text
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
+ }
+ }
+ }
+ Text {
+ text: "When " + Qt.formatDate(now.date, Cal.dayFmt(mod.dateFormat, false))
+ color: Theme.subtext
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
+ }
+ Row {
+ spacing: 2
+ Repeater {
+ model: [8, 9, 10, 11, 12]
+ delegate: Rectangle {
+ required property int modelData
+ width: 34
+ height: 26
+ radius: 6
+ color: modelData === 9 ? Qt.alpha(Theme.accent, 0.35) : "transparent"
+ Text {
+ anchors.centerIn: parent
+ text: Cal.hourLabel(parent.modelData, mod.h12)
+ color: Theme.text
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ component Heading: Text {
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 3; bold: true }
+ color: Theme.text
+ }
+
+ component Hint: Text {
+ width: parent ? parent.width : 0
+ wrapMode: Text.WordWrap
+ color: Theme.overlay
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
+ }
+}
diff --git a/desktop/modules/island/IslandPillsModule.qml b/desktop/modules/island/IslandPillsModule.qml
new file mode 100644
index 0000000..4a3e09d
--- /dev/null
+++ b/desktop/modules/island/IslandPillsModule.qml
@@ -0,0 +1,140 @@
+// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+import QtQuick
+import "../.."
+
+// The order of the island's pills, dragged into place.
+Module {
+ id: mod
+ name: "island-pills"
+ label: "Pills"
+ // nf-md-view_column, present in Inconsolata Nerd Font.
+ icon: "\u{f056d}"
+ settings: true
+ group: "Island bar"
+ keywords: ["island", "pills", "order", "layout", "clock", "player", "status", "obs"]
+ searchItems: [{ text: "Pill order", key: "pills" }]
+
+ readonly property var names: ({ media: "Player", clock: "Clock", status: "Status", obs: "OBS" })
+ property var draft: Prefs.island.pills
+ dirty: JSON.stringify(draft) !== JSON.stringify(Prefs.island.pills)
+ function refresh() { if (!mod.dirty) mod.draft = Prefs.island.pills; }
+ function moveTo(from, to) {
+ const d = mod.draft.slice();
+ d.splice(to, 0, d.splice(from, 1)[0]);
+ mod.draft = d;
+ }
+
+ page: Component {
+ Page {
+ title: "Pills"
+ actions: Component {
+ SaveBar {
+ dirty: mod.dirty
+ onSave: Prefs.setIsland({ pills: mod.draft })
+ onDiscard: mod.draft = Prefs.island.pills
+ }
+ }
+ Column {
+ objectName: "pills"
+ width: parent.width
+ spacing: 8
+ Text {
+ width: parent.width
+ wrapMode: Text.WordWrap
+ text: "Drag to reorder, left to right; the bar marks the screen's centre. Player shows only while something plays, OBS only while it runs."
+ color: Theme.overlay
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
+ }
+ // Fixed slots, the centre bar between the second and third.
+ // A dropped pill takes the slot nearest where it lands.
+ Item {
+ id: strip
+ readonly property real slot: 96
+ readonly property real mid: 24
+ function slotX(i) { return i * slot + (i >= 2 ? mid : 0); }
+ // While a pill is dragged: where it came from and the slot
+ // it would land in; the others step aside for it.
+ property int from: -1
+ property int to: -1
+ function nearest(x) {
+ let to = 0;
+ for (let j = 1; j < 4; j++)
+ if (Math.abs(slotX(j) - x) < Math.abs(slotX(to) - x)) to = j;
+ return to;
+ }
+ function shown(i) {
+ if (from < 0 || i === from) return i;
+ if (from < to && i > from && i <= to) return i - 1;
+ if (to < from && i >= to && i < from) return i + 1;
+ return i;
+ }
+ width: slotX(4)
+ height: 32
+
+ Text {
+ x: strip.slotX(2) - strip.mid
+ width: strip.mid
+ anchors.verticalCenter: parent.verticalCenter
+ horizontalAlignment: Text.AlignHCenter
+ text: "|"
+ color: Theme.accent
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize }
+ }
+
+ Repeater {
+ model: mod.draft
+ delegate: Rectangle {
+ id: pill
+ required property string modelData
+ required property int index
+ x: strip.slotX(strip.shown(index))
+ Behavior on x {
+ enabled: !grab.drag.active
+ NumberAnimation { duration: 150; easing.type: Easing.OutCubic }
+ }
+ z: grab.drag.active ? 1 : 0
+ width: strip.slot - 6
+ height: strip.height
+ radius: 7
+ color: grab.drag.active ? Qt.alpha(Theme.accent, 0.4) : Qt.alpha(Theme.accent, 0.25)
+ border.width: 1
+ border.color: Qt.alpha(Theme.accent, 0.5)
+ Text {
+ anchors.centerIn: parent
+ text: mod.names[pill.modelData]
+ color: Theme.text
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2 }
+ }
+ MouseArea {
+ id: grab
+ anchors.fill: parent
+ preventStealing: true
+ cursorShape: grab.drag.active ? Qt.ClosedHandCursor : Qt.OpenHandCursor
+ drag { target: pill; axis: Drag.XAxis; minimumX: 0; maximumX: strip.slotX(3) }
+ onPressed: { strip.from = pill.index; strip.to = pill.index; }
+ onPositionChanged: if (grab.drag.active) strip.to = strip.nearest(pill.x)
+ onReleased: {
+ const from = strip.from, to = strip.nearest(pill.x);
+ strip.from = -1;
+ // A move rebuilds the delegates; staying put needs the binding back.
+ if (to !== from) mod.moveTo(from, to);
+ else pill.x = Qt.binding(() => strip.slotX(strip.shown(pill.index)));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/desktop/modules/perf/Perf.js b/desktop/modules/perf/Perf.js
index eb0dbd7..b94e5b6 100644
--- a/desktop/modules/perf/Perf.js
+++ b/desktop/modules/perf/Perf.js
@@ -44,6 +44,24 @@ function load(prev, cur) {
return Math.max(0, Math.min(100, 100 * (1 - (cur.idle - prev.idle) / dt)));
}
+// gpu.sh's line as numbers: [vram, rcs busy, rcs clock, ccs busy, ccs clock],
+// null when it printed nothing.
+function gpuSample(text) {
+ const n = text.trim().split(/\s+/).map(Number);
+ return n.length === 5 && n.every(Number.isFinite) ? n : null;
+}
+
+// {render, compute} percent busy between two gpuSample()s, each null when
+// its clock did not move. A client exiting mid-sample takes its cycles with
+// it, so a dip below zero is clamped.
+function gpuLoad(prev, cur) {
+ const pct = (b, c) => {
+ if (!prev || !cur || cur[c] <= prev[c]) return null;
+ return Math.max(0, Math.min(100, 100 * (cur[b] - prev[b]) / (cur[c] - prev[c])));
+ };
+ return { render: pct(1, 2), compute: pct(3, 4) };
+}
+
// {total, used} in bytes; used is MemTotal - MemAvailable.
function meminfo(text) {
const kb = key => {
diff --git a/desktop/modules/perf/Perf.qml b/desktop/modules/perf/Perf.qml
index 5fcf0ab..33b5cbc 100644
--- a/desktop/modules/perf/Perf.qml
+++ b/desktop/modules/perf/Perf.qml
@@ -56,6 +56,9 @@ Singleton {
property var temps: [] // [{label, value, warn, crit}], value null if unread
property var disks: [] // Perf.js df rows
property var vram: null // bytes
+ property var gpu: null // gpuSample, the last scan
+ property var gpuRender: null // percent, rcs
+ property var gpuCompute: null // percent, ccs
property var fan: null // rpm
property var rx: [] // bytes/s, newest last
property var tx: []
@@ -181,18 +184,27 @@ Singleton {
root.temps = t;
if (fanView.path) { fanView.reload(); root.fan = root.num(fanView); }
- if (!vramProc.running) vramProc.running = true;
+ if (!gpuProc.running) gpuProc.running = true;
}
}
// ponytail: a shell glob over every fd on the system, ~14ms every 2s,
// always; gate it on the panel again if that shows up. Only the user's own processes are readable, so a
// system service's GPU use is not counted, as in conky.
- // Summed in vram.sh, so JS gets one number, never the scan itself.
+ // Summed in gpu.sh, so JS gets five numbers, never the scan itself.
Process {
- id: vramProc
- command: ["sh", `${Quickshell.shellDir}/modules/perf/vram.sh`]
- stdout: StdioCollector { onStreamFinished: root.vram = text.trim() === "" ? null : Number(text) }
+ id: gpuProc
+ command: ["sh", `${Quickshell.shellDir}/modules/perf/gpu.sh`]
+ stdout: StdioCollector {
+ onStreamFinished: {
+ const cur = P.gpuSample(text);
+ const l = P.gpuLoad(root.gpu, cur);
+ root.vram = cur ? cur[0] : null;
+ root.gpuRender = l.render;
+ root.gpuCompute = l.compute;
+ root.gpu = cur;
+ }
+ }
}
// --- network ------------------------------------------------------------
diff --git a/desktop/modules/perf/PerfPanel.qml b/desktop/modules/perf/PerfPanel.qml
index 784284a..8ea4af6 100644
--- a/desktop/modules/perf/PerfPanel.qml
+++ b/desktop/modules/perf/PerfPanel.qml
@@ -320,13 +320,32 @@ Column {
// --- GPU ----------------------------------------------------------------
- // No utilisation: xe exposes no busy percentage.
+ // Busy per engine from fdinfo's cycle counters: render is games, compute
+ // local LLMs; the headline is the busier of the two.
Card {
+ readonly property var busy: Perf.gpuRender === null && Perf.gpuCompute === null ? null
+ : Math.max(Perf.gpuRender ?? 0, Perf.gpuCompute ?? 0)
title: "GPU · " + Perf.gpuName
- headline: panel.deg(panel.gpuTemp.value)
- headlineColor: panel.tone(panel.gpuTemp.value, panel.gpuTemp.warn, panel.gpuTemp.crit)
+ headline: busy === null ? "--" : Math.round(busy) + "%"
+ headlineColor: panel.tone(busy, 25, 75)
Pair {
+ label: "Render"
+ value: Perf.gpuRender === null ? "--" : Math.round(Perf.gpuRender) + "%"
+ }
+ Bar {
+ frac: (Perf.gpuRender ?? 0) / 100
+ fill: panel.tone(Perf.gpuRender, 25, 75)
+ }
+ Pair {
+ label: "Compute"
+ value: Perf.gpuCompute === null ? "--" : Math.round(Perf.gpuCompute) + "%"
+ }
+ Bar {
+ frac: (Perf.gpuCompute ?? 0) / 100
+ fill: panel.tone(Perf.gpuCompute, 25, 75)
+ }
+ Pair {
label: "VRAM"
value: Perf.vram === null ? "--" : P.bytes(Perf.vram) + " / " + P.bytes(Perf.vramTotal)
}
@@ -335,6 +354,11 @@ Column {
fill: panel.tone(panel.pct(Perf.vram, Perf.vramTotal), 25, 75)
}
Pair {
+ label: "Temperature"
+ value: panel.deg(panel.gpuTemp.value)
+ valueColor: panel.tone(panel.gpuTemp.value, panel.gpuTemp.warn, panel.gpuTemp.crit)
+ }
+ Pair {
label: "Fan"
value: Perf.fan === null ? "--" : Perf.fan + " rpm"
}
diff --git a/desktop/modules/perf/README.md b/desktop/modules/perf/README.md
index d5ae0b3..9fdbc6e 100644
--- a/desktop/modules/perf/README.md
+++ b/desktop/modules/perf/README.md
@@ -2,10 +2,12 @@
The figures the conky dashboard used to show, as a drawer page of cards, one
per row; the page scrolls. CPU load with a bar per core, the CPU model and
-RAM; every temperature as a tile; the Arc B580's VRAM and fan (no
-utilisation, xe exposes none); the five mounts with their usage; and
+RAM; every temperature as a tile; the Arc B580's render and compute load
+(games and local LLMs, from fdinfo's cycle counters), VRAM, temperature and
+fan; the five mounts with their usage; and
`~/.cache` with its five largest children. `Perf.qml` reads them; `Perf.js`
-holds the parsing, tested by `node desktop/modules/perf/test_perf.js`.
+holds the parsing, tested by `node desktop/modules/perf/test_perf.js`;
+`gpu.sh` sums the fdinfo scan, tested by `sh desktop/modules/perf/test_gpu.sh`.
The tile shows CPU and RAM, and a dot for the worst of these, yellow or red:
@@ -27,7 +29,7 @@ into the LAN depends on the ISP's fixed address. The fetch is
never a mismatch: the old value goes stale after 4 hours and shows as a dash.
Everything is sampled always, including per-core load, the network rate,
-VRAM (a scan of every fdinfo, ~14ms every 2s) and the fan. The network rate
+GPU load and VRAM (a scan of every fdinfo, ~14ms every 2s) and the fan. The network rate
is drawn by the network page, which reads it from here, so its graph opens
on the last minute of history instead of empty. The mount list, `br0`, the GPU name and the 12 GiB VRAM
size are constants in `Perf.qml`.
diff --git a/desktop/modules/perf/vram.sh b/desktop/modules/perf/gpu.sh
index 83db27d..31f8a6e 100755
--- a/desktop/modules/perf/vram.sh
+++ b/desktop/modules/perf/gpu.sh
@@ -11,10 +11,14 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-# VRAM in bytes from the fdinfo scan: drm-resident-vram0 of every xe fd,
-# counted once per drm-client-id because a client holds several fds. Prints
-# nothing when no xe client is found. With a file argument it reads that
-# instead of scanning, for test_vram.sh.
+# GPU from the fdinfo scan, every xe fd counted once per drm-client-id
+# because a client holds several fds. Prints one line, "vram rcs_busy
+# rcs_clock ccs_busy ccs_clock": VRAM in bytes (drm-resident-vram0), then
+# per engine the busy cycles summed over clients and the GPU's cycle
+# counter, which Perf.js turns into a percentage between two scans. rcs is
+# render (games), ccs compute (local LLMs). Prints nothing when no xe
+# client is found. With a file argument it reads that instead of scanning,
+# for test_gpu.sh.
#
# Summed here rather than in JS: a process holding thousands of DRM fds
# makes the scan a few hundred KB, which is a lot of string churn to parse
@@ -28,6 +32,7 @@
scan() {
if [ -n "$1" ]; then cat "$1"
else grep -sH -e '^drm-driver' -e '^drm-client-id' -e '^drm-resident-vram0' \
+ -e '^drm-cycles-[rc]cs' -e '^drm-total-cycles-[rc]cs' \
/proc/[0-9]*/fdinfo/* 2>/dev/null
fi
}
@@ -45,10 +50,16 @@ scan "$1" | awk -F: '
id = d[p, "drm-client-id"]
if (d[p, "drm-driver"] != "xe" || id == "" || (id in seen)) continue
if (split(d[p, "drm-resident-vram0"], n, " ") < 1 || n[1] !~ /^[0-9]+$/) continue
+ for (i = 1; i <= 2; i++) {
+ e = i == 1 ? "rcs" : "ccs"
+ busy[e] += d[p, "drm-cycles-" e]
+ c = d[p, "drm-total-cycles-" e] + 0
+ if (c > clock[e]) clock[e] = c
+ }
seen[id]
u = n[2] == "KiB" ? 1024 : n[2] == "MiB" ? 1048576 : n[2] == "GiB" ? 1073741824 : 1
total += n[1] * u
any = 1
}
- if (any) printf "%.0f\n", total
+ if (any) printf "%.0f %.0f %.0f %.0f %.0f\n", total, busy["rcs"], clock["rcs"], busy["ccs"], clock["ccs"]
}'
diff --git a/desktop/modules/perf/test_vram.sh b/desktop/modules/perf/test_gpu.sh
index 7ef4ade..8467c74 100755
--- a/desktop/modules/perf/test_vram.sh
+++ b/desktop/modules/perf/test_gpu.sh
@@ -11,8 +11,8 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-# vram.sh: summed once per xe client id, units honoured, other drivers
-# ignored; nothing at all when no xe client is found.
+# gpu.sh: VRAM and engine cycles summed once per xe client id, units
+# honoured, other drivers ignored; nothing at all when no xe client is found.
set -e
dir=$(dirname "$0")
tmp=$(mktemp)
@@ -22,19 +22,25 @@ printf '%s\n' \
"/proc/1/fdinfo/7:drm-driver: xe" \
"/proc/1/fdinfo/7:drm-client-id: 38" \
"/proc/1/fdinfo/7:drm-resident-vram0: 1024 KiB" \
+ "/proc/1/fdinfo/7:drm-cycles-rcs: 30" \
+ "/proc/1/fdinfo/7:drm-total-cycles-rcs: 1000" \
"/proc/1/fdinfo/10:drm-driver: xe" \
"/proc/1/fdinfo/10:drm-client-id: 38" \
"/proc/1/fdinfo/10:drm-resident-vram0: 1024 KiB" \
+ "/proc/1/fdinfo/10:drm-cycles-rcs: 30" \
+ "/proc/1/fdinfo/10:drm-total-cycles-rcs: 1000" \
"/proc/2/fdinfo/5:drm-driver: xe" \
"/proc/2/fdinfo/5:drm-client-id: 40" \
"/proc/2/fdinfo/5:drm-resident-vram0: 2 MiB" \
+ "/proc/2/fdinfo/5:drm-cycles-ccs: 7" \
+ "/proc/2/fdinfo/5:drm-total-cycles-ccs: 900" \
"/proc/3/fdinfo/4:drm-driver: amdgpu" \
"/proc/3/fdinfo/4:drm-client-id: 1" \
"/proc/3/fdinfo/4:drm-resident-vram0: 9 GiB" > "$tmp"
-got=$(sh "$dir/vram.sh" "$tmp")
-[ "$got" = $((1024 * 1024 + 2 * 1024 * 1024)) ] || { echo "vram: got '$got'"; exit 1; }
+got=$(sh "$dir/gpu.sh" "$tmp")
+[ "$got" = "$((1024 * 1024 + 2 * 1024 * 1024)) 30 1000 7 900" ] || { echo "gpu: got '$got'"; exit 1; }
: > "$tmp"
-got=$(sh "$dir/vram.sh" "$tmp")
+got=$(sh "$dir/gpu.sh" "$tmp")
[ -z "$got" ] || { echo "empty: got '$got'"; exit 1; }
echo ok
diff --git a/desktop/modules/perf/test_perf.js b/desktop/modules/perf/test_perf.js
index d5856e8..a1a068d 100644
--- a/desktop/modules/perf/test_perf.js
+++ b/desktop/modules/perf/test_perf.js
@@ -20,7 +20,7 @@ const src = fs.readFileSync(__dirname + "/Perf.js", "utf8")
.replace(/^\.pragma library$/m, "");
const P = new Function(src + "\nreturn { cpuTimes, load, meminfo, df, rate, " +
"hwmonMap, lanAddr, cpuModel, du, band, worst, isIPv4, parsePubip, formatPubip, " +
- "ipCheck, due, push, bytes, speed, procs, sockets, netProcs };")();
+ "ipCheck, due, push, bytes, speed, procs, sockets, netProcs, gpuSample, gpuLoad };")();
// cpuTimes: aggregate first, then cores; idle is idle + iowait.
const stat = [
@@ -183,4 +183,11 @@ assert.deepStrictEqual(P.netProcs([{ key: "a", name: "firefox", rx: 5000, tx: 10
[{ name: "firefox", rx: 3000, tx: 0 }]);
assert.deepStrictEqual(P.netProcs([], later, 0), []);
+
+// gpu.sh: five numbers or nothing; load per engine between two scans.
+assert.strictEqual(P.gpuSample(""), null);
+const g1 = P.gpuSample("100 0 1000 0 1000\n"), g2 = P.gpuSample("100 200 2000 900 2000");
+assert.deepStrictEqual(P.gpuLoad(g1, g2), { render: 20, compute: 90 });
+assert.deepStrictEqual(P.gpuLoad(null, g2), { render: null, compute: null });
+assert.deepStrictEqual(P.gpuLoad(g2, [100, 0, 3000, 0, 2000]), { render: 0, compute: null });
console.log("test_perf: ok");
diff --git a/desktop/modules/sound/Player.qml b/desktop/modules/sound/Player.qml
index e32a1b9..7522d80 100644
--- a/desktop/modules/sound/Player.qml
+++ b/desktop/modules/sound/Player.qml
@@ -12,6 +12,7 @@
pragma Singleton
import Quickshell
+import Quickshell.Io
import Quickshell.Services.Mpris
import QtQuick
@@ -59,6 +60,38 @@ Singleton {
// per track, so the path can repeat while the image behind it changes.
// The cache buster makes Image reload instead of showing the last cover.
readonly property string artUrl:
- (current?.trackArtUrl ?? "") === "" ? ""
- : current.trackArtUrl + "#" + encodeURIComponent(title)
+ (current?.trackArtUrl ?? "") !== ""
+ ? current.trackArtUrl + "#" + encodeURIComponent(title)
+ : (videoUrl !== "" && thumbFor === videoUrl)
+ ? "file://" + thumbPath + "#" + encodeURIComponent(videoUrl) : ""
+
+ // Haruna clears mpris:artUrl for every video on purpose (so the task
+ // manager shows the live window), so a local video with no cover gets a
+ // frame grabbed by ffmpeg instead. One file, overwritten per video; the
+ // URL fragment above makes Image reload it.
+ readonly property string videoUrl: {
+ const url = String(current?.metadata?.["xesam:url"] ?? "");
+ return (current?.trackArtUrl ?? "") === "" && url.startsWith("file://")
+ && /\.(mp4|m4v|mkv|webm|avi|mov|wmv|flv|mpe?g|ts|ogv)$/i.test(url) ? url : "";
+ }
+ readonly property string thumbPath: (Quickshell.env("XDG_RUNTIME_DIR") || "/tmp") + "/qs-video-thumb.jpg"
+ property string thumbFor: ""
+
+ onVideoUrlChanged: grab()
+ Component.onCompleted: grab()
+
+ function grab() {
+ if (videoUrl === "") return;
+ thumb.running = false;
+ thumb.url = videoUrl;
+ thumb.command = ["ffmpeg", "-y", "-v", "error", "-i", decodeURIComponent(videoUrl.slice(7)),
+ "-vf", "thumbnail,scale=480:-2", "-frames:v", "1", thumbPath];
+ thumb.running = true;
+ }
+
+ Process {
+ id: thumb
+ property string url: ""
+ onExited: code => { if (code === 0) root.thumbFor = url; }
+ }
}