mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
feat: DMS Cursor Control - Size & Theme in niri
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -190,7 +190,13 @@ Singleton {
|
||||
|
||||
const userPrefix = SettingsData.launchPrefix?.trim() || "";
|
||||
const defaultPrefix = Quickshell.env("DMS_DEFAULT_LAUNCH_PREFIX") || "";
|
||||
const prefix = userPrefix.length > 0 ? userPrefix : defaultPrefix;
|
||||
const cursorPrefix = typeof SettingsData.getCursorEnvPrefix !== "undefined" ? SettingsData.getCursorEnvPrefix() : "";
|
||||
|
||||
let prefix = userPrefix.length > 0 ? userPrefix : defaultPrefix;
|
||||
if (cursorPrefix) {
|
||||
prefix = prefix.length > 0 ? `${cursorPrefix} ${prefix}` : cursorPrefix;
|
||||
}
|
||||
|
||||
const workDir = desktopEntry.workingDirectory || Quickshell.env("HOME");
|
||||
const escapedCmd = cmd.map(arg => escapeShellArg(arg)).join(" ");
|
||||
const shellCmd = prefix.length > 0 ? `${prefix} ${escapedCmd}` : escapedCmd;
|
||||
@@ -230,7 +236,12 @@ Singleton {
|
||||
|
||||
const userPrefix = SettingsData.launchPrefix?.trim() || "";
|
||||
const defaultPrefix = Quickshell.env("DMS_DEFAULT_LAUNCH_PREFIX") || "";
|
||||
const prefix = userPrefix.length > 0 ? userPrefix : defaultPrefix;
|
||||
const cursorPrefix = typeof SettingsData.getCursorEnvPrefix !== "undefined" ? SettingsData.getCursorEnvPrefix() : "";
|
||||
|
||||
let prefix = userPrefix.length > 0 ? userPrefix : defaultPrefix;
|
||||
if (cursorPrefix) {
|
||||
prefix = prefix.length > 0 ? `${cursorPrefix} ${prefix}` : cursorPrefix;
|
||||
}
|
||||
|
||||
if (prefix.length > 0 && needsShellExecution(prefix)) {
|
||||
const escapedCmd = cmd.map(arg => escapeShellArg(arg)).join(" ");
|
||||
|
||||
Reference in New Issue
Block a user