1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-06 13:38: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
+34 -5
View File
@@ -32,6 +32,11 @@ Singleton {
property int _frameTransitionRevision: 0
readonly property bool frameLayoutReady: _layoutAppliedRevision >= _frameTransitionRevision
// dms/layout.lua is the source of truth for xray; parsed once before the first regeneration
property bool layoutXrayEnabled: false
property bool _layoutXrayLoaded: false
property bool _layoutXrayLoading: false
DeferredAction {
id: layoutGenerationAction
onTriggered: root.doGenerateLayoutConfig()
@@ -262,6 +267,28 @@ Singleton {
});
}
function setLayoutXray(enabled) {
layoutXrayEnabled = enabled;
_layoutXrayLoaded = true;
generateLayoutConfig();
}
function loadLayoutXrayState() {
if (_layoutXrayLoading)
return;
_layoutXrayLoading = true;
const configDir = Paths.strip(StandardPaths.writableLocation(StandardPaths.ConfigLocation));
Proc.runCommand("hypr-read-layout-xray", ["cat", configDir + "/hypr/dms/layout.lua"], (output, exitCode) => {
_layoutXrayLoading = false;
if (!_layoutXrayLoaded) {
layoutXrayEnabled = exitCode === 0 && output.includes('"^dms:.*$"');
_layoutXrayLoaded = true;
}
if (layoutGenerationPending)
layoutGenerationAction.schedule();
});
}
function generateLayoutConfig(frameTransition) {
if (!CompositorService.isHyprland)
return;
@@ -275,6 +302,10 @@ Singleton {
function doGenerateLayoutConfig() {
if (layoutGenerationRunning)
return;
if (!_layoutXrayLoaded) {
loadLayoutXrayState();
return;
}
layoutGenerationPending = false;
const requestRevision = _layoutRequestRevision;
if (!canWriteLuaConfig("layout")) {
@@ -295,12 +326,10 @@ Singleton {
const gaps = (typeof SettingsData !== "undefined" && SettingsData.hyprlandLayoutGapsOverride >= 0) ? SettingsData.hyprlandLayoutGapsOverride : defaultGaps;
const borderSize = (typeof SettingsData !== "undefined" && SettingsData.hyprlandLayoutBorderSize >= 0) ? SettingsData.hyprlandLayoutBorderSize : defaultBorderSize;
const resizeOnBorder = (typeof SettingsData !== "undefined" && SettingsData.hyprlandResizeOnBorder) ? true : false;
const xrayEnabled = typeof SettingsData !== "undefined" && SettingsData.hyprlandLayoutXrayEnabled;
const barFrameXrayEnabled = typeof SettingsData === "undefined" || SettingsData.hyprlandLayoutBarXrayEnabled;
const frameEnabled = typeof SettingsData !== "undefined" && SettingsData.frameEnabled;
const frameConnectedMode = frameEnabled && SettingsData.frameMode === "connected";
// Hyprland `xray = false` is still early-development; unset already samples real content, so only force xray=true
// 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");
let content = `-- Auto-generated by DMS do not edit manually
@@ -318,7 +347,7 @@ hl.config({
})
`;
if (xrayEnabled) {
if (layoutXrayEnabled) {
content += `
hl.layer_rule({
match = { namespace = "^dms:.*$" },
@@ -326,7 +355,7 @@ hl.layer_rule({
})
`;
}
if (barFrameXrayEnabled && barFrameTargetNamespace) {
if (barFrameTargetNamespace) {
content += `
hl.layer_rule({
match = { namespace = "^${barFrameTargetNamespace}$" },
+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() {