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:
commit
99e64a7713
433 files changed
+57792
No files matched your search
@@ -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
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
Face 1.0 Face.qml
|
||||
Reference in new issue
Block a user