Skip to content

Commit c26bc0f

Browse files
committed
feat: set Xresource and Xdefaultffor cursors too
1 parent 09c37dc commit c26bc0f

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

Configs/.local/lib/hyde/theme.switch.sh

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ else
117117
fi
118118
GTK_ICON="$(get_hyprConf "ICON_THEME")"
119119
CURSOR_THEME="$(get_hyprConf "CURSOR_THEME")"
120+
CURSOR_SIZE=${_CURSOR_SIZE:-"$(get_hyprConf "CURSOR_SIZE")"}
120121
font_name="$(get_hyprConf "FONT")"
121122
font_size="$(get_hyprConf "FONT_SIZE")"
122123
monospace_font_name="$(get_hyprConf "MONOSPACE_FONT")"
@@ -179,6 +180,7 @@ sed -i -e "/^gtk-theme-name=/c\gtk-theme-name=\"${GTK_THEME}\"" \
179180
toml_write "${confDir}/gtk-3.0/settings.ini" "Settings" "gtk-theme-name" "${GTK_THEME}"
180181
toml_write "${confDir}/gtk-3.0/settings.ini" "Settings" "gtk-icon-theme-name" "${GTK_ICON}"
181182
toml_write "${confDir}/gtk-3.0/settings.ini" "Settings" "gtk-cursor-theme-name" "${CURSOR_THEME}"
183+
toml_write "${confDir}/gtk-3.0/settings.ini" "Settings" "gtk-cursor-theme-size" "${CURSOR_SIZE}"
182184
toml_write "${confDir}/gtk-3.0/settings.ini" "Settings" "gtk-font-name" "${font_name} ${font_size}"
183185

184186
#// gtk4
@@ -210,7 +212,8 @@ fi
210212

211213
sed -i -e "/^Net\/ThemeName /c\Net\/ThemeName \"${GTK_THEME}\"" \
212214
-e "/^Net\/IconThemeName /c\Net\/IconThemeName \"${GTK_ICON}\"" \
213-
-e "/^Gtk\/CURSOR_THEMEName /c\Gtk\/CURSOR_THEMEName \"${CURSOR_THEME}\"" \
215+
-e "/^Gtk\/CursorThemeName /c\Gtk\/CursorThemeName \"${CURSOR_THEME}\"" \
216+
-e "/^Gtk\/CursorThemeSize /c\Gtk\/CursorThemeSize ${CURSOR_SIZE}" \
214217
"$confDir/xsettingsd/xsettingsd.conf"
215218

216219
# // Legacy themes using ~/.themes also fixed GTK4 not following xdg
@@ -222,6 +225,33 @@ if [ ! -L "$HOME/.themes/${GTK_THEME}" ] && [ -d "${themesDir}/${GTK_THEME}" ];
222225
ln -snf "${themesDir}/${GTK_THEME}" "$HOME/.themes/"
223226
fi
224227

228+
# // .Xresources
229+
if [ -f "$HOME/.Xresources" ]; then
230+
sed -i -e "/^Xcursor\.theme:/c\Xcursor.theme: ${CURSOR_THEME}" \
231+
-e "/^Xcursor\.size:/c\Xcursor.size: ${CURSOR_SIZE}" "$HOME/.Xresources"
232+
233+
# Add if they don't exist
234+
grep -q "^Xcursor\.theme:" "$HOME/.Xresources" || echo "Xcursor.theme: ${CURSOR_THEME}" >>"$HOME/.Xresources"
235+
grep -q "^Xcursor\.size:" "$HOME/.Xresources" || echo "Xcursor.size: 30" >>"$HOME/.Xresources"
236+
else
237+
# Create .Xresources if it doesn't exist
238+
cat >"$HOME/.Xresources" <<EOF
239+
Xcursor.theme: ${CURSOR_THEME}
240+
Xcursor.size: ${CURSOR_SIZE}
241+
EOF
242+
fi
243+
244+
# // .Xdefaults
245+
246+
if [ -f "$HOME/.Xdefaults" ]; then
247+
sed -i -e "/^Xcursor\.theme:/c\Xcursor.theme: ${CURSOR_THEME}" \
248+
-e "/^Xcursor\.size:/c\Xcursor.size: ${CURSOR_SIZE}" "$HOME/.Xdefaults"
249+
250+
# Add if they don't exist
251+
grep -q "^Xcursor\.theme:" "$HOME/.Xdefaults" || echo "Xcursor.theme: ${CURSOR_THEME}" >>"$HOME/.Xdefaults"
252+
grep -q "^Xcursor\.size:" "$HOME/.Xdefaults" || echo "Xcursor.size: 30" >>"$HOME/.Xdefaults"
253+
fi
254+
225255
#// wallpaper
226256
export -f pkg_installed
227257
export scrDir

0 commit comments

Comments
 (0)