1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -05:00

cursor: hypr, mango, and dankinstall support for configs

This commit is contained in:
bbedward
2026-01-06 20:35:22 -05:00
parent 721700190b
commit ad43053b94
24 changed files with 2741 additions and 709 deletions

View File

@@ -14,6 +14,7 @@ Singleton {
readonly property string mangoDmsDir: configDir + "/mango/dms"
readonly property string outputsPath: mangoDmsDir + "/outputs.conf"
readonly property string layoutPath: mangoDmsDir + "/layout.conf"
readonly property string cursorPath: mangoDmsDir + "/cursor.conf"
property int _lastGapValue: -1
@@ -400,4 +401,53 @@ borderpx=${borderSize}
return 0;
}
}
function generateCursorConfig() {
if (!CompositorService.isDwl)
return;
console.log("DwlService: Generating cursor config...");
const settings = typeof SettingsData !== "undefined" ? SettingsData.cursorSettings : null;
if (!settings) {
Proc.runCommand("mango-write-cursor", ["sh", "-c", `mkdir -p "${mangoDmsDir}" && : > "${cursorPath}"`], (output, exitCode) => {
if (exitCode !== 0)
console.warn("DwlService: Failed to write cursor config:", output);
});
return;
}
const themeName = settings.theme === "System Default" ? (SettingsData.systemDefaultCursorTheme || "") : settings.theme;
const size = settings.size || 24;
const hideTimeout = settings.dwl?.cursorHideTimeout || 0;
const isDefaultConfig = !themeName && size === 24 && hideTimeout === 0;
if (isDefaultConfig) {
Proc.runCommand("mango-write-cursor", ["sh", "-c", `mkdir -p "${mangoDmsDir}" && : > "${cursorPath}"`], (output, exitCode) => {
if (exitCode !== 0)
console.warn("DwlService: Failed to write cursor config:", output);
});
return;
}
let content = `# Auto-generated by DMS - do not edit manually
cursor_size=${size}`;
if (themeName)
content += `\ncursor_theme=${themeName}`;
if (hideTimeout > 0)
content += `\ncursor_hide_timeout=${hideTimeout}`;
content += `\n`;
Proc.runCommand("mango-write-cursor", ["sh", "-c", `mkdir -p "${mangoDmsDir}" && cat > "${cursorPath}" << 'EOF'\n${content}EOF`], (output, exitCode) => {
if (exitCode !== 0) {
console.warn("DwlService: Failed to write cursor config:", output);
return;
}
console.info("DwlService: Generated cursor config at", cursorPath);
reloadConfig();
});
}
}

View File

@@ -13,6 +13,7 @@ Singleton {
readonly property string hyprDmsDir: configDir + "/hypr/dms"
readonly property string outputsPath: hyprDmsDir + "/outputs.conf"
readonly property string layoutPath: hyprDmsDir + "/layout.conf"
readonly property string cursorPath: hyprDmsDir + "/cursor.conf"
property int _lastGapValue: -1
@@ -241,4 +242,65 @@ decoration {
return "Normal";
}
}
function generateCursorConfig() {
if (!CompositorService.isHyprland)
return;
console.log("HyprlandService: Generating cursor config...");
const settings = typeof SettingsData !== "undefined" ? SettingsData.cursorSettings : null;
if (!settings) {
Proc.runCommand("hypr-write-cursor", ["sh", "-c", `mkdir -p "${hyprDmsDir}" && : > "${cursorPath}"`], (output, exitCode) => {
if (exitCode !== 0)
console.warn("HyprlandService: Failed to write cursor config:", output);
});
return;
}
const themeName = settings.theme === "System Default" ? (SettingsData.systemDefaultCursorTheme || "") : settings.theme;
const size = settings.size || 24;
const hideWhenTyping = settings.hyprland?.hideWhenTyping || false;
const hideOnTouch = settings.hyprland?.hideOnTouch || false;
const hideOnKeyPress = settings.hyprland?.hideOnKeyPress || false;
const inactiveTimeout = settings.hyprland?.inactiveTimeout || 0;
const isDefaultConfig = !themeName && size === 24 && !hideWhenTyping && !hideOnTouch && !hideOnKeyPress && inactiveTimeout === 0;
if (isDefaultConfig) {
Proc.runCommand("hypr-write-cursor", ["sh", "-c", `mkdir -p "${hyprDmsDir}" && : > "${cursorPath}"`], (output, exitCode) => {
if (exitCode !== 0)
console.warn("HyprlandService: Failed to write cursor config:", output);
});
return;
}
let content = `# Auto-generated by DMS - do not edit manually
cursor {
size = ${size}`;
if (themeName)
content += `\n theme = ${themeName}`;
if (hideWhenTyping)
content += `\n hide_on_key_press = true`;
if (hideOnTouch)
content += `\n hide_on_touch = true`;
if (inactiveTimeout > 0)
content += `\n inactive_timeout = ${inactiveTimeout}`;
content += `\n}
`;
Proc.runCommand("hypr-write-cursor", ["sh", "-c", `mkdir -p "${hyprDmsDir}" && cat > "${cursorPath}" << 'EOF'\n${content}EOF`], (output, exitCode) => {
if (exitCode !== 0) {
console.warn("HyprlandService: Failed to write cursor config:", output);
return;
}
console.info("HyprlandService: Generated cursor config at", cursorPath);
reloadConfig();
});
}
}

