dotfiles/dot_local/bin/executable_fix_xcursor

49 lines
1.7 KiB
Text
Raw Normal View History

#! /usr/bin/env bash
2022-07-30 07:17:12 +02:00
# config files
gtk2=$HOME/.gtkrc-2.0
gtk3=$HOME/.config/gtk-3.0/settings.ini
[[ -e $HOME/.extend.Xresources ]] && xr=$HOME/.extend.Xresources || xr=$HOME/.Xresources
# we'll have to override libxcursor's default
default=share/icons/default/index.theme
glob_default=/usr/$default
user_default=$HOME/.local/$default
[[ -e $glob_default ]] && [[ ! -e $user_default ]] && install -D $glob_default "$user_default"
2022-07-30 07:17:12 +02:00
# cursor-theme entries
cursor_gtk2=$(grep "cursor-theme-name" "$gtk2" | cut -d'"' -f2)
cursor_gtk3=$(grep "cursor-theme-name" "$gtk3" | cut -d'=' -f2)
cursor_xr=$(grep "Xcursor.theme" "$xr" | cut -d' ' -f2)
2022-07-30 07:17:12 +02:00
cursor=$1
# find config last modified
if [ -z "$1" ]; then
2022-07-30 07:17:12 +02:00
cursor=$cursor_gtk2; newest=$gtk2
[[ $xr -nt $gtk2 ]] && [[ -n $cursor_xr ]] && cursor=$cursor_xr && newest=$xr
[[ $gtk3 -nt $newest ]] && [[ -n $cursor_gtk3 ]] && cursor=$cursor_gtk3
2022-07-30 07:17:12 +02:00
fi
# Strip any quotes from cursor string
cursor=${cursor/\"/}
2022-07-30 07:17:12 +02:00
# set theme in all config files
echo "setting cursortheme \"$cursor\""
[[ "$cursor" != "$cursor_xr" ]] && \
sed -i "s/Xcursor.theme:.*/Xcursor.theme: $cursor/g" "$xr" &>/dev/null && \
xrdb -merge -I"$HOME" ~/.Xresources
2022-07-30 07:17:12 +02:00
[[ "$cursor" != "$cursor_gtk2" ]] && \
sed -i "s/cursor-theme-name=\".*\"/cursor-theme-name=\"$cursor\"/" "$gtk2"
2022-07-30 07:17:12 +02:00
[[ "$cursor" != "$cursor_gtk3" ]] && \
sed -i "s/cursor-theme-name=.*/cursor-theme-name=$cursor/" "$gtk3" &>/dev/null
[[ -e $user_default ]] && sed -i "s/Inherits=.*/Inherits=$cursor/" "$user_default" &>/dev/null
2022-07-30 07:17:12 +02:00
# and in the realms of the GNOMEs
[[ -f /usr/bin/gconftool-2 ]] && gconftool-2 --type string -s /desktop/gnome/peripherals/mouse/cursor "$cursor"
[[ -f /usr/bin/gsettings ]] && gsettings set org.gnome.desktop.interface cursor-theme "$cursor"
2022-07-30 07:17:12 +02:00
exit
# oberon 2016