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>
61 lines
2.5 KiB
QML
61 lines
2.5 KiB
QML
pragma Singleton
|
|
import QtQuick
|
|
import Quickshell
|
|
import "../services"
|
|
|
|
// Bar module layouts. Screens listed in `bar.screens` have their own module
|
|
// list (e.g. a narrow vertical monitor); every other screen uses `bar.modules`.
|
|
Singleton {
|
|
id: root
|
|
readonly property var screens: ConfigService.ready ? (ConfigService.data.bar.screens || ({})) : ({})
|
|
function hasOwn(screenName) {
|
|
return !!screenName && !!screens[screenName] && Array.isArray(screens[screenName].modules);
|
|
}
|
|
function modulesFor(screenName) {
|
|
if (!ConfigService.ready)
|
|
return [];
|
|
return hasOwn(screenName) ? screens[screenName].modules : ConfigService.data.bar.modules;
|
|
}
|
|
// Entries for a notch module list ("left", "right", "innerLeft",
|
|
// "innerRight" or "strip"). Each reuses the module's bar entry for its
|
|
// options when the layout has one.
|
|
function notchModules(screenName, key) {
|
|
if (!ConfigService.ready || !ConfigService.data.notch)
|
|
return [];
|
|
const layout = modulesFor(screenName);
|
|
return (ConfigService.data.notch[key] || []).map(id => Object.assign({}, layout.find(m => m.id === id) || {
|
|
id: id
|
|
}, {
|
|
id: id,
|
|
enabled: true,
|
|
notch: true,
|
|
// The spots beside the notch never draw pills.
|
|
bare: key === "innerLeft" || key === "innerRight",
|
|
position: key === "right" || key === "innerRight" ? "right" : key === "left" || key === "innerLeft" ? "left" : "center"
|
|
}));
|
|
}
|
|
// Saves to the screen's own layout when it has one, else the shared layout.
|
|
function save(screenName, modules) {
|
|
if (!hasOwn(screenName))
|
|
return ConfigService.setValue("bar.modules", modules);
|
|
const next = Object.assign({}, screens);
|
|
next[screenName] = Object.assign({}, next[screenName], {
|
|
modules: modules
|
|
});
|
|
return ConfigService.setValue("bar.screens", next);
|
|
}
|
|
// A new screen layout starts as a copy of the shared one.
|
|
function setOwn(screenName, own) {
|
|
if (!screenName || own === hasOwn(screenName))
|
|
return false;
|
|
const next = Object.assign({}, screens);
|
|
if (own)
|
|
next[screenName] = {
|
|
modules: ConfigService.data.bar.modules.map(m => Object.assign({}, m))
|
|
};
|
|
else
|
|
delete next[screenName];
|
|
return ConfigService.setValue("bar.screens", next);
|
|
}
|
|
}
|