1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-07 05:58:28 -04:00

niri/xray: make bar xray implicit, add conflict detection for

configuration
This commit is contained in:
bbedward
2026-07-02 10:05:23 -04:00
parent 57d08f6b3b
commit 9ff085c46a
9 changed files with 1686 additions and 1280 deletions
+67 -35
View File
@@ -49,6 +49,11 @@ Singleton {
property string _lastGeneratedAlttabContent: ""
readonly property bool frameLayoutReady: _layoutAppliedRevision >= _frameTransitionRevision
// dms/layout.kdl is the source of truth for xray; parsed once before the first regeneration
property bool layoutXrayEnabled: true
property bool _layoutXrayLoaded: false
property bool _layoutXrayLoading: false
readonly property string screenshotsDir: Paths.strip(StandardPaths.writableLocation(StandardPaths.PicturesLocation)) + "/Screenshots"
property string pendingScreenshotPath: ""
@@ -1094,6 +1099,28 @@ Singleton {
return _matchAndEnrichToplevels(toplevels, windows.filter(nw => outputWorkspaceIds.has(nw.workspace_id)));
}
function setLayoutXray(enabled) {
layoutXrayEnabled = enabled;
_layoutXrayLoaded = true;
generateNiriLayoutConfig();
}
function loadLayoutXrayState() {
if (_layoutXrayLoading)
return;
_layoutXrayLoading = true;
const configDir = Paths.strip(StandardPaths.writableLocation(StandardPaths.ConfigLocation));
Proc.runCommand("niri-read-layout-xray", ["cat", configDir + "/niri/dms/layout.kdl"], (output, exitCode) => {
_layoutXrayLoading = false;
if (!_layoutXrayLoaded) {
layoutXrayEnabled = exitCode !== 0 || !output.includes("xray false");
_layoutXrayLoaded = true;
}
if (configGenerationPending)
configGenerationAction.schedule();
});
}
function generateNiriLayoutConfig(frameTransition) {
if (!CompositorService.isNiri)
return;
@@ -1108,6 +1135,10 @@ Singleton {
function doGenerateNiriLayoutConfig() {
if (writeConfigProcess.running || _awaitingLayoutReloadRevision > _layoutAppliedRevision)
return;
if (!_layoutXrayLoaded) {
loadLayoutXrayState();
return;
}
configGenerationPending = false;
log.debug("Generating layout config...");
@@ -1118,63 +1149,65 @@ Singleton {
const cornerRadius = (typeof SettingsData !== "undefined" && SettingsData.niriLayoutRadiusOverride >= 0) ? SettingsData.niriLayoutRadiusOverride : defaultRadius;
const gaps = (typeof SettingsData !== "undefined" && SettingsData.niriLayoutGapsOverride >= 0) ? SettingsData.niriLayoutGapsOverride : defaultGaps;
const borderSize = (typeof SettingsData !== "undefined" && SettingsData.niriLayoutBorderSize >= 0) ? SettingsData.niriLayoutBorderSize : defaultBorderSize;
const xrayEnabled = typeof SettingsData !== "undefined" && SettingsData.niriLayoutXrayEnabled;
const barFrameXrayEnabled = typeof SettingsData === "undefined" || SettingsData.niriLayoutBarXrayEnabled;
const frameEnabled = typeof SettingsData !== "undefined" && SettingsData.frameEnabled;
const frameConnectedMode = frameEnabled && SettingsData.frameMode === "connected";
// Standalone Bar Xray is safe only while every active bar reserves its strip
// Bar/Frame sit flush on the wallpaper, so force the cheap xray blur whenever safe
const barFrameTargetNamespace = !frameEnabled ? (SettingsData.standaloneBarXrayAvailable ? "dms:bar" : null) : (frameConnectedMode ? null : "dms:frame");
// Xray is niri's default blur, so only the off state needs a rule
let xrayRules = "";
if (!xrayEnabled) {
if (!layoutXrayEnabled) {
xrayRules += `
layer-rule {
match namespace=".*"
background-effect {
layer-rule {
background-effect {
xray false
}
}`;
}
}`;
}
if (barFrameXrayEnabled && barFrameTargetNamespace) {
if (barFrameTargetNamespace) {
xrayRules += `
layer-rule {
match namespace="^${barFrameTargetNamespace}$"
background-effect {
layer-rule {
match namespace="^${barFrameTargetNamespace}$"
background-effect {
xray true
}
}`;
}
}`;
}
const dmsWarning = `// ! DO NOT EDIT !
// ! AUTO-GENERATED BY DMS !
// ! CHANGES WILL BE OVERWRITTEN !
// ! PLACE YOUR CUSTOM CONFIGURATION ELSEWHERE !
// ! AUTO-GENERATED BY DMS !
// ! CHANGES WILL BE OVERWRITTEN !
// ! PLACE YOUR CUSTOM CONFIGURATION ELSEWHERE !
`;
`;
const configContent = dmsWarning + `layout {
gaps ${gaps}
gaps ${gaps}
border {
border {
width ${borderSize}
}
}
focus-ring {
focus-ring {
width ${borderSize}
}
}
window-rule {
geometry-corner-radius ${cornerRadius}
clip-to-geometry true
tiled-state true
draw-border-with-background false
}` + xrayRules;
}
}
window-rule {
geometry-corner-radius ${cornerRadius}
clip-to-geometry true
tiled-state true
draw-border-with-background false
}` + xrayRules;
const alttabContent = dmsWarning + `recent-windows {
highlight {
highlight {
corner-radius ${cornerRadius}
}
}`;
}
}`;
const configDir = Paths.strip(StandardPaths.writableLocation(StandardPaths.ConfigLocation));
const niriDmsDir = configDir + "/niri/dms";
@@ -1203,7 +1236,6 @@ Singleton {
log.warn("Failed to ensure " + name + ".kdl, exit code:", exitCode);
});
}
}
function generateNiriBlurrule() {