Add glassMxrph shell sources

Initial commit of the Quickshell desktop suite: bar, dock, launcher,
settings, Control Center, dashboard, OSD, lock screen, desktop widgets,
plugin host with the vendored Noctalia/Omarchy compatibility layer,
helpers, packaging, tests and phase documentation.

Includes the optimization work so far: usage widgets and dashboard
gauges no longer animate continuously, desktop widgets pause while
covered, system controls stop flickering on background polls, dock app
matching uses an indexed catalog, and workspace ghosts are created only
for occupied slots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mxandClaude Opus 5.5 committed 2026-10-07 22:36:17 +02:00
commit 99e64a7713
433 files changed
+57792

No files matched your search

+75
View File
@@ -0,0 +1,75 @@
pragma ComponentBehavior: Bound
import QtQuick
import Quickshell
import Quickshell.Wayland
import "../components"
import "../services"
import "../theme"
// One desktop widget: its own layer surface on the desktop (Bottom) layer,
// sized and placed from its item (or the live draft while it is edited).
// Right-click opens the widget editor with this widget selected.
// qmllint disable uncreatable-type
PanelWindow {
id: root
required property string modelData
readonly property string widgetId: modelData
readonly property var item: WidgetState.item(widgetId)
readonly property var type: item ? WidgetRegistry.type(item.type) : null
readonly property var geometry: WidgetState.rect(widgetId)
readonly property bool transparentFace: !!item && WidgetRegistry.transparent(item.type, item.variant)
// Kept separate from `screen`, which Quickshell itself assigns on show
// (reading it in `visible` would loop).
readonly property var output: item ? Quickshell.screens.find(s => s.name === item.monitor) || null : null
screen: output
readonly property bool desktopShown: WidgetState.editing || !output || !HyprlandService.coveredMonitors.includes(output.name)
visible: !!item && !!type && !!output
anchors {
top: true
left: true
}
// Margins is present at runtime but unresolved in 0.3.1 qmltypes.
// qmllint disable unqualified unresolved-type
margins {
left: Math.round(root.geometry.x)
top: Math.round(root.geometry.y)
}
// qmllint enable unqualified unresolved-type
implicitWidth: Math.max(1, Math.round(geometry.w))
implicitHeight: Math.max(1, Math.round(geometry.h))
color: Theme.transparent
exclusionMode: ExclusionMode.Ignore
WlrLayershell.layer: WlrLayer.Bottom
WlrLayershell.namespace: "glassMxrph-widget-" + (item ? item.type : "unknown")
WlrLayershell.keyboardFocus: type && type.keyboard ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None
Component.onCompleted: WidgetState.surfaces[widgetId] = content
Component.onDestruction: delete WidgetState.surfaces[widgetId]
Item {
id: content
anchors.fill: parent
opacity: root.item ? root.item.opacity : 1
GlassPanel {
anchors.fill: parent
visible: !root.transparentFace
}
Loader {
id: face
anchors.fill: parent
active: !!root.item && !!root.type
source: root.item ? WidgetRegistry.source(root.item.type) : ""
onLoaded: {
item.widgetId = Qt.binding(() => root.widgetId);
item.kind = Qt.binding(() => root.item ? root.item.type : "");
item.variant = Qt.binding(() => root.item ? root.item.variant : "");
item.options = Qt.binding(() => root.item && root.item.options ? root.item.options : ({}));
item.desktopVisible = Qt.binding(() => root.desktopShown);
}
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.RightButton
onClicked: WidgetState.edit(root.widgetId)
}
}
}
+25
View File
@@ -0,0 +1,25 @@
import QtQuick
import Quickshell
// One surface per configured desktop widget. The model is the list of ids, so
// editing an item updates its existing surface instead of recreating it.
Scope {
id: root
// Widgets are created shortly after startup: building many faces while
// Quickshell 0.3.1 parses its first Hyprland client list makes a crash in
// HyprlandToplevel::updateFromObject far more likely.
property bool started: false
Timer {
running: true
interval: 1500
onTriggered: root.started = true
}
Variants {
model: root.started ? WidgetState.items.filter(i => !!WidgetRegistry.type(i.type)).map(i => i.id) : []
DesktopWidget {}
}
Variants {
model: WidgetState.editing ? Quickshell.screens : []
WidgetEditor {}
}
}
+554
View File
@@ -0,0 +1,554 @@
pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Layouts
import Quickshell
import Quickshell.Wayland
import "../components"
import "../services"
import "../theme"
import "../services/WidgetLogic.js" as Logic
// Desktop widget editor for one output (after Serpantinum's widget redactor):
// drag to move, handles to resize, snapping guides or a grid, a toolbar to add
// widgets and an inspector for the selected one. The real widget surfaces sit
// below and follow every change live.
// qmllint disable uncreatable-type
PanelWindow {
id: root
required property var modelData
screen: modelData
anchors {
top: true
bottom: true
left: true
right: true
}
color: Theme.transparent
exclusionMode: ExclusionMode.Ignore
WlrLayershell.layer: WlrLayer.Overlay
WlrLayershell.namespace: "glassMxrph-widget-editor"
WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
Component.onCompleted: WidgetState.editors = WidgetState.editors.concat([keys])
Component.onDestruction: WidgetState.editors = WidgetState.editors.filter(e => e !== keys)
readonly property var bounds: ({
w: width,
h: height
})
readonly property var onScreen: WidgetState.items.filter(i => i.monitor === screen.name && !!WidgetRegistry.type(i.type))
readonly property var selectedItem: WidgetState.item(WidgetState.selected)
readonly property var selectedType: selectedItem ? WidgetRegistry.type(selectedItem.type) : null
readonly property bool selectionHere: !!selectedItem && selectedItem.monitor === screen.name
readonly property var selectedRect: selectionHere ? WidgetState.rect(selectedItem.id) : null
// Move the toolbar and inspector to the top when they would cover the selection.
readonly property bool chromeOnTop: !!selectedRect && height > 0 && selectedRect.y + selectedRect.h > height - 280
readonly property int gridStep: WidgetState.grid ? WidgetState.gridSize : 0
property var guides: ({
x: [],
y: []
})
function others(id) {
return onScreen.filter(i => i.id !== id).map(i => WidgetState.rect(i.id));
}
function nudge(dx, dy) {
if (!selectionHere)
return;
const r = WidgetState.rect(selectedItem.id);
WidgetState.setDraft(selectedItem.id, Logic.clampRect({
x: r.x + dx,
y: r.y + dy,
w: r.w,
h: r.h
}, bounds));
WidgetState.commit(selectedItem.id);
}
Item {
id: keys
anchors.fill: parent
focus: true
Component.onCompleted: forceActiveFocus()
Keys.onPressed: event => {
const step = event.modifiers & Qt.ShiftModifier ? 10 : 1;
if (event.key === Qt.Key_Escape) {
if (WidgetState.selected)
WidgetState.selected = "";
else
WidgetState.done();
} else if ((event.key === Qt.Key_Delete || event.key === Qt.Key_Backspace) && root.selectionHere)
WidgetState.remove(root.selectedItem.id);
else if (event.key === Qt.Key_Left)
root.nudge(-step, 0);
else if (event.key === Qt.Key_Right)
root.nudge(step, 0);
else if (event.key === Qt.Key_Up)
root.nudge(0, -step);
else if (event.key === Qt.Key_Down)
root.nudge(0, step);
else
return;
event.accepted = true;
}
Rectangle {
anchors.fill: parent
color: Qt.alpha("#000000", 0.3)
}
Canvas {
id: gridLines
anchors.fill: parent
visible: WidgetState.grid
readonly property color line: Qt.alpha(Theme.text, 0.07)
onVisibleChanged: requestPaint()
onPaint: {
const ctx = getContext("2d");
ctx.reset();
ctx.strokeStyle = line;
ctx.lineWidth = 1;
ctx.beginPath();
for (let x = WidgetState.gridSize; x < width; x += WidgetState.gridSize) {
ctx.moveTo(x + 0.5, 0);
ctx.lineTo(x + 0.5, height);
}
for (let y = WidgetState.gridSize; y < height; y += WidgetState.gridSize) {
ctx.moveTo(0, y + 0.5);
ctx.lineTo(width, y + 0.5);
}
ctx.stroke();
}
}
MouseArea {
anchors.fill: parent
onPressed: {
WidgetState.selected = "";
keys.forceActiveFocus();
}
}
Repeater {
model: root.guides.x
Rectangle {
required property real modelData
x: modelData
width: 1
height: parent.height
color: Theme.accent
}
}
Repeater {
model: root.guides.y
Rectangle {
required property real modelData
y: modelData
height: 1
width: parent.width
color: Theme.accent
}
}
// One frame per widget on this output.
Repeater {
model: root.onScreen.map(i => i.id)
Item {
id: proxy
required property string modelData
readonly property var item: WidgetState.item(modelData)
readonly property var geometry: WidgetState.rect(modelData)
readonly property bool selected: WidgetState.selected === modelData
x: geometry.x
y: geometry.y
width: geometry.w
height: geometry.h
z: selected ? 2 : 1
Rectangle {
anchors.fill: parent
radius: Math.min(Theme.radius, width / 2, height / 2)
color: proxy.selected ? Qt.alpha(Theme.accent, 0.1) : move.containsMouse ? Qt.alpha(Theme.text, 0.06) : Theme.transparent
border.width: proxy.selected ? 2 : 1
border.color: proxy.selected ? Theme.accent : Qt.alpha(Theme.text, move.containsMouse ? 0.6 : 0.3)
}
Rectangle {
visible: proxy.selected || move.containsMouse
y: proxy.y > 30 ? -26 : proxy.height + 4
implicitWidth: label.implicitWidth + 16
implicitHeight: 22
radius: 11
color: proxy.selected ? Theme.accent : Qt.alpha(Theme.tint, 0.75)
Text {
id: label
anchors.centerIn: parent
text: proxy.item ? WidgetRegistry.type(proxy.item.type).name + " " + Math.round(proxy.geometry.w) + "×" + Math.round(proxy.geometry.h) : ""
color: proxy.selected ? Theme.accentText : Theme.text
font.pixelSize: 11
}
}
MouseArea {
id: move
objectName: "widgetMove-" + proxy.modelData
anchors.fill: parent
hoverEnabled: true
cursorShape: pressed ? Qt.ClosedHandCursor : Qt.OpenHandCursor
property point start
property var startRect
onPressed: mouse => {
WidgetState.selected = proxy.modelData;
keys.forceActiveFocus();
start = mapToItem(null, mouse.x, mouse.y);
startRect = proxy.geometry;
}
onPositionChanged: mouse => {
if (!pressed)
return;
const p = mapToItem(null, mouse.x, mouse.y);
const snapped = Logic.snapMove({
x: startRect.x + p.x - start.x,
y: startRect.y + p.y - start.y,
w: startRect.w,
h: startRect.h
}, root.others(proxy.modelData), root.bounds, root.gridStep, 10);
WidgetState.setDraft(proxy.modelData, snapped);
root.guides = snapped.guides;
}
onReleased: {
WidgetState.commit(proxy.modelData);
root.guides = {
x: [],
y: []
};
}
}
// Corner and edge handles.
Repeater {
model: proxy.selected ? [
{
fx: 0,
fy: 0,
edges: {
left: true,
top: true
},
cursor: Qt.SizeFDiagCursor
},
{
fx: 0.5,
fy: 0,
edges: {
top: true
},
cursor: Qt.SizeVerCursor
},
{
fx: 1,
fy: 0,
edges: {
right: true,
top: true
},
cursor: Qt.SizeBDiagCursor
},
{
fx: 1,
fy: 0.5,
edges: {
right: true
},
cursor: Qt.SizeHorCursor
},
{
fx: 1,
fy: 1,
edges: {
right: true,
bottom: true
},
cursor: Qt.SizeFDiagCursor
},
{
fx: 0.5,
fy: 1,
edges: {
bottom: true
},
cursor: Qt.SizeVerCursor
},
{
fx: 0,
fy: 1,
edges: {
left: true,
bottom: true
},
cursor: Qt.SizeBDiagCursor
},
{
fx: 0,
fy: 0.5,
edges: {
left: true
},
cursor: Qt.SizeHorCursor
}
] : []
Rectangle {
id: handle
required property var modelData
x: proxy.width * modelData.fx - width / 2
y: proxy.height * modelData.fy - height / 2
width: 14
height: 14
radius: 7
color: Theme.text
border.width: 2
border.color: Theme.accent
MouseArea {
anchors.fill: parent
anchors.margins: -4
cursorShape: handle.modelData.cursor
property point start
property var startRect
onPressed: mouse => {
start = mapToItem(null, mouse.x, mouse.y);
startRect = proxy.geometry;
}
onPositionChanged: mouse => {
if (!pressed)
return;
const p = mapToItem(null, mouse.x, mouse.y);
WidgetState.setDraft(proxy.modelData, Logic.resizeRect(startRect, p.x - start.x, p.y - start.y, handle.modelData.edges, WidgetState.limits(proxy.item.type), root.bounds, root.gridStep));
}
onReleased: WidgetState.commit(proxy.modelData)
}
}
}
}
}
// Toolbar and inspector, stacked at the bottom (or top, away from the selection).
Column {
id: chrome
// Above every widget frame.
z: 10
anchors.horizontalCenter: parent.horizontalCenter
// Plain y (not switched anchors, which do not reliably reset).
y: root.chromeOnTop ? (ConfigService.ready ? ConfigService.data.bar.margin + ConfigService.data.bar.height : 48) + 20 : parent.height - height - 28
width: Math.min(root.width - 48, 900)
spacing: 12
// Inspector for the selected widget.
GlassPanel {
id: inspector
objectName: "widgetInspector"
visible: root.selectionHere
surfaceOpacity: Math.max(Theme.panelOpacity, 0.8)
anchors.horizontalCenter: parent.horizontalCenter
width: Math.min(chrome.width, 520)
height: inspectorBody.implicitHeight + 28
MouseArea {
anchors.fill: parent
}
ColumnLayout {
id: inspectorBody
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.margins: 14
spacing: 10
RowLayout {
Layout.fillWidth: true
spacing: 10
GlassIcon {
size: 32
glyph: root.selectedType ? root.selectedType.icon : ""
fallback: root.selectedType ? root.selectedType.name.charAt(0) : ""
active: true
}
Text {
text: root.selectedType ? root.selectedType.name : ""
color: Theme.text
font.pixelSize: 14
font.weight: Font.DemiBold
Layout.fillWidth: true
}
GlassButton {
text: "Duplicate"
onClicked: WidgetState.duplicate(root.selectedItem.id)
}
GlassButton {
objectName: "widgetDelete"
text: "Delete"
onClicked: WidgetState.remove(root.selectedItem.id)
}
}
RowLayout {
visible: !!root.selectedItem && WidgetRegistry.variants(root.selectedItem.type).length > 1
Layout.fillWidth: true
Text {
text: "Style"
color: Theme.textSecondary
font.pixelSize: 12
Layout.preferredWidth: 70
}
GlassSegmented {
model: root.selectedItem ? WidgetRegistry.variants(root.selectedItem.type) : []
currentIndex: root.selectedItem ? model.indexOf(root.selectedItem.variant) : -1
onActivated: (index, value) => WidgetState.update(root.selectedItem.id, {
variant: value
})
}
Item {
Layout.fillWidth: true
}
}
RowLayout {
Layout.fillWidth: true
Text {
text: "Opacity"
color: Theme.textSecondary
font.pixelSize: 12
Layout.preferredWidth: 70
}
GlassSlider {
Layout.fillWidth: true
from: 0.1
to: 1
stepSize: 0.05
value: root.selectedItem ? root.selectedItem.opacity : 1
onMoved: WidgetState.update(root.selectedItem.id, {
opacity: Math.round(value * 100) / 100
})
}
Text {
text: root.selectedItem ? Math.round(root.selectedItem.opacity * 100) + "%" : ""
color: Theme.textSecondary
font.pixelSize: 12
Layout.preferredWidth: 40
horizontalAlignment: Text.AlignRight
}
}
Repeater {
model: root.selectedType && root.selectedType.options ? root.selectedType.options : []
RowLayout {
id: option
required property var modelData
readonly property var current: root.selectedItem && root.selectedItem.options ? root.selectedItem.options[modelData.id] : undefined
Layout.fillWidth: true
Text {
text: option.modelData.label
color: Theme.textSecondary
font.pixelSize: 12
Layout.fillWidth: option.modelData.kind === "toggle"
Layout.preferredWidth: option.modelData.kind === "toggle" ? -1 : 150
wrapMode: Text.Wrap
}
GlassToggle {
visible: option.modelData.kind === "toggle"
checked: !!option.current
onToggled: WidgetState.setOption(root.selectedItem.id, option.modelData.id, checked)
}
GlassTextField {
visible: option.modelData.kind === "text"
Layout.fillWidth: true
text: option.current || ""
onEditingFinished: WidgetState.setOption(root.selectedItem.id, option.modelData.id, text.trim())
Keys.onEscapePressed: keys.forceActiveFocus()
}
}
}
}
}
// Add widgets, grid toggle and Done.
GlassPanel {
objectName: "widgetToolbar"
surfaceOpacity: Math.max(Theme.panelOpacity, 0.8)
width: chrome.width
height: toolbarBody.implicitHeight + 24
MouseArea {
anchors.fill: parent
}
ColumnLayout {
id: toolbarBody
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.margins: 12
spacing: 10
Flow {
Layout.preferredWidth: chrome.width - 24
Layout.fillWidth: true
spacing: 6
Repeater {
model: WidgetRegistry.order
Rectangle {
id: adder
required property string modelData
readonly property var type: WidgetRegistry.type(modelData)
objectName: "widgetAdd-" + modelData
width: 64
height: 62
radius: 12
color: addArea.containsMouse ? Theme.hover : Theme.transparent
Column {
anchors.centerIn: parent
spacing: 4
GlassIcon {
anchors.horizontalCenter: parent.horizontalCenter
size: 34
glyph: adder.type.icon
fallback: adder.type.name.charAt(0)
}
Text {
anchors.horizontalCenter: parent.horizontalCenter
width: 60
horizontalAlignment: Text.AlignHCenter
elide: Text.ElideRight
text: adder.type.name
color: Theme.textSecondary
font.pixelSize: 10
}
}
MouseArea {
id: addArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
WidgetState.add(adder.modelData, root.screen.name);
keys.forceActiveFocus();
}
}
}
}
}
RowLayout {
Layout.fillWidth: true
spacing: 10
Text {
text: "Drag to move · handles resize · arrows nudge · Delete removes · Esc finishes"
color: Theme.textSecondary
font.pixelSize: 11
elide: Text.ElideRight
Layout.fillWidth: true
}
Text {
text: "Snap to grid"
color: Theme.text
font.pixelSize: 12
}
GlassToggle {
objectName: "widgetGrid"
checked: WidgetState.grid
onToggled: ConfigService.setValue("desktopWidgets.grid", checked)
}
GlassButton {
objectName: "widgetDone"
text: "Done"
accented: true
onClicked: WidgetState.done()
}
}
}
}
}
}
}
+173
View File
@@ -0,0 +1,173 @@
pragma Singleton
import QtQuick
import Quickshell
// Desktop widget types. Sizes are logical pixels; `variants` maps id -> label;
// `options` lists editable per-widget options shown in the editor inspector;
// `background: false` draws the face without the glass card.
Singleton {
readonly property var order: ["clock", "calendar", "weather", "music", "visualizer", "cpu", "ram", "gpu", "temp", "disk", "network", "user", "image", "note"]
readonly property var types: ({
clock: {
name: "Clock",
icon: "󰥔",
file: "faces/ClockFace.qml",
size: [260, 130],
min: [140, 70],
variants: {
digital: "Digital",
analog: "Analog",
minimal: "Minimal"
},
transparent: ["minimal"],
options: [
{
id: "seconds",
label: "Show seconds",
kind: "toggle"
}
]
},
calendar: {
name: "Calendar",
icon: "󰃭",
file: "faces/CalendarFace.qml",
size: [270, 260],
min: [210, 200]
},
weather: {
name: "Weather",
icon: "󰖐",
file: "faces/WeatherFace.qml",
size: [270, 140],
min: [180, 100],
options: [
{
id: "location",
label: "Location (blank = automatic)",
kind: "text"
},
{
id: "fahrenheit",
label: "Fahrenheit",
kind: "toggle"
}
]
},
music: {
name: "Music",
icon: "󰝚",
file: "faces/MusicFace.qml",
size: [380, 160],
min: [320, 140]
},
visualizer: {
name: "Visualizer",
icon: "󰺢",
file: "faces/VisualizerFace.qml",
size: [420, 120],
min: [140, 50],
variants: {
bars: "Bars",
mirror: "Mirror"
},
transparent: ["bars", "mirror"]
},
cpu: {
name: "CPU",
icon: "󰻠",
file: "faces/UsageFace.qml",
size: [180, 130],
min: [110, 80]
},
ram: {
name: "Memory",
icon: "󰍛",
file: "faces/UsageFace.qml",
size: [180, 130],
min: [110, 80]
},
gpu: {
name: "GPU",
icon: "󰢮",
file: "faces/UsageFace.qml",
size: [180, 130],
min: [110, 80]
},
temp: {
name: "CPU temp",
icon: "󰔏",
file: "faces/UsageFace.qml",
size: [180, 130],
min: [110, 80]
},
disk: {
name: "Disk",
icon: "󰋊",
file: "faces/UsageFace.qml",
size: [180, 130],
min: [110, 80]
},
network: {
name: "Network",
icon: "󰛳",
file: "faces/NetworkFace.qml",
size: [270, 140],
min: [180, 100]
},
user: {
name: "User",
icon: "󰀄",
file: "faces/UserFace.qml",
size: [290, 120],
min: [230, 100]
},
image: {
name: "Image",
icon: "󰋩",
file: "faces/ImageFace.qml",
size: [300, 200],
min: [60, 60],
variants: {
rounded: "Rounded",
rect: "Square",
round: "Circle"
},
transparent: ["rounded", "rect", "round"],
options: [
{
id: "path",
label: "Image file",
kind: "text"
}
]
},
note: {
name: "Note",
icon: "󰎚",
file: "faces/NoteFace.qml",
size: [240, 200],
min: [150, 100],
keyboard: true
}
})
function type(id) {
return Object.prototype.hasOwnProperty.call(types, id) ? types[id] : null;
}
function variants(id) {
const t = type(id);
return t && t.variants ? Object.keys(t.variants) : [];
}
function defaultVariant(id) {
const v = variants(id);
return v.length ? v[0] : "default";
}
function transparent(id, variant) {
const t = type(id);
return !!t && !!t.transparent && t.transparent.includes(variant);
}
function source(id) {
const t = type(id);
return t ? Qt.resolvedUrl(t.file) : "";
}
}
+181
View File
@@ -0,0 +1,181 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
import "../services"
import "../core"
import "../services/WidgetLogic.js" as Logic
// Desktop widget items plus editor state. While a widget is dragged or resized
// its geometry lives in `drafts`, so the real surface follows live; the result
// is written to the configuration on release.
Singleton {
id: root
readonly property var items: ConfigService.ready ? ConfigService.data.desktopWidgets.items : []
readonly property bool grid: ConfigService.ready && ConfigService.data.desktopWidgets.grid
readonly property int gridSize: 20
property bool editing: false
property string selected: ""
property var drafts: ({})
// Live surfaces by widget id and editor windows, for diagnostics and tests.
property var surfaces: ({})
property var editors: []
function item(id) {
return items.find(i => i.id === id) || null;
}
function rect(id) {
const draft = drafts[id];
if (draft)
return draft;
const i = item(id);
return i ? {
x: i.x,
y: i.y,
w: i.w,
h: i.h
} : {
x: 0,
y: 0,
w: 0,
h: 0
};
}
function limits(type) {
const t = WidgetRegistry.type(type);
return {
minW: t ? t.min[0] : 60,
minH: t ? t.min[1] : 60,
maxW: 4000,
maxH: 4000
};
}
function setDraft(id, r) {
const next = Object.assign({}, drafts);
next[id] = {
x: r.x,
y: r.y,
w: r.w,
h: r.h
};
drafts = next;
}
function commit(id) {
const r = drafts[id];
if (!r)
return;
update(id, {
x: Math.round(r.x),
y: Math.round(r.y),
w: Math.round(r.w),
h: Math.round(r.h)
});
const next = Object.assign({}, drafts);
delete next[id];
drafts = next;
}
function update(id, patch) {
return ConfigService.setValue("desktopWidgets.items", Logic.updateItem(items, id, patch));
}
function setOption(id, key, value) {
const i = item(id);
if (!i)
return false;
const options = Object.assign({}, i.options || {});
options[key] = value;
return update(id, {
options: options
});
}
// Adds a widget centred on the given output and selects it.
function add(type, monitor) {
const t = WidgetRegistry.type(type);
const screen = Quickshell.screens.find(s => s.name === monitor) || ScreenService.active;
if (!t || !screen)
return "";
const id = Logic.newId(items);
let x = Math.round((screen.width - t.size[0]) / 2), y = Math.round((screen.height - t.size[1]) / 2);
if (grid) {
x = Math.round(x / gridSize) * gridSize;
y = Math.round(y / gridSize) * gridSize;
}
// Offset when another widget already sits exactly there.
while (items.some(i => i.monitor === screen.name && i.x === x && i.y === y)) {
x += 24;
y += 24;
}
const added = ConfigService.setValue("desktopWidgets.items", Logic.addItem(items, {
id: id,
type: type,
variant: WidgetRegistry.defaultVariant(type),
monitor: screen.name,
x: x,
y: y,
w: t.size[0],
h: t.size[1],
opacity: 1,
options: {}
}));
if (added)
selected = id;
return added ? id : "";
}
function duplicate(id) {
const i = item(id);
if (!i)
return "";
const copy = Object.assign({}, i, {
id: Logic.newId(items),
x: i.x + 24,
y: i.y + 24,
options: Object.assign({}, i.options || {})
});
if (ConfigService.setValue("desktopWidgets.items", Logic.addItem(items, copy)))
selected = copy.id;
return copy.id;
}
function remove(id) {
if (selected === id)
selected = "";
return ConfigService.setValue("desktopWidgets.items", Logic.removeItem(items, id));
}
function edit(id) {
ShellState.settingsOpen = false;
ShellState.controlCenterOpen = false;
ShellState.launcherOpen = false;
ShellState.wallpaperPickerOpen = false;
selected = id || "";
editing = true;
}
function done() {
editing = false;
selected = "";
drafts = {};
}
IpcHandler {
target: "widgets"
function edit(): void {
root.edit("");
}
function toggle(): void {
if (root.editing)
root.done();
else
root.edit("");
}
function done(): void {
root.done();
}
function add(type: string): string {
return root.add(type, ScreenService.active ? ScreenService.active.name : "");
}
function list(): string {
return JSON.stringify({
editing: root.editing,
selected: root.selected,
items: root.items
});
}
}
}
+112
View File
@@ -0,0 +1,112 @@
pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Layouts
import Quickshell
import "../../theme"
// Month view starting on the locale's first weekday; arrows browse months.
Face {
id: root
SystemClock {
id: clock
precision: SystemClock.Minutes
}
property int offset: 0
readonly property date today: clock.date
readonly property date shown: new Date(today.getFullYear(), today.getMonth() + offset, 1)
readonly property int firstDay: Qt.locale().firstDayOfWeek % 7
readonly property var cells: {
const start = (shown.getDay() - firstDay + 7) % 7;
const result = [];
for (let i = 0; i < 42; i++)
result.push(new Date(shown.getFullYear(), shown.getMonth(), 1 - start + i));
return result;
}
ColumnLayout {
anchors.fill: parent
anchors.margins: 14
spacing: 6
RowLayout {
Layout.fillWidth: true
Text {
text: Qt.formatDate(root.shown, "MMMM yyyy")
color: Theme.text
font.pixelSize: 14
font.weight: Font.DemiBold
Layout.fillWidth: true
}
Repeater {
model: [-1, 1]
Rectangle {
id: arrow
required property int modelData
implicitWidth: 22
implicitHeight: 22
radius: 11
color: arrowArea.containsMouse ? Theme.hover : Theme.transparent
Text {
anchors.centerIn: parent
text: arrow.modelData < 0 ? "‹" : "›"
color: Theme.textSecondary
font.pixelSize: 16
}
MouseArea {
id: arrowArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: root.offset += arrow.modelData
}
}
}
}
GridLayout {
Layout.fillWidth: true
Layout.fillHeight: true
columns: 7
rowSpacing: 0
columnSpacing: 0
Repeater {
model: 7
Text {
required property int index
text: Qt.locale().dayName((root.firstDay + index) % 7, Locale.NarrowFormat)
color: Theme.textSecondary
font.pixelSize: 10
font.weight: Font.DemiBold
horizontalAlignment: Text.AlignHCenter
Layout.fillWidth: true
}
}
Repeater {
model: root.cells
Item {
id: cell
required property date modelData
readonly property bool isToday: modelData.toDateString() === root.today.toDateString()
readonly property bool inMonth: modelData.getMonth() === root.shown.getMonth()
Layout.fillWidth: true
Layout.fillHeight: true
Rectangle {
anchors.centerIn: parent
width: Math.min(parent.width, parent.height) - 2
height: width
radius: width / 2
color: Theme.accent
visible: cell.isToday
}
Text {
anchors.centerIn: parent
text: cell.modelData.getDate()
color: cell.isToday ? Theme.accentText : Theme.text
opacity: cell.inMonth ? 1 : 0.3
font.pixelSize: 11
font.weight: cell.isToday ? Font.DemiBold : Font.Normal
}
}
}
}
}
// Jump back to the current month when the day changes.
onTodayChanged: offset = 0
}
+125
View File
@@ -0,0 +1,125 @@
import QtQuick
import QtQuick.Effects
import Quickshell
import "../../services"
import "../../theme"
Face {
id: root
readonly property bool seconds: !!options.seconds
SystemClock {
id: clock
precision: root.seconds || root.variant === "analog" ? SystemClock.Seconds : SystemClock.Minutes
}
// Follows the bar clock's 12/24-hour preference.
readonly property string timeFormat: (ConfigService.ready && !ConfigService.data.bar.clock.use24Hour ? "h:mm" : "HH:mm") + (seconds ? ":ss" : "")
// Digital: large time with the date below.
Column {
visible: root.variant === "digital"
anchors.centerIn: parent
spacing: root.height * 0.02
Text {
anchors.horizontalCenter: parent.horizontalCenter
text: Qt.formatTime(clock.date, root.timeFormat)
color: Theme.text
font.pixelSize: Math.min(root.height * 0.42, root.width / (root.seconds ? 4.4 : 3))
font.weight: Font.Light
font.features: {
"tnum": 1
}
}
Text {
anchors.horizontalCenter: parent.horizontalCenter
text: Qt.formatDate(clock.date, "dddd, d MMMM")
color: Theme.textSecondary
font.pixelSize: Math.max(10, root.height * 0.11)
}
}
// Minimal: no card; large thin time and the weekday, readable on any wallpaper.
Item {
id: minimal
visible: root.variant === "minimal"
anchors.fill: parent
layer.enabled: visible
layer.effect: MultiEffect {
shadowEnabled: true
shadowColor: "#99000000"
shadowBlur: 0.6
shadowVerticalOffset: 2
}
Column {
anchors.left: parent.left
anchors.leftMargin: root.width * 0.04
anchors.verticalCenter: parent.verticalCenter
Text {
text: Qt.formatTime(clock.date, root.timeFormat)
color: Theme.text
font.pixelSize: Math.min(root.height * 0.55, root.width / (root.seconds ? 4.2 : 2.9))
font.weight: Font.Thin
font.features: {
"tnum": 1
}
}
Text {
text: Qt.formatDate(clock.date, "dddd d MMMM").toUpperCase()
color: Theme.text
opacity: 0.85
font.pixelSize: Math.max(10, root.height * 0.1)
font.letterSpacing: 2
font.weight: Font.DemiBold
}
}
}
// Analog: ticks and hands; the second hand follows the seconds option.
Canvas {
id: dial
visible: root.variant === "analog"
anchors.centerIn: parent
width: Math.min(root.width, root.height) - 16
height: width
readonly property var time: clock.date
readonly property color hand: Theme.text
readonly property color accent: Theme.accentVivid
onTimeChanged: requestPaint()
onVisibleChanged: if (visible)
requestPaint()
onWidthChanged: requestPaint()
onPaint: {
const ctx = getContext("2d");
ctx.reset();
const r = width / 2;
ctx.translate(r, r);
for (let i = 0; i < 60; i++) {
const a = i * Math.PI / 30, major = i % 5 === 0;
ctx.beginPath();
ctx.moveTo(Math.sin(a) * r * (major ? 0.82 : 0.9), -Math.cos(a) * r * (major ? 0.82 : 0.9));
ctx.lineTo(Math.sin(a) * r * 0.96, -Math.cos(a) * r * 0.96);
ctx.strokeStyle = Qt.alpha(hand, major ? 0.85 : 0.3);
ctx.lineWidth = major ? Math.max(1.5, r * 0.035) : 1;
ctx.lineCap = "round";
ctx.stroke();
}
const d = time, h = d.getHours() % 12, m = d.getMinutes(), s = d.getSeconds();
const handAt = (angle, length, widthFactor, color) => {
ctx.beginPath();
ctx.moveTo(-Math.sin(angle) * r * 0.1, Math.cos(angle) * r * 0.1);
ctx.lineTo(Math.sin(angle) * r * length, -Math.cos(angle) * r * length);
ctx.strokeStyle = color;
ctx.lineWidth = Math.max(1.5, r * widthFactor);
ctx.lineCap = "round";
ctx.stroke();
};
handAt((h + m / 60) * Math.PI / 6, 0.5, 0.06, hand);
handAt((m + s / 60) * Math.PI / 30, 0.74, 0.04, hand);
if (root.seconds)
handAt(s * Math.PI / 30, 0.8, 0.015, accent);
ctx.beginPath();
ctx.arc(0, 0, Math.max(3, r * 0.05), 0, 2 * Math.PI);
ctx.fillStyle = accent;
ctx.fill();
}
}
}
+28
View File
@@ -0,0 +1,28 @@
import QtQuick
import "../../services"
// Base for desktop widget faces; DesktopWidget binds these after loading.
Item {
id: face
property string widgetId
property string kind
property string variant
property var options: ({})
// False while windows cover this widget's desktop: faces pause motion and sampling.
property bool desktopVisible: true
// Faces showing live metrics keep the shared collector running only while shown.
property bool usesMetrics: false
readonly property bool sampling: usesMetrics && desktopVisible
property bool counted: false
function count(next) {
if (next !== counted) {
MetricsService.consumers += next ? 1 : -1;
counted = next;
}
}
onSamplingChanged: count(sampling)
Component.onCompleted: count(sampling)
Component.onDestruction: count(false)
// Reference size for typography that scales with the widget.
readonly property real unit: Math.min(width, height * 2)
}
+54
View File
@@ -0,0 +1,54 @@
import QtQuick
import QtQuick.Effects
import "../../theme"
// A picture from disk: rounded, square or circular.
Face {
id: root
readonly property string path: options.path || ""
Image {
id: picture
anchors.fill: parent
visible: false
source: root.path ? "file://" + encodeURI(root.path).replace(/#/g, "%23").replace(/\?/g, "%3F") : ""
sourceSize: Qt.size(Math.max(1, root.width) * 2, Math.max(1, root.height) * 2)
fillMode: Image.PreserveAspectCrop
asynchronous: true
}
Item {
id: shape
anchors.centerIn: parent
width: root.variant === "round" ? Math.min(root.width, root.height) : root.width
height: root.variant === "round" ? width : root.height
visible: false
layer.enabled: true
Rectangle {
anchors.fill: parent
radius: root.variant === "round" ? width / 2 : root.variant === "rect" ? 0 : Theme.radius
}
}
MultiEffect {
anchors.fill: parent
source: picture
maskEnabled: true
maskSource: shape
visible: picture.status === Image.Ready
}
Rectangle {
anchors.fill: shape
visible: picture.status !== Image.Ready
radius: root.variant === "round" ? width / 2 : root.variant === "rect" ? 0 : Theme.radius
color: Theme.fill
border.width: 1
border.color: Theme.border
Text {
anchors.centerIn: parent
width: parent.width - 20
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.Wrap
text: root.path ? "Cannot load image" : "Right-click to choose an image"
color: Theme.textSecondary
font.pixelSize: 11
}
}
}
+13
View File
@@ -0,0 +1,13 @@
import QtQuick
import "../../media"
import "../../theme"
// The shared media card, drawn on the widget's own glass.
Face {
MediaCard {
anchors.fill: parent
compact: true
color: Theme.transparent
border.width: 0
}
}
+115
View File
@@ -0,0 +1,115 @@
import QtQuick
import QtQuick.Layouts
import "../../components"
import "../../services"
import "../../theme"
// Live download/upload rates with a one-minute history graph.
Face {
id: root
usesMetrics: true
readonly property var samples: MetricsService.history
ColumnLayout {
anchors.fill: parent
anchors.margins: 12
spacing: 6
RowLayout {
Layout.fillWidth: true
spacing: 6
GlassIcon {
size: 22
glyphSize: 12
glyph: "󰛳"
fallback: "N"
color: Theme.transparent
border.width: 0
}
Text {
text: "Network"
color: Theme.text
font.pixelSize: 12
font.weight: Font.DemiBold
Layout.fillWidth: true
}
}
RowLayout {
Layout.fillWidth: true
spacing: 14
Repeater {
model: [
{
label: "↓",
value: MetricsService.network.download,
color: Theme.accentVivid
},
{
label: "↑",
value: MetricsService.network.upload,
color: Theme.text
}
]
Row {
id: rate
required property var modelData
spacing: 4
Text {
text: rate.modelData.label
color: rate.modelData.color
font.pixelSize: 15
font.weight: Font.DemiBold
}
Text {
text: MetricsService.bytes(rate.modelData.value) + "/s"
color: Theme.text
font.pixelSize: 15
font.weight: Font.Light
font.features: {
"tnum": 1
}
}
}
}
}
Canvas {
id: graph
Layout.fillWidth: true
Layout.fillHeight: true
readonly property var samples: root.samples
readonly property color down: Theme.accentVivid
readonly property color up: Theme.text
onSamplesChanged: requestPaint()
onWidthChanged: requestPaint()
onHeightChanged: requestPaint()
onPaint: {
const ctx = getContext("2d");
ctx.reset();
const values = samples.filter(s => Number.isFinite(s.down) && Number.isFinite(s.up));
if (values.length < 2)
return;
const peak = Math.max(1024, ...values.map(s => Math.max(s.down, s.up)));
const step = width / 59;
const offset = width - (values.length - 1) * step;
for (const [key, color, alpha] of [["down", down, 0.3], ["up", up, 0.12]]) {
ctx.beginPath();
ctx.moveTo(offset, height);
values.forEach((s, i) => ctx.lineTo(offset + i * step, height - s[key] / peak * (height - 2)));
ctx.lineTo(offset + (values.length - 1) * step, height);
ctx.closePath();
ctx.fillStyle = Qt.alpha(color, alpha);
ctx.fill();
ctx.beginPath();
values.forEach((s, i) => {
const y = height - s[key] / peak * (height - 2);
if (i === 0)
ctx.moveTo(offset, y);
else
ctx.lineTo(offset + i * step, y);
});
ctx.strokeStyle = Qt.alpha(color, 0.9);
ctx.lineWidth = 1.5;
ctx.stroke();
}
}
}
}
}
+32
View File
@@ -0,0 +1,32 @@
import QtQuick
import QtQuick.Controls
import "../../theme"
import ".."
// Sticky note; text is saved shortly after typing stops.
Face {
id: root
ScrollView {
anchors.fill: parent
anchors.margins: 12
TextArea {
id: editor
text: root.options.text || ""
placeholderText: "Write a note…"
placeholderTextColor: Theme.textSecondary
color: Theme.text
selectionColor: Theme.accent
selectedTextColor: Theme.accentText
wrapMode: TextEdit.Wrap
font.pixelSize: 13
background: null
onTextChanged: if (activeFocus)
save.restart()
}
}
Timer {
id: save
interval: 700
onTriggered: WidgetState.setOption(root.widgetId, "text", editor.text)
}
}
+166
View File
@@ -0,0 +1,166 @@
import QtQuick
import "../../components"
import "../../services"
import "../../theme"
// CPU, memory, GPU, CPU temperature and disk: a liquid fill rising with the
// value (after Serpantinum's usage cards), with title, value and detail.
Face {
id: root
usesMetrics: true
readonly property var disk: (MetricsService.snapshot.storage || [])[0] || ({})
readonly property var raw: {
switch (kind) {
case "cpu":
return {
title: "CPU",
icon: "󰻠",
value: MetricsService.cpu.percent,
text: MetricsService.value(MetricsService.cpu.percent, "%"),
detail: Number.isFinite(MetricsService.cpu.frequency) ? (MetricsService.cpu.frequency / 1000).toFixed(1) + " GHz" : ""
};
case "ram":
return {
title: "Memory",
icon: "󰍛",
value: MetricsService.ram.percent,
text: MetricsService.value(MetricsService.ram.percent, "%"),
detail: MetricsService.ram.available ? MetricsService.bytes(MetricsService.ram.used) + " of " + MetricsService.bytes(MetricsService.ram.total) : ""
};
case "gpu":
return {
title: "GPU",
icon: "󰢮",
value: MetricsService.gpu.percent,
text: MetricsService.value(MetricsService.gpu.percent, "%"),
detail: MetricsService.gpu.name || "No GPU telemetry"
};
case "temp":
return {
title: "CPU temp",
icon: "󰔏",
value: MetricsService.cpu.temperature,
text: MetricsService.value(MetricsService.cpu.temperature, "°C"),
detail: MetricsService.cpu.name || ""
};
default:
return {
title: "Disk",
icon: "󰋊",
value: root.disk.percent,
text: MetricsService.value(root.disk.percent, "%"),
detail: root.disk.available ? MetricsService.bytes(root.disk.free) + " free · " + root.disk.path : ""
};
}
}
readonly property real level: Number.isFinite(raw.value) ? Math.max(0, Math.min(1, raw.value / 100)) : 0
// The wave moves only while easing to a visibly different reading (12 fps,
// at least `settleTicks` steps), then holds still; small changes repaint
// once. An endless wave kept every usage widget repainting and the
// compositor recompositing the glass behind it.
readonly property bool animated: Theme.intensity > 0
readonly property int settleTicks: 18
property real shownLevel: level
property real phase: 0
property int ticks: 0
onLevelChanged: {
if (!animated || !desktopVisible || (!wave.running && Math.abs(level - shownLevel) < 0.02)) {
shownLevel = level;
return;
}
ticks = 0;
wave.start();
}
Timer {
id: wave
interval: 83
repeat: true
onTriggered: {
root.phase = (root.phase + Math.PI * 2 * interval / 2400) % (Math.PI * 2);
const gap = root.level - root.shownLevel;
root.shownLevel = Math.abs(gap) < 0.002 ? root.level : root.shownLevel + gap * 0.3;
if ((++root.ticks >= root.settleTicks && root.shownLevel === root.level) || !root.desktopVisible || !root.animated)
stop();
}
}
readonly property bool compact: height < 100 || width < 140
Canvas {
id: liquid
anchors.fill: parent
readonly property real level: root.shownLevel
readonly property real phase: root.phase
readonly property color fill: Theme.accentVivid
readonly property real radius: Theme.radius
onLevelChanged: requestPaint()
onPhaseChanged: requestPaint()
onFillChanged: requestPaint()
onPaint: {
const ctx = getContext("2d");
ctx.reset();
const w = width, h = height, r = Math.min(radius, h / 2, w / 2);
ctx.beginPath();
ctx.roundedRect(0, 0, w, h, r, r);
ctx.clip();
const surface = h * (1 - level), amp = Math.max(2, h * 0.035);
for (const [shift, alpha] of [[Math.PI, 0.18], [0, 0.38]]) {
ctx.beginPath();
ctx.moveTo(0, h);
for (let x = 0; x <= w; x += 4)
ctx.lineTo(x, surface + Math.sin(x / w * Math.PI * 2 + phase + shift) * amp);
ctx.lineTo(w, h);
ctx.closePath();
ctx.fillStyle = Qt.alpha(fill, alpha);
ctx.fill();
}
}
}
Column {
anchors.left: parent.left
anchors.top: parent.top
anchors.margins: 12
spacing: 2
Row {
spacing: 6
GlassIcon {
size: 22
glyphSize: 12
glyph: root.raw.icon
fallback: root.raw.title.charAt(0)
color: Theme.transparent
border.width: 0
}
Text {
anchors.verticalCenter: parent.verticalCenter
text: root.raw.title
color: Theme.text
font.pixelSize: 12
font.weight: Font.DemiBold
}
}
}
Column {
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.margins: 12
spacing: 0
Text {
text: root.raw.text
color: Theme.text
font.pixelSize: Math.max(18, Math.min(root.height * 0.3, root.width * 0.24))
font.weight: Font.Light
font.features: {
"tnum": 1
}
}
Text {
visible: !root.compact && text !== ""
width: parent.width
text: root.raw.detail
color: Theme.textSecondary
font.pixelSize: 10
elide: Text.ElideRight
}
}
}
+117
View File
@@ -0,0 +1,117 @@
import QtQuick
import QtQuick.Effects
import QtQuick.Layouts
import Quickshell
import Quickshell.Io
import "../../theme"
// Avatar (~/.face or AccountsService), greeting, user@host and uptime.
Face {
id: root
readonly property string user: Quickshell.env("USER") || "user"
readonly property var avatars: ["file://" + Quickshell.env("HOME") + "/.face", "file://" + Quickshell.env("HOME") + "/.face.icon", "file:///var/lib/AccountsService/icons/" + user]
property int avatarIndex: 0
SystemClock {
id: clock
precision: SystemClock.Minutes
}
readonly property string greeting: {
const h = clock.date.getHours();
return h < 5 ? "Good night" : h < 12 ? "Good morning" : h < 18 ? "Good afternoon" : "Good evening";
}
FileView {
id: hostname
path: "/etc/hostname"
}
FileView {
id: uptime
path: "/proc/uptime"
}
Timer {
interval: 60000
running: root.visible && root.desktopVisible
repeat: true
onTriggered: uptime.reload()
}
onDesktopVisibleChanged: if (desktopVisible)
uptime.reload()
readonly property string uptimeText: {
const seconds = parseFloat(uptime.text());
if (!Number.isFinite(seconds))
return "";
const d = Math.floor(seconds / 86400), h = Math.floor(seconds % 86400 / 3600), m = Math.floor(seconds % 3600 / 60);
return "up " + (d ? d + "d " : "") + (d || h ? h + "h " : "") + m + "m";
}
RowLayout {
anchors.fill: parent
anchors.margins: 14
spacing: 14
Item {
readonly property real size: Math.min(root.height - 28, 80)
Layout.preferredWidth: size
Layout.preferredHeight: size
Image {
id: avatar
anchors.fill: parent
source: root.avatarIndex < root.avatars.length ? root.avatars[root.avatarIndex] : ""
sourceSize: Qt.size(160, 160)
fillMode: Image.PreserveAspectCrop
asynchronous: true
visible: false
onStatusChanged: if (status === Image.Error)
root.avatarIndex++
}
Rectangle {
id: mask
anchors.fill: parent
radius: width / 2
visible: false
layer.enabled: true
}
MultiEffect {
anchors.fill: parent
source: avatar
maskEnabled: true
maskSource: mask
visible: avatar.status === Image.Ready
}
Rectangle {
anchors.fill: parent
radius: width / 2
visible: avatar.status !== Image.Ready
color: Theme.accent
Text {
anchors.centerIn: parent
text: root.user.charAt(0).toUpperCase()
color: Theme.accentText
font.pixelSize: parent.width * 0.45
font.weight: Font.DemiBold
}
}
}
ColumnLayout {
Layout.fillWidth: true
spacing: 1
Text {
text: root.greeting + ","
color: Theme.textSecondary
font.pixelSize: 12
}
Text {
text: root.user.charAt(0).toUpperCase() + root.user.slice(1)
color: Theme.text
font.pixelSize: Math.max(16, root.height * 0.18)
font.weight: Font.DemiBold
elide: Text.ElideRight
Layout.fillWidth: true
}
Text {
text: root.user + "@" + hostname.text().trim() + (root.uptimeText ? " · " + root.uptimeText : "")
color: Theme.textSecondary
font.pixelSize: 10
elide: Text.ElideRight
Layout.fillWidth: true
}
}
}
}
@@ -0,0 +1,40 @@
pragma ComponentBehavior: Bound
import QtQuick
import "../../services"
import "../../theme"
// Cava bars for system audio: rising bars, or mirrored around the centre line.
Face {
id: root
Component.onCompleted: CavaService.widgetConsumers++
Component.onDestruction: CavaService.widgetConsumers--
readonly property bool mirror: variant === "mirror"
Row {
id: bars
anchors.fill: parent
anchors.margins: 6
spacing: Math.max(2, width / 24 * 0.3)
Repeater {
model: 24
Item {
id: column
required property int index
readonly property real level: Math.max(0.03, CavaService.bars[index] || 0)
width: (bars.width - bars.spacing * 23) / 24
height: bars.height
Rectangle {
width: parent.width
height: Math.max(width, column.height * column.level)
y: root.mirror ? (column.height - height) / 2 : column.height - height
radius: width / 2
color: Qt.alpha(Theme.accentVivid, 0.55 + column.level * 0.45)
Behavior on height {
NumberAnimation {
duration: 60
}
}
}
}
}
}
}
+100
View File
@@ -0,0 +1,100 @@
import QtQuick
import QtQuick.Layouts
import Quickshell
import Quickshell.Io
import "../../components"
import "../../theme"
// Current conditions from wttr.in, refreshed every 30 minutes.
Face {
id: root
readonly property string location: options.location || ""
readonly property bool fahrenheit: !!options.fahrenheit
property var current: null
property string error: ""
function temperature(celsius) {
return Math.round(fahrenheit ? celsius * 9 / 5 + 32 : celsius) + "°";
}
// WWO weather codes used by wttr.in.
function glyph(code) {
if (code === 113)
return "󰖙";
if (code === 116)
return "󰖕";
if (code === 119 || code === 122)
return "󰖐";
if ([143, 248, 260].includes(code))
return "󰖑";
if ([200, 386, 389, 392, 395].includes(code))
return "󰖓";
if ([179, 182, 185, 227, 230, 317, 320, 323, 326, 329, 332, 335, 338, 350, 362, 365, 368, 371, 374, 377].includes(code))
return "󰖘";
return "󰖗";
}
Process {
id: fetch
command: ["python3", Quickshell.shellPath("helpers/weather.py"), root.location]
stdout: StdioCollector {
onStreamFinished: {
try {
const result = JSON.parse(text);
if (result.ok) {
root.current = result;
root.error = "";
} else
root.error = "Weather unavailable";
} catch (e) {
root.error = "Weather unavailable";
}
}
}
}
Timer {
interval: 30 * 60 * 1000
running: root.visible
repeat: true
triggeredOnStart: true
onTriggered: if (!fetch.running)
fetch.running = true
}
onLocationChanged: if (!fetch.running)
fetch.running = true
RowLayout {
anchors.fill: parent
anchors.margins: 14
spacing: 12
GlassIcon {
size: Math.min(root.height - 28, 64)
glyphSize: size * 0.62
glyph: root.current ? root.glyph(root.current.code) : "󰖐"
fallback: "☁"
color: Theme.transparent
border.width: 0
}
ColumnLayout {
Layout.fillWidth: true
spacing: 0
Text {
text: root.current ? root.temperature(root.current.celsius) : "—"
color: Theme.text
font.pixelSize: Math.max(20, root.height * 0.3)
font.weight: Font.Light
}
Text {
text: root.current ? root.current.description : root.error || "Loading…"
color: Theme.text
font.pixelSize: 12
elide: Text.ElideRight
Layout.fillWidth: true
}
Text {
visible: !!root.current && root.height > 110
text: root.current ? root.current.place + " · feels " + root.temperature(root.current.feelsCelsius) : ""
color: Theme.textSecondary
font.pixelSize: 10
elide: Text.ElideRight
Layout.fillWidth: true
}
}
}
}
+1
View File
@@ -0,0 +1 @@
Face 1.0 Face.qml
+5
View File
@@ -0,0 +1,5 @@
singleton WidgetRegistry 1.0 WidgetRegistry.qml
singleton WidgetState 1.0 WidgetState.qml
DesktopWidget 1.0 DesktopWidget.qml
DesktopWidgets 1.0 DesktopWidgets.qml
WidgetEditor 1.0 WidgetEditor.qml