From 033e62418ab29d4f20a6a7bba1504de06a0ac6d1 Mon Sep 17 00:00:00 2001 From: bbedward Date: Thu, 8 Jan 2026 09:30:52 -0500 Subject: [PATCH] hyprland: fix cursor setting --- quickshell/Services/HyprlandService.qml | 51 ++++++++++++++----------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/quickshell/Services/HyprlandService.qml b/quickshell/Services/HyprlandService.qml index 31fc6f26..0db4dd8e 100644 --- a/quickshell/Services/HyprlandService.qml +++ b/quickshell/Services/HyprlandService.qml @@ -247,8 +247,6 @@ decoration { 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) => { @@ -260,13 +258,15 @@ decoration { 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 hideOnTouch = settings.hyprland?.hideOnTouch || false; const inactiveTimeout = settings.hyprland?.inactiveTimeout || 0; - const isDefaultConfig = !themeName && size === 24 && !hideWhenTyping && !hideOnTouch && !hideOnKeyPress && inactiveTimeout === 0; - if (isDefaultConfig) { + const hasTheme = themeName && themeName.length > 0; + 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) => { if (exitCode !== 0) console.warn("HyprlandService: Failed to write cursor config:", output); @@ -274,32 +274,37 @@ decoration { return; } - let content = `# Auto-generated by DMS - do not edit manually + let lines = ["# Auto-generated by DMS - do not edit manually", ""]; -cursor { - size = ${size}`; + if (hasTheme) { + lines.push(`env = HYPRCURSOR_THEME,${themeName}`); + lines.push(`env = XCURSOR_THEME,${themeName}`); + } + lines.push(`env = HYPRCURSOR_SIZE,${size}`); + lines.push(`env = XCURSOR_SIZE,${size}`); - if (themeName) - content += `\n theme = ${themeName}`; + if (hasCursorSettings) { + lines.push(""); + lines.push("cursor {"); + if (hideOnKeyPress) + lines.push(" hide_on_key_press = true"); + if (hideOnTouch) + lines.push(" hide_on_touch = true"); + if (inactiveTimeout > 0) + lines.push(` inactive_timeout = ${inactiveTimeout}`); + lines.push("}"); + } - 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} -`; + 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) => { if (exitCode !== 0) { console.warn("HyprlandService: Failed to write cursor config:", output); return; } - console.info("HyprlandService: Generated cursor config at", cursorPath); + if (hasTheme) + Proc.runCommand("hyprctl-setcursor", ["hyprctl", "setcursor", themeName, String(size)], () => {}); reloadConfig(); }); }