mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-13 09:12:08 -04:00
cursor: more intelligent Xresources editing
This commit is contained in:
@@ -1804,17 +1804,23 @@ Singleton {
|
|||||||
|
|
||||||
function setCursorTheme(themeName) {
|
function setCursorTheme(themeName) {
|
||||||
const updated = JSON.parse(JSON.stringify(cursorSettings));
|
const updated = JSON.parse(JSON.stringify(cursorSettings));
|
||||||
|
if (updated.theme === themeName)
|
||||||
|
return;
|
||||||
updated.theme = themeName;
|
updated.theme = themeName;
|
||||||
cursorSettings = updated;
|
cursorSettings = updated;
|
||||||
saveSettings();
|
saveSettings();
|
||||||
|
updateXResources();
|
||||||
updateCompositorCursor();
|
updateCompositorCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
function setCursorSize(size) {
|
function setCursorSize(size) {
|
||||||
const updated = JSON.parse(JSON.stringify(cursorSettings));
|
const updated = JSON.parse(JSON.stringify(cursorSettings));
|
||||||
|
if (updated.size === size)
|
||||||
|
return;
|
||||||
updated.size = size;
|
updated.size = size;
|
||||||
cursorSettings = updated;
|
cursorSettings = updated;
|
||||||
saveSettings();
|
saveSettings();
|
||||||
|
updateXResources();
|
||||||
updateCompositorCursor();
|
updateCompositorCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1822,7 +1828,6 @@ Singleton {
|
|||||||
// https://github.com/Supreeeme/xwayland-satellite/issues/104
|
// https://github.com/Supreeeme/xwayland-satellite/issues/104
|
||||||
// no idea if this matters on other compositors but we also set XCURSOR stuff in the launcher
|
// no idea if this matters on other compositors but we also set XCURSOR stuff in the launcher
|
||||||
function updateCompositorCursor() {
|
function updateCompositorCursor() {
|
||||||
updateXResources();
|
|
||||||
if (typeof CompositorService === "undefined")
|
if (typeof CompositorService === "undefined")
|
||||||
return;
|
return;
|
||||||
if (CompositorService.isNiri && typeof NiriService !== "undefined") {
|
if (CompositorService.isNiri && typeof NiriService !== "undefined") {
|
||||||
@@ -1850,10 +1855,23 @@ Singleton {
|
|||||||
|
|
||||||
const script = `
|
const script = `
|
||||||
xresources_file="${xresourcesPath}"
|
xresources_file="${xresourcesPath}"
|
||||||
temp_file="\${xresources_file}.tmp.$$"
|
|
||||||
theme_name="${themeName}"
|
theme_name="${themeName}"
|
||||||
cursor_size="${size}"
|
cursor_size="${size}"
|
||||||
|
|
||||||
|
current_theme=""
|
||||||
|
current_size=""
|
||||||
|
if [ -f "$xresources_file" ]; then
|
||||||
|
current_theme=$(grep -E '^[[:space:]]*Xcursor\\.theme:' "$xresources_file" 2>/dev/null | sed 's/.*:[[:space:]]*//' | head -1)
|
||||||
|
current_size=$(grep -E '^[[:space:]]*Xcursor\\.size:' "$xresources_file" 2>/dev/null | sed 's/.*:[[:space:]]*//' | head -1)
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ "$current_theme" = "$theme_name" ] && [ "$current_size" = "$cursor_size" ] && exit 0
|
||||||
|
|
||||||
|
if [ -f "$xresources_file" ]; then
|
||||||
|
cp "$xresources_file" "\${xresources_file}.backup$(date +%s)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
temp_file="\${xresources_file}.tmp.$$"
|
||||||
if [ -f "$xresources_file" ]; then
|
if [ -f "$xresources_file" ]; then
|
||||||
grep -v '^[[:space:]]*Xcursor\\.theme:' "$xresources_file" | grep -v '^[[:space:]]*Xcursor\\.size:' > "$temp_file" 2>/dev/null || true
|
grep -v '^[[:space:]]*Xcursor\\.theme:' "$xresources_file" | grep -v '^[[:space:]]*Xcursor\\.size:' > "$temp_file" 2>/dev/null || true
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user