mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
hyprland: fix cursor setting
This commit is contained in:
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user