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

hyprland: fix cursor setting

This commit is contained in:
bbedward
2026-01-08 09:30:52 -05:00
parent 3c69e8b1cc
commit 033e62418a

View File

@@ -247,8 +247,6 @@ decoration {
if (!CompositorService.isHyprland) if (!CompositorService.isHyprland)
return; return;
console.log("HyprlandService: Generating cursor config...");
const settings = typeof SettingsData !== "undefined" ? SettingsData.cursorSettings : null; const settings = typeof SettingsData !== "undefined" ? SettingsData.cursorSettings : null;
if (!settings) { if (!settings) {
Proc.runCommand("hypr-write-cursor", ["sh", "-c", `mkdir -p "${hyprDmsDir}" && : > "${cursorPath}"`], (output, exitCode) => { Proc.runCommand("hypr-write-cursor", ["sh", "-c", `mkdir -p "${hyprDmsDir}" && : > "${cursorPath}"`], (output, exitCode) => {
@@ -260,13 +258,15 @@ decoration {
const themeName = settings.theme === "System Default" ? (SettingsData.systemDefaultCursorTheme || "") : settings.theme; const themeName = settings.theme === "System Default" ? (SettingsData.systemDefaultCursorTheme || "") : settings.theme;
const size = settings.size || 24; const size = settings.size || 24;
const hideWhenTyping = settings.hyprland?.hideWhenTyping || false;
const hideOnTouch = settings.hyprland?.hideOnTouch || false;
const hideOnKeyPress = settings.hyprland?.hideOnKeyPress || false; const hideOnKeyPress = settings.hyprland?.hideOnKeyPress || false;
const hideOnTouch = settings.hyprland?.hideOnTouch || false;
const inactiveTimeout = settings.hyprland?.inactiveTimeout || 0; const inactiveTimeout = settings.hyprland?.inactiveTimeout || 0;
const isDefaultConfig = !themeName && size === 24 && !hideWhenTyping && !hideOnTouch && !hideOnKeyPress && inactiveTimeout === 0; const hasTheme = themeName && themeName.length > 0;
if (isDefaultConfig) { const hasNonDefaultSize = size !== 24;
const hasCursorSettings = hideOnKeyPress || hideOnTouch || inactiveTimeout > 0;
if (!hasTheme && !hasNonDefaultSize && !hasCursorSettings) {
Proc.runCommand("hypr-write-cursor", ["sh", "-c", `mkdir -p "${hyprDmsDir}" && : > "${cursorPath}"`], (output, exitCode) => { Proc.runCommand("hypr-write-cursor", ["sh", "-c", `mkdir -p "${hyprDmsDir}" && : > "${cursorPath}"`], (output, exitCode) => {
if (exitCode !== 0) if (exitCode !== 0)
console.warn("HyprlandService: Failed to write cursor config:", output); console.warn("HyprlandService: Failed to write cursor config:", output);
@@ -274,32 +274,37 @@ decoration {
return; return;
} }
let content = `# Auto-generated by DMS - do not edit manually let lines = ["# Auto-generated by DMS - do not edit manually", ""];
cursor { if (hasTheme) {
size = ${size}`; lines.push(`env = HYPRCURSOR_THEME,${themeName}`);
lines.push(`env = XCURSOR_THEME,${themeName}`);
if (themeName) }
content += `\n theme = ${themeName}`; lines.push(`env = HYPRCURSOR_SIZE,${size}`);
lines.push(`env = XCURSOR_SIZE,${size}`);
if (hideWhenTyping)
content += `\n hide_on_key_press = true`;
if (hasCursorSettings) {
lines.push("");
lines.push("cursor {");
if (hideOnKeyPress)
lines.push(" hide_on_key_press = true");
if (hideOnTouch) if (hideOnTouch)
content += `\n hide_on_touch = true`; lines.push(" hide_on_touch = true");
if (inactiveTimeout > 0) if (inactiveTimeout > 0)
content += `\n inactive_timeout = ${inactiveTimeout}`; lines.push(` inactive_timeout = ${inactiveTimeout}`);
lines.push("}");
}
content += `\n} lines.push("");
`; const content = lines.join("\n");
Proc.runCommand("hypr-write-cursor", ["sh", "-c", `mkdir -p "${hyprDmsDir}" && cat > "${cursorPath}" << 'EOF'\n${content}EOF`], (output, exitCode) => { Proc.runCommand("hypr-write-cursor", ["sh", "-c", `mkdir -p "${hyprDmsDir}" && cat > "${cursorPath}" << 'EOF'\n${content}EOF`], (output, exitCode) => {
if (exitCode !== 0) { if (exitCode !== 0) {
console.warn("HyprlandService: Failed to write cursor config:", output); console.warn("HyprlandService: Failed to write cursor config:", output);
return; return;
} }
console.info("HyprlandService: Generated cursor config at", cursorPath); if (hasTheme)
Proc.runCommand("hyprctl-setcursor", ["hyprctl", "setcursor", themeName, String(size)], () => {});
reloadConfig(); reloadConfig();
}); });
} }