mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-07 14:08:29 -04:00
niri/xray: make bar xray implicit, add conflict detection for
configuration
This commit is contained in:
@@ -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}$" },
|
||||
|
||||
Reference in New Issue
Block a user