Files
mxandClaude Opus 5.5 bc197339fa Add bar spots beside the notch, and Caffeine and Night Light modules
Notch mode gets two more module lists, notch.innerLeft and
notch.innerRight: spots right beside the notch at the same distance on
both sides. They follow the notch's edges as it springs wider for media,
never draw pills (plugins and the tray drop theirs there), and fade out
while the notch is open or widened. Picking a module for one of the four
side spots in Settings -> Notch moves it there from the others.

Caffeine and Night Light are now bar modules too; Night Light polls its
state every 30 s while only the bar watches it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 23:27:01 +01:00

120 lines
8.0 KiB
QML

pragma Singleton
import QtQuick
import Quickshell
import "../services"
Singleton {
// Shared pill height for bar modules: 36px, shrinking to fit shorter bars.
readonly property int pillHeight: ConfigService.ready ? Math.max(24, Math.min(36, ConfigService.data.bar.height - 6)) : 36
readonly property var modules: ({
cpu: Qt.resolvedUrl("../bar/modules/MetricsModule.qml"),
cpuTemperature: Qt.resolvedUrl("../bar/modules/MetricsModule.qml"),
gpu: Qt.resolvedUrl("../bar/modules/MetricsModule.qml"),
gpuTemperature: Qt.resolvedUrl("../bar/modules/MetricsModule.qml"),
ram: Qt.resolvedUrl("../bar/modules/MetricsModule.qml"),
storage: Qt.resolvedUrl("../bar/modules/MetricsModule.qml"),
networkThroughput: Qt.resolvedUrl("../bar/modules/MetricsModule.qml"),
activeWindow: Qt.resolvedUrl("../bar/modules/ActiveWindowModule.qml"),
cava: Qt.resolvedUrl("../bar/modules/CavaModule.qml"),
nowPlaying: Qt.resolvedUrl("../bar/modules/NowPlayingModule.qml"),
settings: Qt.resolvedUrl("../bar/modules/SettingsModule.qml"),
workspaces: Qt.resolvedUrl("../bar/modules/WorkspacesModule.qml"),
clock: Qt.resolvedUrl("../bar/modules/ClockModule.qml"),
tray: Qt.resolvedUrl("../bar/modules/TrayModule.qml"),
system: Qt.resolvedUrl("../bar/modules/SystemModule.qml"),
volume: Qt.resolvedUrl("../bar/modules/VolumeModule.qml"),
caffeine: Qt.resolvedUrl("../bar/modules/CaffeineModule.qml"),
nightLight: Qt.resolvedUrl("../bar/modules/NightLightModule.qml")
})
// Installed plugin bar widgets are modules named "plugin:<id>".
function isPlugin(id) { return String(id).startsWith("plugin:"); }
function source(id) { return isPlugin(id) ? Qt.resolvedUrl("../bar/modules/PluginModule.qml") : modules[id] || ""; }
// Every module that can be added: built-ins plus enabled plugin widgets.
readonly property var available: Object.keys(modules).concat(PluginService.barModules)
// Readable names for the Settings → Bar editor.
readonly property var titles: ({
activeWindow: "Windows", cava: "Visualizer", clock: "Clock", cpu: "CPU", cpuTemperature: "CPU temp",
gpu: "GPU", gpuTemperature: "GPU temp", networkThroughput: "Network", nowPlaying: "Now playing",
ram: "Memory", settings: "Settings", storage: "Storage", system: "System", tray: "Tray",
volume: "Volume", workspaces: "Workspaces", caffeine: "Caffeine", nightLight: "Night Light"
})
function title(id) { return isPlugin(id) ? PluginService.title(String(id).slice(7)) : titles[id] || id; }
// Per-module options edited from the cog on each card in Settings → Bar.
// Stored on the module entry, so per-screen layouts can differ.
readonly property var optionSchemas: ({
activeWindow: [
{ key: "transition", label: "On switch", choices: ["fade", "slide", "pop", "none"], fallback: "fade" },
{ key: "labels", label: "Names", choices: ["all", "focused", "icons"], fallback: "all" },
{ key: "collapse", label: "Icons after", choices: ["3", "4", "6", "never"], fallback: "3" },
{ key: "labelWidth", label: "Name width", choices: ["short", "medium", "long"], fallback: "medium" },
{ key: "preview", label: "Hover preview", choices: ["on", "off"], fallback: "on" }
]
})
// Cog options stored outside the module entry: a config path shared by every
// layout (`setting`), or another module's enabled flag (`module`). Every cog
// opens inline; these mirror the controls on the module's settings page.
readonly property var metricsOptions: [
{ key: "interval", setting: "metrics.interval", label: "Sampling interval", type: "integer", min: 1, max: 30, description: "Seconds between samples, shared by every metric" }
]
readonly property var gpuOption: ({ key: "gpu", setting: "metrics.gpu", label: "GPU", type: "choice",
choices: ["auto"].concat(MetricsService.gpus.map(g => g.id)),
choiceLabels: ["Automatic"].concat(MetricsService.gpus.map(g => g.name)) })
readonly property var sharedOptions: ({
clock: [
{ key: "showDate", setting: "bar.clock.showDate", label: "Show date", type: "boolean" },
{ key: "use24Hour", setting: "bar.clock.use24Hour", label: "24-hour time", type: "boolean" },
{ key: "showSeconds", setting: "bar.clock.showSeconds", label: "Show seconds", type: "boolean" }
],
workspaces: [
{ key: "style", setting: "bar.workspaces.style", label: "Style", type: "choice", choices: ["numbers", "roman", "kanji", "dots", "pacman"] },
{ key: "preview", setting: "bar.workspaces.preview", label: "Preview on hover", type: "boolean" },
{ key: "count", setting: "bar.workspaces.count", label: "Count", type: "integer", min: 1, max: 20 }
],
tray: [
{ key: "background", setting: "tray.background", label: "Background", type: "choice", choices: ["pill", "transparent", "icons"] },
{ key: "hoverMenus", setting: "tray.hoverMenus", label: "Hover menus", type: "boolean", description: "Open application menus on hover" },
{ key: "iconSize", setting: "tray.iconSize", label: "Icon size", type: "integer", min: 16, max: 32 },
{ key: "spacing", setting: "tray.spacing", label: "Spacing", type: "integer", min: 0, max: 24 }
],
volume: [
{ key: "step", setting: "osd.step", label: "Step", type: "integer", min: 1, max: 20, description: "Percent per scroll or key press" }
],
cpu: metricsOptions,
cpuTemperature: metricsOptions,
ram: metricsOptions,
storage: metricsOptions,
gpu: metricsOptions.concat([gpuOption]),
gpuTemperature: metricsOptions.concat([gpuOption]),
networkThroughput: metricsOptions.concat([{ key: "networkInterface", setting: "metrics.networkInterface", label: "Interface", type: "choice",
description: "Auto totals physical interfaces to avoid counting VPN/bridge traffic twice",
choices: Array.from(new Set(["auto", ConfigService.ready ? ConfigService.data.metrics.networkInterface : "auto"].concat((MetricsService.network.interfaces || []).map(i => i.name)))) }]),
nowPlaying: [
{ key: "visualizer", module: "cava", label: "Visualizer", type: "boolean", description: "Cava bars beside the track; shows system audio and only runs while something plays" },
{ key: "cavaBars", setting: "bar.cava.bars", label: "Visualizer bars", type: "integer", min: 4, max: 24 },
{ key: "cavaStyle", setting: "bar.cava.style", label: "Visualizer style", type: "choice", choices: ["bars", "mirror"] },
{ key: "cavaHide", setting: "bar.cava.hideWhenIdle", label: "Hide while paused", type: "boolean" }
],
cava: [
{ key: "cavaBars", setting: "bar.cava.bars", label: "Bars", type: "integer", min: 4, max: 24 },
{ key: "cavaStyle", setting: "bar.cava.style", label: "Style", type: "choice", choices: ["bars", "mirror"] },
{ key: "cavaHide", setting: "bar.cava.hideWhenIdle", label: "Hide while paused", type: "boolean" }
]
})
// Modules with more on a settings page than fits the cog: the open cog
// ends with a link there.
readonly property var moreSettings: ({
volume: { page: "osd", title: "OSD" },
cpu: { page: "metrics", title: "Metrics" },
cpuTemperature: { page: "metrics", title: "Metrics" },
gpu: { page: "metrics", title: "Metrics" },
gpuTemperature: { page: "metrics", title: "Metrics" },
ram: { page: "metrics", title: "Metrics" },
storage: { page: "metrics", title: "Metrics" },
networkThroughput: { page: "metrics", title: "Metrics" }
})
function option(entry, key) {
const schema = (optionSchemas[entry.id] || []).find(o => o.key === key);
const value = entry.options ? entry.options[key] : undefined;
return schema && schema.choices.includes(value) ? value : schema ? schema.fallback : value;
}
}