View File

@@ -179,6 +179,16 @@ Singleton {
}
}
Process {
id: ensureCursorProcess
property string cursorPath: ""
onExited: exitCode => {
if (exitCode !== 0)
console.warn("NiriService: Failed to ensure cursor.kdl, exit code:", exitCode);
}
}
DankSocket {
id: eventStreamSocket
path: root.socketPath
@@ -1088,6 +1098,11 @@ Singleton {
ensureBindsProcess.command = ["sh", "-c", `mkdir -p "${niriDmsDir}" && [ ! -f "${bindsPath}" ] && touch "${bindsPath}" || true`];
ensureBindsProcess.running = true;
const cursorPath = niriDmsDir + "/cursor.kdl";
ensureCursorProcess.cursorPath = cursorPath;
ensureCursorProcess.command = ["sh", "-c", `mkdir -p "${niriDmsDir}" && [ ! -f "${cursorPath}" ] && touch "${cursorPath}" || true`];
ensureCursorProcess.running = true;
configGenerationPending = false;
}
@@ -1110,16 +1125,33 @@ Singleton {
console.log("NiriService: Generating cursor config...");
const settings = typeof SettingsData !== "undefined" ? SettingsData.cursorSettings : {
theme: "System Default",
size: 24,
niri: {}
};
const configDir = Paths.strip(StandardPaths.writableLocation(StandardPaths.ConfigLocation));
const niriDmsDir = configDir + "/niri/dms";
const cursorPath = niriDmsDir + "/cursor.kdl";
const settings = typeof SettingsData !== "undefined" ? SettingsData.cursorSettings : null;
if (!settings) {
writeCursorProcess.cursorContent = "";
writeCursorProcess.cursorPath = cursorPath;
writeCursorProcess.command = ["sh", "-c", `mkdir -p "${niriDmsDir}" && : > "${cursorPath}"`];
writeCursorProcess.running = true;
return;
}
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 isDefaultConfig = !themeName && size === 24 && !hideWhenTyping && hideAfterMs === 0;
if (isDefaultConfig) {
writeCursorProcess.cursorContent = "";
writeCursorProcess.cursorPath = cursorPath;
writeCursorProcess.command = ["sh", "-c", `mkdir -p "${niriDmsDir}" && : > "${cursorPath}"`];
writeCursorProcess.running = true;
return;
}
const dmsWarning = `// ! DO NOT EDIT !
// ! AUTO-GENERATED BY DMS !
// ! CHANGES WILL BE OVERWRITTEN !
@@ -1129,25 +1161,19 @@ Singleton {
let cursorContent = dmsWarning + `cursor {\n`;
if (themeName) {
if (themeName)
cursorContent += ` xcursor-theme "${themeName}"\n`;
}
cursorContent += ` xcursor-size ${size}\n`;
if (hideWhenTyping) {
if (hideWhenTyping)
cursorContent += ` hide-when-typing\n`;
}
if (hideAfterMs > 0) {
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;

View File

@@ -184,84 +184,76 @@ Singleton {
function launchDesktopEntry(desktopEntry, useNvidia) {
let cmd = desktopEntry.command;
if (useNvidia && nvidiaCommand) {
if (useNvidia && nvidiaCommand)
cmd = [nvidiaCommand].concat(cmd);
}
const userPrefix = SettingsData.launchPrefix?.trim() || "";
const defaultPrefix = Quickshell.env("DMS_DEFAULT_LAUNCH_PREFIX") || "";
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 prefix = userPrefix.length > 0 ? userPrefix : defaultPrefix;
const workDir = desktopEntry.workingDirectory || Quickshell.env("HOME");
const escapedCmd = cmd.map(arg => escapeShellArg(arg)).join(" ");
const shellCmd = prefix.length > 0 ? `${prefix} ${escapedCmd}` : escapedCmd;
const cursorEnv = typeof SettingsData.getCursorEnvironment === "function" ? SettingsData.getCursorEnvironment() : {};
if (desktopEntry.runInTerminal) {
const terminal = Quickshell.env("TERMINAL") || "xterm";
const escapedCmd = cmd.map(arg => escapeShellArg(arg)).join(" ");
const shellCmd = prefix.length > 0 ? `${prefix} ${escapedCmd}` : escapedCmd;
Quickshell.execDetached({
command: [terminal, "-e", "sh", "-c", shellCmd],
workingDirectory: workDir
workingDirectory: workDir,
environment: cursorEnv
});
return;
}
if (prefix.length > 0 && needsShellExecution(prefix)) {
const escapedCmd = cmd.map(arg => escapeShellArg(arg)).join(" ");
Quickshell.execDetached({
command: ["sh", "-c", shellCmd],
workingDirectory: workDir
command: ["sh", "-c", `${prefix} ${escapedCmd}`],
workingDirectory: workDir,
environment: cursorEnv
});
return;
}
if (prefix.length > 0) {
if (prefix.length > 0)
cmd = prefix.split(" ").concat(cmd);
}
Quickshell.execDetached({
command: cmd,
workingDirectory: workDir
workingDirectory: workDir,
environment: cursorEnv
});
}
function launchDesktopAction(desktopEntry, action, useNvidia) {
let cmd = action.command;
if (useNvidia && nvidiaCommand) {
if (useNvidia && nvidiaCommand)
cmd = [nvidiaCommand].concat(cmd);
}
const userPrefix = SettingsData.launchPrefix?.trim() || "";
const defaultPrefix = Quickshell.env("DMS_DEFAULT_LAUNCH_PREFIX") || "";
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 prefix = userPrefix.length > 0 ? userPrefix : defaultPrefix;
const workDir = desktopEntry.workingDirectory || Quickshell.env("HOME");
const cursorEnv = typeof SettingsData.getCursorEnvironment === "function" ? SettingsData.getCursorEnvironment() : {};
if (prefix.length > 0 && needsShellExecution(prefix)) {
const escapedCmd = cmd.map(arg => escapeShellArg(arg)).join(" ");
const shellCmd = `${prefix} ${escapedCmd}`;
Quickshell.execDetached({
command: ["sh", "-c", shellCmd],
workingDirectory: desktopEntry.workingDirectory || Quickshell.env("HOME")
});
} else {
if (prefix.length > 0) {
const launchPrefix = prefix.split(" ");
cmd = launchPrefix.concat(cmd);
}
Quickshell.execDetached({
command: cmd,
workingDirectory: desktopEntry.workingDirectory || Quickshell.env("HOME")
command: ["sh", "-c", `${prefix} ${escapedCmd}`],
workingDirectory: workDir,
environment: cursorEnv
});
return;
}
if (prefix.length > 0)
cmd = prefix.split(" ").concat(cmd);
Quickshell.execDetached({
command: cmd,
workingDirectory: workDir,
environment: cursorEnv
});
}
// * Session management