1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-30 00:12:50 -05:00

feat: DMS Cursor Control - Size & Theme in niri

This commit is contained in:
purian23
2026-01-06 19:08:05 -05:00
parent 8c9c936d0e
commit 721700190b
5 changed files with 251 additions and 2 deletions

View File

@@ -145,6 +145,20 @@ Singleton {
}
}
Process {
id: writeCursorProcess
property string cursorContent: ""
property string cursorPath: ""
onExited: exitCode => {
if (exitCode === 0) {
console.info("NiriService: Generated cursor config at", cursorPath);
return;
}
console.warn("NiriService: Failed to write cursor config, exit code:", exitCode);
}
}
Process {
id: ensureOutputsProcess
property string outputsPath: ""
@@ -1090,6 +1104,59 @@ Singleton {
writeBlurruleProcess.running = true;
}
function generateNiriCursorConfig() {
if (!CompositorService.isNiri)
return;
console.log("NiriService: Generating cursor config...");
const settings = typeof SettingsData !== "undefined" ? SettingsData.cursorSettings : {
theme: "System Default",
size: 24,
niri: {}
};
const themeName = settings.theme === "System Default" ? (SettingsData.systemDefaultCursorTheme || "") : settings.theme;
const size = settings.size || 24;
const hideWhenTyping = settings.niri?.hideWhenTyping || false;
const hideAfterMs = settings.niri?.hideAfterInactiveMs || 0;
const dmsWarning = `// ! DO NOT EDIT !
// ! AUTO-GENERATED BY DMS !
// ! CHANGES WILL BE OVERWRITTEN !
// ! PLACE YOUR CUSTOM CONFIGURATION ELSEWHERE !
`;
let cursorContent = dmsWarning + `cursor {\n`;
if (themeName) {
cursorContent += ` xcursor-theme "${themeName}"\n`;
}
cursorContent += ` xcursor-size ${size}\n`;
if (hideWhenTyping) {
cursorContent += ` hide-when-typing\n`;
}
if (hideAfterMs > 0) {
cursorContent += ` hide-after-inactive-ms ${hideAfterMs}\n`;
}
cursorContent += `}`;
const configDir = Paths.strip(StandardPaths.writableLocation(StandardPaths.ConfigLocation));
const niriDmsDir = configDir + "/niri/dms";
const cursorPath = niriDmsDir + "/cursor.kdl";
writeCursorProcess.cursorContent = cursorContent;
writeCursorProcess.cursorPath = cursorPath;
const escapedCursorContent = cursorContent.replace(/'/g, "'\\''");
writeCursorProcess.command = ["sh", "-c", `mkdir -p "${niriDmsDir}" && printf '%s' '${escapedCursorContent}' > "${cursorPath}"`];
writeCursorProcess.running = true;
}
function updateOutputPosition(outputName, x, y) {
if (!outputs || !outputs[outputName])
return;