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

@@ -0,0 +1,227 @@
pragma ComponentBehavior: Bound
import QtQuick
import Quickshell
import Quickshell.Hyprland
import Quickshell.Widgets
import "../../components"
import "../../core"
import "../../services"
import "../../theme"
// Programs on the focused workspace, left to right. Hover one for a live
// preview, click to focus it, middle-click to close it.
GlassPill {
id: root
objectName: "activeWindowPill"
property var barScreen
// Layout entry; options come from the cog in Settings → Bar.
property var entry: ({
id: "activeWindow"
})
readonly property string transition: ModuleRegistry.option(entry, "transition")
readonly property string labels: ModuleRegistry.option(entry, "labels")
readonly property string collapse: ModuleRegistry.option(entry, "collapse")
readonly property int labelWidth: ({
short: 90,
medium: 150,
long: 230
})[ModuleRegistry.option(entry, "labelWidth")] || 150
readonly property bool previews: ModuleRegistry.option(entry, "preview") !== "off"
readonly property int workspace: Hyprland.focusedWorkspace ? Hyprland.focusedWorkspace.id : 0
// Workspace switches replace the whole list: animate it as one, in the
// switch direction, instead of popping each pill in.
property int previousWorkspace: workspace
property real slideFrom: 0
property bool switching: false
onWorkspaceChanged: {
slideFrom = workspace > previousWorkspace ? 1 : -1;
previousWorkspace = workspace;
switching = true;
settle.restart();
if (transition === "fade" || transition === "slide")
switchAnim.restart();
}
Timer {
id: settle
interval: Theme.duration + 50
onTriggered: root.switching = false
}
ParallelAnimation {
id: switchAnim
NumberAnimation {
target: row
property: "opacity"
from: 0
to: 1
duration: Theme.duration * 1.2
easing.type: Easing.OutCubic
}
NumberAnimation {
target: slide
property: "x"
from: root.transition === "slide" ? 14 * root.slideFrom * Math.max(0.3, Theme.intensity) : 0
to: 0
duration: Theme.duration * 1.4
easing.type: Easing.OutCubic
}
}
// Left to right by Hyprland's last known position. Positions are not
// refreshed here: Hyprland.refreshToplevels() can crash Quickshell 0.3.1
// (HyprlandToplevel::updateFromObject), so windows without one go last.
// Read windows only after startup: bindings on Hyprland toplevels during
// Quickshell's initial window parse make its startup crash far likelier.
property bool armed: false
Timer {
interval: 1500
running: true
onTriggered: root.armed = true
}
readonly property var windows: !armed ? [] : HyprlandService.windows.filter(w => w.workspace === root.workspace && !!w.handle).sort((a, b) => root.order(a) - root.order(b))
function order(w) {
return w.width > 0 ? w.x * 10000 + w.y : 1e12 + HyprlandService.windows.indexOf(w);
}
// Crowded workspaces show the unfocused programs as icons only.
readonly property bool compact: labels === "icons" || labels === "focused" || (collapse !== "never" && windows.length > Number(collapse))
function pretty(id) {
const last = String(id || "").split(".").pop().replace(/[-_]+/g, " ");
return last ? last.charAt(0).toUpperCase() + last.slice(1) : "Window";
}
implicitHeight: ModuleRegistry.pillHeight
implicitWidth: (windows.length ? row.implicitWidth : empty.implicitWidth) + 8
Behavior on implicitWidth {
enabled: root.transition !== "none"
NumberAnimation {
duration: Theme.duration
easing.type: Easing.OutCubic
}
}
clip: true
Text {
id: empty
anchors.centerIn: parent
visible: root.windows.length === 0
leftPadding: 12
rightPadding: 12
text: "Desktop"
color: Theme.textSecondary
font.pixelSize: 13
}
Row {
id: row
anchors.centerIn: parent
spacing: 2
transform: Translate {
id: slide
}
// Single new windows pop in; a workspace switch uses switchAnim.
add: Transition {
enabled: root.transition !== "none" && (root.transition === "pop" || !root.switching)
NumberAnimation {
properties: "opacity,scale"
from: 0
to: 1
duration: Theme.duration
easing.type: Easing.OutCubic
}
}
move: Transition {
enabled: root.transition !== "none"
NumberAnimation {
properties: "x"
duration: Theme.duration
easing.type: Easing.OutCubic
}
}
Repeater {
model: ScriptModel {
values: root.windows
objectProp: "address"
}
Rectangle {
id: item
required property var modelData
required property int index
readonly property var toplevel: modelData.handle
// Previews hang under the whole list so the pane stays put.
readonly property Item placement: root
readonly property var entry: modelData.appId ? DesktopEntries.heuristicLookup(modelData.appId) : null
readonly property string name: entry && entry.name ? entry.name : root.pretty(modelData.appId || modelData.title)
readonly property bool focused: !!toplevel && toplevel.activated
readonly property bool previewing: PopoutState.open && PopoutState.anchor === item
readonly property bool labelled: root.labels !== "icons" && (!root.compact || focused)
objectName: "windowItem-" + index
implicitHeight: ModuleRegistry.pillHeight - 6
implicitWidth: content.implicitWidth + 16
radius: height / 2
color: previewing ? Qt.alpha(Theme.accent, 0.28) : focused ? Qt.alpha(Theme.text, 0.13) : hover.hovered ? Theme.hover : Theme.transparent
Behavior on color {
ColorAnimation {
duration: Theme.duration / 2
}
}
Behavior on implicitWidth {
NumberAnimation {
duration: Theme.duration
easing.type: Easing.OutCubic
}
}
Row {
id: content
anchors.centerIn: parent
spacing: 7
IconImage {
id: icon
anchors.verticalCenter: parent.verticalCenter
implicitSize: Math.round(ModuleRegistry.pillHeight * 0.5)
source: item.entry && item.entry.icon ? Quickshell.iconPath(item.entry.icon, true) : Quickshell.iconPath("application-x-executable", true)
// Synchronous on purpose: Quickshell's icon provider loads QPixmaps,
// which crash when built off the GUI thread (Quickshell 0.3.1).
}
Text {
anchors.verticalCenter: parent.verticalCenter
visible: item.labelled
width: Math.min(implicitWidth, root.labelWidth)
text: item.name
color: item.focused ? Theme.text : Theme.textSecondary
font.pixelSize: 13
font.weight: item.focused ? Font.DemiBold : Font.Normal
elide: Text.ElideRight
}
}
// Focused-window underline.
Rectangle {
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
width: item.focused ? 14 : 0
height: 2
radius: 1
color: Theme.accentVivid
Behavior on width {
NumberAnimation {
duration: Theme.duration
easing.type: Easing.OutCubic
}
}
}
HoverHandler {
id: hover
cursorShape: Qt.PointingHandCursor
onHoveredChanged: hovered ? PopoutState.hover(item, root.previews ? "window" : "tooltip", item.modelData.title || item.name, item.toplevel) : PopoutState.unhover(item)
}
TapHandler {
acceptedButtons: Qt.LeftButton
onTapped: {
PopoutState.close();
HyprlandService.focusWindow(item.modelData.address);
}
}
TapHandler {
acceptedButtons: Qt.MiddleButton
onTapped: HyprlandService.closeWindow(item.modelData.address)
}
Accessible.role: Accessible.Button
Accessible.name: item.name + (item.focused ? ", focused" : "")
}
}
}
}
+83
View File
@@ -0,0 +1,83 @@
pragma ComponentBehavior: Bound
import QtQuick
import "../../components"
import "../../core"
import "../../services"
import "../../theme"
// Cava audio visualizer in the bar. Click opens the dashboard's Media tab,
// right-click the Media settings. Cava only runs while something plays.
GlassPill {
id: root
objectName: "cavaPill"
readonly property var options: ConfigService.ready ? ConfigService.data.bar.cava : ({
bars: 12,
style: "bars",
hideWhenIdle: true
})
readonly property bool mirror: options.style === "mirror"
readonly property bool shown: !CavaService.failed && (MediaService.playing || !options.hideWhenIdle)
readonly property int barWidth: 3
readonly property int gap: 2
implicitHeight: ModuleRegistry.pillHeight
implicitWidth: shown ? options.bars * barWidth + (options.bars - 1) * gap + 22 : 0
visible: implicitWidth > 0.5
opacity: shown ? 1 : 0
clip: true
Behavior on implicitWidth {
NumberAnimation {
duration: Theme.duration * 1.4
easing.type: Easing.OutCubic
}
}
Behavior on opacity {
NumberAnimation {
duration: Theme.duration
}
}
Component.onCompleted: CavaService.widgetConsumers++
Component.onDestruction: CavaService.widgetConsumers--
// Cava emits 24 bands; each pill bar averages its share of them.
function level(index) {
const all = CavaService.bars, n = options.bars, from = Math.floor(index * all.length / n), to = Math.max(from + 1, Math.floor((index + 1) * all.length / n));
let sum = 0;
for (let i = from; i < to; i++)
sum += all[i] || 0;
return sum / (to - from);
}
Row {
anchors.centerIn: parent
height: parent.height - 12
spacing: root.gap
Repeater {
model: root.options.bars
Rectangle {
required property int index
readonly property real value: MediaService.playing ? Math.min(1, root.level(index)) : 0
width: root.barWidth
radius: width / 2
height: Math.max(width, parent.height * value)
y: root.mirror ? (parent.height - height) / 2 : parent.height - height
color: Theme.accentVivid
opacity: 0.55 + 0.45 * value
Behavior on height {
NumberAnimation {
duration: 80
}
}
}
}
}
TapHandler {
acceptedButtons: Qt.LeftButton
onTapped: ShellState.toggleDashboard("media")
}
TapHandler {
acceptedButtons: Qt.RightButton
onTapped: ShellState.openSettings("media")
}
HoverHandler {
cursorShape: Qt.PointingHandCursor
}
Accessible.name: "Audio visualizer"
}
+31
View File
@@ -0,0 +1,31 @@
import QtQuick
import Quickshell
import "../../components"
import "../../theme"
import "../../services"
import "../../core"
GlassPill {
id: root
readonly property var options: ConfigService.data.bar.clock
width: label.implicitWidth + 30
height: ModuleRegistry.pillHeight
SystemClock {
id: clock
precision: root.options.showSeconds ? SystemClock.Seconds : SystemClock.Minutes
}
Text {
id: label
anchors.centerIn: parent
text: Qt.formatDateTime(clock.date, (root.options.showDate ? "ddd, d MMM " : "") + (root.options.use24Hour ? "HH:mm" : "h:mm") + (root.options.showSeconds ? ":ss" : "") + (root.options.use24Hour ? "" : " AP"))
color: Theme.text
font.pixelSize: 13
}
// Clicking the clock opens the dashboard (Settings → Dashboard).
MouseArea {
anchors.fill: parent
enabled: ConfigService.ready && ConfigService.data.dashboard.enabled && ConfigService.data.dashboard.openFromClock
cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
onClicked: ShellState.toggleDashboard("")
}
}
+35
View File
@@ -0,0 +1,35 @@
import QtQuick
import "../../components"
import "../../services"
import "../../core"
GlassButton {
property string metric: "cpu"
implicitHeight: ModuleRegistry.pillHeight
Component.onCompleted: MetricsService.consumers++
Component.onDestruction: MetricsService.consumers--
text: {
switch (metric) {
case "cpu":
return "CPU " + MetricsService.value(MetricsService.cpu.percent, "%");
case "cpuTemperature":
return "CPU " + MetricsService.value(MetricsService.cpu.temperature, "°C");
case "gpu":
return "GPU " + MetricsService.value(MetricsService.gpu.percent, "%");
case "gpuTemperature":
return "GPU " + MetricsService.value(MetricsService.gpu.temperature, "°C");
case "ram":
return "RAM " + MetricsService.value(MetricsService.ram.percent, "%");
case "storage":
return "Disk " + MetricsService.value((MetricsService.snapshot.storage || [
{}
])[0]?.percent, "%");
default:
return "↓ " + MetricsService.bytes(MetricsService.network.download) + "/s ↑ " + MetricsService.bytes(MetricsService.network.upload) + "/s";
}
}
readonly property bool network: metric === "networkThroughput"
accented: network && ShellState.controlCenterOpen
onClicked: network ? ShellState.toggleControlCenter() : ShellState.openSettings("metrics")
Accessible.name: text
}
@@ -0,0 +1,36 @@
import QtQuick
import QtQuick.Layouts
import "../../components"
import "../../services"
import "../../core"
import "../../theme"
GlassPill {
implicitWidth: content.implicitWidth + 12
implicitHeight: ModuleRegistry.pillHeight
RowLayout {
id: content
anchors.centerIn: parent
spacing: 3
GlassButton {
implicitWidth: ModuleRegistry.pillHeight - 4
implicitHeight: ModuleRegistry.pillHeight - 4
text: MediaService.playing ? "Ⅱ" : "▶"
enabled: !!MediaService.player && MediaService.player.canTogglePlaying && MediaService.player.canControl
onClicked: MediaService.toggle()
Accessible.name: "Toggle playback"
}
GlassButton {
implicitWidth: 160
implicitHeight: ModuleRegistry.pillHeight - 4
contentItem: Text {
text: MediaService.title
color: Theme.text
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
}
onClicked: ShellState.openSettings("media")
Accessible.name: "Media settings"
}
}
}
+120
View File
@@ -0,0 +1,120 @@
import QtQuick
import Quickshell
import "../../components"
import "../../core"
import "../../services"
import "../../theme"
import "../../compat/omarchy/Ui" as OmarchyUi
// Hosts an installed plugin's bar widget inside glassMxrph's own pill, so it
// sits in the bar like any built-in module (size, glass, spacing, per-screen
// layouts, cog options). The widget gets a PluginBarApi whose colors, font and
// size come from the glassMxrph theme; tooltips use the shared hover popout.
GlassPill {
id: root
property var barScreen
property var entry: ({})
readonly property string pluginId: entry.id ? String(entry.id).slice("plugin:".length) : ""
readonly property bool noctalia: PluginService.ecosystem(pluginId) === "noctalia"
readonly property string source: PluginService.entryUrl(pluginId, "bar-widget")
readonly property var settings: PluginService.widgetSettings(pluginId, entry.options)
readonly property Item widget: loader.item as Item
// Not widget.visible: that reads false while this pill is still hidden.
// Omarchy widgets report emptiness through hasVisualContent instead.
readonly property var widgetObject: loader.item
readonly property bool shown: !!widget && (noctalia || widgetObject.hasVisualContent !== false) && widget.implicitWidth > 0
implicitHeight: ModuleRegistry.pillHeight
implicitWidth: shown ? Math.ceil(widget.implicitWidth) + 8 : 0
visible: implicitWidth > 0
Behavior on implicitWidth {
NumberAnimation {
duration: Theme.duration
easing.type: Easing.OutCubic
}
}
OmarchyUi.PluginBarApi {
id: api
pluginId: root.pluginId
moduleName: root.pluginId
shell: root.pluginId ? PluginService.shellFor(root.pluginId) : null
foreground: Theme.text
barForeground: Theme.text
background: Qt.alpha(Theme.surface, Theme.glassOpacity)
urgent: Theme.urgent
fontFamily: fontProbe.font.family
position: "top"
vertical: false
barSize: ModuleRegistry.pillHeight
transparent: true
foregroundAnimationEnabled: Theme.duration > 0
activePopout: PluginService.activePopout
layoutConfig: root.settings
// Like Omarchy's bar: only a hovered widget shows its tooltip (plugins
// also call this whenever their data refreshes).
_showTooltip: (target, text) => {
if (text && target && target.tooltipHovered !== false)
PopoutState.hover(target, "tooltip", text);
}
_hideTooltip: target => PopoutState.unhover(target)
_requestPopout: owner => PluginService.requestPopout(owner)
_releasePopout: owner => PluginService.releasePopout(owner)
_switchPanelFrom: (owner, direction) => false
_targetBelongsToWindow: (target, window) => !!target && !!target.QsWindow && target.QsWindow.window === window
_moduleWidgets: id => PluginService.widgets[id] || []
_run: command => Quickshell.execDetached(Array.isArray(command) ? command : ["sh", "-c", String(command)])
}
// The default UI font, which glassMxrph's own text uses.
Text {
id: fontProbe
visible: false
}
// Noctalia widgets get their pluginApi at creation, as in Noctalia, so their
// first bindings already see it.
onSourceChanged: load()
Component.onCompleted: load()
function load() {
if (!source) {
loader.source = "";
return;
}
if (!noctalia) {
loader.source = source;
return;
}
loader.setSource(source, {
pluginApi: PluginService.noctaliaApi(pluginId),
screen: barScreen,
widgetId: pluginId,
section: entry.position || "right",
sectionWidgetIndex: 0,
sectionWidgetsCount: 1
});
}
Loader {
id: loader
anchors.centerIn: parent
height: parent.height
onLoaded: {
if (root.noctalia) {
// Noctalia v4 bar widget contract.
const napi = PluginService.noctaliaApi(root.pluginId);
if ("screen" in item)
item.screen = Qt.binding(() => root.barScreen);
if (napi)
napi.barWidget = item;
} else {
if ("bar" in item)
item.bar = api;
if ("moduleName" in item)
item.moduleName = root.pluginId;
if ("settings" in item)
item.settings = Qt.binding(() => root.settings);
}
PluginService.registerWidget(root.pluginId, item);
}
}
Component.onDestruction: if (loader.item)
PluginService.unregisterWidget(pluginId, loader.item)
}
+12
View File
@@ -0,0 +1,12 @@
import QtQuick
import "../../components"
import "../../core"
import "../../theme"
GlassIconButton {
text: "⚙"
implicitWidth: ModuleRegistry.pillHeight
implicitHeight: ModuleRegistry.pillHeight
onClicked: ShellState.toggleSettings()
rotation: ShellState.settingsOpen ? 60 * Theme.intensity : 0
Behavior on rotation { NumberAnimation { duration: Theme.duration; easing.type: Easing.OutCubic } }
}
+18
View File
@@ -0,0 +1,18 @@
import QtQuick
import "../../components"
import "../../core"
import "../../services"
GlassButton {
id: root
property var barScreen
Component.onCompleted: ShellState.systemPills = ShellState.systemPills.concat([root])
Component.onDestruction: ShellState.systemPills = ShellState.systemPills.filter(p => p !== root)
objectName: "systemPill"
readonly property bool volumeInBar: BarLayout.modulesFor(barScreen ? barScreen.name : "").some(m => m.id === "volume" && m.enabled)
implicitHeight: ModuleRegistry.pillHeight
text: volumeInBar ? "☷" : "☷ " + (AudioService.sink && AudioService.sink.audio ? (AudioService.sink.audio.muted ? "Muted" : Math.round(AudioService.sink.audio.volume * 100) + "%") : "System")
accented: ShellState.controlCenterOpen
onClicked: ShellState.toggleControlCenter()
Accessible.name: "Control Center"
}
+25
View File
@@ -0,0 +1,25 @@
pragma ComponentBehavior: Bound
import QtQuick
import "../../components"
import "../../services"
import "../../menus"
import "../../core"
Item {
id: root
property var barScreen
readonly property bool shown: TrayService.options.enabled && TrayService.items.length > 0
implicitWidth: shown ? row.implicitWidth + 12 : 0
implicitHeight: shown ? ModuleRegistry.pillHeight : 0
visible: shown
// The whole pill is hover space: gaps between icons keep a hover menu open.
readonly property bool hovered: hover.hovered
HoverHandler { id: hover }
GlassPill { anchors.fill: parent; visible: TrayService.options.background === "pill" }
Row {
id: row; anchors.centerIn: parent; spacing: TrayService.options.spacing
Repeater {
model: root.shown ? TrayService.items : []
TrayIcon { required property var modelData; trayItem: modelData; barScreen: root.barScreen; group: root }
}
}
}
+70
View File
@@ -0,0 +1,70 @@
import QtQuick
import "../../components"
import "../../core"
import "../../services"
import "../../theme"
// Output volume: scroll to adjust, click to mute, right-click for audio settings.
GlassButton {
id: root
objectName: "volumePill"
readonly property var audio: AudioService.sink ? AudioService.sink.audio : null
readonly property bool muted: !!audio && audio.muted
readonly property real level: audio ? audio.volume : 0
readonly property int step: ConfigService.ready ? ConfigService.data.osd.step : 5
readonly property string glyph: !audio ? "󰖁" : muted || level === 0 ? "󰖁" : level < 0.34 ? "󰕿" : level < 0.67 ? "󰖀" : "󰕾"
enabled: !!audio
accented: false
implicitHeight: ModuleRegistry.pillHeight
// Width comes from the texts directly; the value reserves room for "100%"
// so the pill does not jitter while scrolling.
TextMetrics {
id: widest
font: value.font
text: "100%"
}
contentItem: Item {
implicitWidth: icon.implicitWidth + 6 + valueWidth
implicitHeight: Math.max(icon.implicitHeight, value.implicitHeight)
readonly property real valueWidth: Math.max(widest.advanceWidth, value.implicitWidth)
Text {
id: icon
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
text: Icons.available ? root.glyph : (root.muted ? "×" : "♪")
font.family: Icons.available ? Icons.family : ""
font.pixelSize: 15
color: root.muted ? Theme.urgent : Theme.text
}
Text {
id: value
anchors.left: icon.right
anchors.leftMargin: 6
anchors.verticalCenter: parent.verticalCenter
text: !root.audio ? "—" : root.muted ? "Off" : Math.round(root.level * 100) + "%"
font.pixelSize: 13
font.features: {
"tnum": 1
}
color: root.muted ? Theme.urgent : Theme.text
}
}
implicitWidth: icon.implicitWidth + 6 + Math.max(widest.advanceWidth, value.implicitWidth) + 28
onClicked: AudioService.mute(false)
WheelHandler {
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
onWheel: event => {
if (!root.audio)
return;
const delta = (event.angleDelta.y || -event.angleDelta.x) > 0 ? 1 : -1;
if (delta > 0)
root.audio.muted = false;
AudioService.volume(false, root.level + delta * root.step / 100);
}
}
TapHandler {
acceptedButtons: Qt.RightButton
onTapped: ShellState.openSettings("audio")
}
Accessible.name: "Volume " + (muted ? "muted" : Math.round(level * 100) + "%")
}
+281
View File
@@ -0,0 +1,281 @@
pragma ComponentBehavior: Bound
import QtQuick
import Quickshell.Hyprland
import "../../components"
import "../../theme"
import "../../services"
import "../../core"
// Workspace switcher. Styles (bar.workspaces.style): numbers, roman numerals,
// dots (filled = occupied, ring = empty) and pacman (after Serpantinum: pellets
// for empty workspaces, ghosts for occupied ones, Pac-Man on the active one).
GlassPill {
id: root
property var barScreen
// Every bar follows the globally focused workspace, whichever monitor it is on.
readonly property int activeId: Hyprland.focusedWorkspace ? Hyprland.focusedWorkspace.id : 0
// Workspaces shown on other monitors get a faint outline.
readonly property var visibleIds: Hyprland.monitors.values.map(m => m.activeWorkspace ? m.activeWorkspace.id : 0).filter(id => id > 0 && id !== activeId)
readonly property int count: ConfigService.data.bar.workspaces.count
readonly property string style: ConfigService.data.bar.workspaces.style || "numbers"
readonly property bool pacman: style === "pacman"
readonly property real pacmanScale: 0.95
readonly property int slotWidth: style === "roman" ? 38 : style === "dots" ? 22 : style === "pacman" ? 24 : 32
readonly property int slotHeight: height - 6
readonly property int activeIndex: activeId >= 1 && activeId <= count ? activeId - 1 : -1
width: count * slotWidth + 8
height: ModuleRegistry.pillHeight
function roman(value) {
const numerals = [[10, "X"], [9, "IX"], [5, "V"], [4, "IV"], [1, "I"]];
let result = "";
for (const [n, symbol] of numerals)
while (value >= n) {
result += symbol;
value -= n;
}
return result;
}
Repeater {
model: root.pacman ? [] : root.visibleIds.filter(id => id <= root.count)
Rectangle {
required property int modelData
x: 4 + (modelData - 1) * root.slotWidth
y: 3
width: root.slotWidth
height: root.slotHeight
radius: height / 2
color: Qt.alpha(Theme.accent, 0.18)
border.width: 1
border.color: Qt.alpha(Theme.accent, 0.6)
}
}
// Sliding accent highlight (all styles except pacman, whose actor marks the active slot).
Rectangle {
visible: !root.pacman && root.activeIndex >= 0
x: 4 + Math.max(0, root.activeIndex) * root.slotWidth
y: 3
width: root.slotWidth
height: root.slotHeight
radius: height / 2
color: Theme.accent
Behavior on x {
NumberAnimation {
duration: Theme.duration
easing.type: Easing.OutCubic
}
}
}
Row {
x: 4
y: 3
Repeater {
model: root.count
Item {
id: slot
required property int index
readonly property var workspace: Hyprland.workspaces.values.find(w => w.id === index + 1) || null
readonly property bool active: root.activeIndex === index
readonly property bool occupied: !!workspace && workspace.toplevels.values.length > 0
readonly property bool urgent: !!workspace && workspace.urgent
width: root.slotWidth
height: root.slotHeight
// Numbers and roman numerals
Text {
visible: root.style === "numbers" || root.style === "roman"
anchors.centerIn: parent
anchors.verticalCenterOffset: slot.occupied && !slot.active ? -2 : 0
text: root.style === "roman" ? root.roman(slot.index + 1) : slot.index + 1
font.pixelSize: root.style === "roman" ? 11 : 12
font.weight: root.style === "roman" ? Font.DemiBold : Font.Normal
font.letterSpacing: root.style === "roman" ? 0.5 : 0
color: slot.urgent ? Theme.urgent : slot.active ? Theme.accentText : Theme.text
opacity: slot.active || slot.occupied ? 1 : 0.5
}
Rectangle {
visible: (root.style === "numbers" || root.style === "roman") && slot.occupied && !slot.active
anchors.bottom: parent.bottom
anchors.bottomMargin: 1
anchors.horizontalCenter: parent.horizontalCenter
width: 3
height: 3
radius: 2
color: Theme.text
}
// Dots: filled when occupied, ring when empty
Rectangle {
visible: root.style === "dots"
anchors.centerIn: parent
width: slot.active ? 9 : 8
height: width
radius: width / 2
color: slot.active ? Theme.accentText : slot.urgent ? Theme.urgent : slot.occupied ? Theme.text : Theme.transparent
border.width: slot.occupied || slot.active ? 0 : 1.5
border.color: slot.urgent ? Theme.urgent : Qt.alpha(Theme.text, 0.6)
Behavior on width {
NumberAnimation {
duration: Theme.duration / 2
}
}
}
// Pacman: pellets (every second one a power pellet) and ghosts
Rectangle {
visible: root.pacman && !slot.occupied
anchors.centerIn: parent
width: Math.round((slot.index % 2 === 1 ? 9 : 6) * root.pacmanScale)
height: width
radius: width / 2
color: slot.urgent ? Theme.urgent : Qt.alpha(Theme.text, 0.75)
scale: slot.active ? 0 : pelletArea.containsMouse ? 1.25 : 1
Behavior on scale {
NumberAnimation {
duration: 180
easing.type: Easing.OutBack
}
}
}
// Created only for occupied slots in pacman style: each Canvas holds
// its own 2D context and texture.
Loader {
active: root.pacman && slot.occupied
anchors.centerIn: parent
sourceComponent: Canvas {
id: ghost
width: Math.round(16 * root.pacmanScale)
height: Math.round(17 * root.pacmanScale)
scale: slot.active ? 0 : pelletArea.containsMouse ? 1.15 : 1
Behavior on scale {
NumberAnimation {
duration: 220
easing.type: Easing.OutBack
}
}
// Pupils look towards Pac-Man.
readonly property real look: root.activeIndex > slot.index ? 1 : root.activeIndex < slot.index && root.activeIndex >= 0 ? -1 : 0
readonly property color body: slot.urgent ? Theme.urgent : Theme.textSecondary
onLookChanged: requestPaint()
onBodyChanged: requestPaint()
onVisibleChanged: if (visible)
requestPaint()
Component.onCompleted: requestPaint()
onPaint: {
const ctx = getContext("2d");
ctx.reset();
const w = width - 2, h = height - 2, r = w / 2, x0 = 1, y0 = 1;
const bottom = y0 + h, wave = h * 0.14;
ctx.beginPath();
ctx.moveTo(x0, y0 + r);
ctx.arc(x0 + r, y0 + r, r, Math.PI, 0, false);
ctx.lineTo(x0 + w, bottom);
ctx.quadraticCurveTo(x0 + w * 5 / 6, bottom - wave, x0 + w * 2 / 3, bottom);
ctx.quadraticCurveTo(x0 + w / 2, bottom - wave, x0 + w / 3, bottom);
ctx.quadraticCurveTo(x0 + w / 6, bottom - wave, x0, bottom);
ctx.closePath();
ctx.fillStyle = body;
ctx.fill();
const eye = w * 0.17, ex1 = x0 + w * 0.32, ex2 = x0 + w * 0.68, ey = y0 + r * 0.95;
ctx.beginPath();
ctx.arc(ex1, ey, eye, 0, 2 * Math.PI);
ctx.arc(ex2, ey, eye, 0, 2 * Math.PI);
ctx.fillStyle = "#ffffff";
ctx.fill();
const shift = look * eye * 0.35;
ctx.beginPath();
ctx.arc(ex1 + shift, ey, eye * 0.55, 0, 2 * Math.PI);
ctx.arc(ex2 + shift, ey, eye * 0.55, 0, 2 * Math.PI);
ctx.fillStyle = "#11111b";
ctx.fill();
}
}
}
MouseArea {
id: pelletArea
anchors.fill: parent
hoverEnabled: root.pacman
cursorShape: Qt.PointingHandCursor
onClicked: Hyprland.dispatch("workspace " + (slot.index + 1))
}
}
}
}
// Pac-Man glides to the active workspace, chomps, and faces its direction of travel.
Canvas {
id: pac
property int previous: root.activeIndex
property bool facingLeft: false
property real mouth: 0.18
visible: root.pacman && root.activeIndex >= 0
width: Math.round(20 * root.pacmanScale)
height: width
y: 3 + (root.slotHeight - height) / 2
x: 4 + Math.max(0, root.activeIndex) * root.slotWidth + (root.slotWidth - width) / 2
Behavior on x {
NumberAnimation {
duration: Math.max(Theme.duration, 1) * 1.4
easing.type: Easing.OutQuint
}
}
transform: Scale {
origin.x: pac.width / 2
xScale: pac.facingLeft ? -1 : 1
}
Connections {
target: root
function onActiveIndexChanged() {
if (root.activeIndex < pac.previous)
pac.facingLeft = true;
else if (root.activeIndex > pac.previous)
pac.facingLeft = false;
pac.previous = root.activeIndex;
if (Theme.intensity > 0)
chomp.restart();
}
}
SequentialAnimation {
id: chomp
loops: 3
NumberAnimation {
target: pac
property: "mouth"
to: 0.02
duration: 80
easing.type: Easing.InOutQuad
}
NumberAnimation {
target: pac
property: "mouth"
to: 0.18
duration: 80
easing.type: Easing.InOutQuad
}
}
readonly property color body: Theme.accentVivid
onMouthChanged: requestPaint()
onBodyChanged: requestPaint()
onVisibleChanged: if (visible)
requestPaint()
Component.onCompleted: requestPaint()
onPaint: {
const ctx = getContext("2d");
ctx.reset();
const r = width / 2, m = mouth * Math.PI;
ctx.beginPath();
ctx.moveTo(r, r);
ctx.arc(r, r, r - 0.5, m, 2 * Math.PI - m, false);
ctx.closePath();
ctx.fillStyle = body;
ctx.fill();
ctx.beginPath();
ctx.arc(r + r * 0.12, r - r * 0.46, Math.max(1.5, r * 0.14), 0, 2 * Math.PI);
ctx.fillStyle = "#11111b";
ctx.fill();
}
}
}