Scales up the mouse pointer too plus other fixes
This commit is contained in:
parent
d389039f0d
commit
b800bf0bcc
|
@ -11,30 +11,91 @@ flatpak_icons_dir="$HOME/.icons"
|
||||||
mkdir -p "$flatpak_themes_dir" "$flatpak_icons_dir" ||
|
mkdir -p "$flatpak_themes_dir" "$flatpak_icons_dir" ||
|
||||||
{ echo "failed to make directories $flatpak_themes_dir & $flatpak_icons_dir"; exit 1; }
|
{ echo "failed to make directories $flatpak_themes_dir & $flatpak_icons_dir"; exit 1; }
|
||||||
|
|
||||||
|
xdg_directory_lookup() {
|
||||||
|
# Go through each item in $XDG_DATA_DIRS and find the subdirectory $1
|
||||||
|
while read -r dir; do
|
||||||
|
subdir="${dir%/}/$1"
|
||||||
|
if [ -d "$subdir" ]; then
|
||||||
|
echo "$subdir"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done < <(printf '%s:%s\n' "$HOME/.local/share" "$XDG_DATA_DIRS" | tr ':' '\n')
|
||||||
|
}
|
||||||
|
|
||||||
|
hdpi_theme_fix() {
|
||||||
|
# Get the current window scaling factor (highDPI setting)
|
||||||
|
current_scaling=$(xfconf-query -c xsettings -p /Gdk/WindowScalingFactor)
|
||||||
|
# Get the current XFWM theme
|
||||||
|
current_xfwm_theme=$(xfconf-query -c xfwm4 -p /general/theme)
|
||||||
|
# Get the current mouse cursor size
|
||||||
|
cursor_size=$(xfconf-query -c xsettings -p /Gtk/CursorThemeSize)
|
||||||
|
|
||||||
|
if [ "$current_scaling" -eq '2' ]; then
|
||||||
|
# Increase mouse cursor size if it's less than 45
|
||||||
|
if [ "$cursor_size" -lt 45 ]; then
|
||||||
|
xfconf-query -c xsettings -p /Gtk/CursorThemeSize -s '45'
|
||||||
|
notify-send 'Mouse cursor size increased to 45' "Changed to a larger mouse cursor because you've enabled highDPI on your system"
|
||||||
|
fi
|
||||||
|
for variant in xhdpi hdpi; do
|
||||||
|
# If this variant of the theme is already enabled then break out of the loop
|
||||||
|
[ "${current_xfwm_theme##*-}" = "$variant" ] && break
|
||||||
|
# Store the name for this variant of the theme in highDPI_theme variable
|
||||||
|
highDPI_theme=$current_xfwm_theme-$variant
|
||||||
|
# Find the directory where highDPI_theme is stored
|
||||||
|
highDPI_theme_dir=$(xdg_directory_lookup "themes/$highDPI_theme")
|
||||||
|
# If this directory exists then change to that theme for XFWM
|
||||||
|
if [ -d "$highDPI_theme_dir" ]; then
|
||||||
|
xfconf-query -c xfwm4 -p /general/theme -n -t string -s "$highDPI_theme"
|
||||||
|
notify-send "XFWM theme changed to $highDPI_theme" "Changed to the highDPI variant of your chosen theme because you've enabled highDPI on your system"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
# Decrease mouse cursor size if it's greater than or equal to 45
|
||||||
|
if [ "$cursor_size" -ge 45 ]; then
|
||||||
|
xfconf-query -c xsettings -p /Gtk/CursorThemeSize -s '25'
|
||||||
|
notify-send 'Mouse cursor size decreased to 25' "Changed to a smaller mouse cursor because you've disabled highDPI on your system"
|
||||||
|
fi
|
||||||
|
for variant in xhdpi hdpi; do
|
||||||
|
# Continue looping if this (highDPI) variant of the theme is not enabled
|
||||||
|
[ "${current_xfwm_theme##*-}" != "$variant" ] && continue
|
||||||
|
# Store the name for the normal variant of this theme in normal_theme variable
|
||||||
|
normal_theme=${current_xfwm_theme%-"$variant"}
|
||||||
|
# Find the directory where normal_theme is stored
|
||||||
|
normal_theme_dir=$(xdg_directory_lookup "themes/$normal_theme")
|
||||||
|
# If this directory exists then change to that theme for XFWM
|
||||||
|
if [ -d "$normal_theme_dir" ]; then
|
||||||
|
xfconf-query -c xfwm4 -p /general/theme -n -t string -s "$normal_theme"
|
||||||
|
notify-send "XFWM theme changed to $normal_theme" "Changed to the normal variant of your chosen theme because you've disabled highDPI on your system"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
sync_theme() {
|
sync_theme() {
|
||||||
# Get the current system theme
|
# Get the current system theme
|
||||||
current_theme=$(xfconf-query -c xsettings -p /Net/ThemeName)
|
current_theme=$(xfconf-query -c xsettings -p /Net/ThemeName)
|
||||||
|
|
||||||
# Enable syncing the current theme with xfwm4 theme if not already enabled
|
# Enable syncing the current theme with XFWM theme if not already enabled
|
||||||
[ "$(xfconf-query -c xsettings -p /Xfce/SyncThemes)" != 'true' ] && xfconf-query -c xsettings -p /Xfce/SyncThemes -n -t bool -s true
|
[ "$(xfconf-query -c xsettings -p /Xfce/SyncThemes)" != 'true' ] && xfconf-query -c xsettings -p /Xfce/SyncThemes -n -t bool -s true
|
||||||
# Apply the current theme with gsettings
|
# Apply the current theme with gsettings
|
||||||
gsettings set org.gnome.desktop.interface gtk-theme "$current_theme"
|
gsettings set org.gnome.desktop.interface gtk-theme "$current_theme"
|
||||||
# Apply the current theme for GTK and Libadwaita apps on flatpak
|
# Apply the current theme for GTK and Libadwaita apps on flatpak
|
||||||
flatpak override --user --env=GTK_THEME="$current_theme"
|
flatpak override --user --env=GTK_THEME="$current_theme"
|
||||||
|
|
||||||
|
# Change XFWM theme and mouse cursor size according to the user's highDPI setting
|
||||||
|
hdpi_theme_fix
|
||||||
|
|
||||||
|
|
||||||
# Cleanup flatpak_themes_dir
|
# Cleanup flatpak_themes_dir
|
||||||
rm -rf "${flatpak_themes_dir:?}"/*
|
rm -rf "${flatpak_themes_dir:?}"/*
|
||||||
|
|
||||||
# Go through each item in $XDG_DATA_DIRS to find the directory where
|
# Find the directory where the current theme is stored
|
||||||
# the current theme is stored, and copy/sync them to flatpak_themes_dir
|
current_theme_dir=$(xdg_directory_lookup "themes/$current_theme")
|
||||||
while read -r dir; do
|
# Copy/sync current_theme_dir to flatpak_themes_dir
|
||||||
current_theme_dir=${dir%/}/themes/${current_theme}
|
[ -d "$current_theme_dir" ] &&
|
||||||
if [ -d "$current_theme_dir" ]; then
|
|
||||||
rsync -av --delete --progress "$current_theme_dir" "$flatpak_themes_dir"
|
rsync -av --delete --progress "$current_theme_dir" "$flatpak_themes_dir"
|
||||||
break
|
|
||||||
fi
|
|
||||||
done < <(printf '%s:%s\n' "$HOME/.local/share" "$XDG_DATA_DIRS" | tr ':' '\n')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sync_icons() {
|
sync_icons() {
|
||||||
|
@ -44,15 +105,11 @@ sync_icons() {
|
||||||
# Cleanup flatpak_icons_dir
|
# Cleanup flatpak_icons_dir
|
||||||
rm -rf "${flatpak_icons_dir:?}"/*
|
rm -rf "${flatpak_icons_dir:?}"/*
|
||||||
|
|
||||||
# Go through each item in $XDG_DATA_DIRS to find the directory where
|
# Find the directory where the current icon theme is stored
|
||||||
# the current icon theme is stored, and copy/sync them to flatpak_icons_dir
|
current_icon_theme_dir=$(xdg_directory_lookup "icons/$current_icon_theme")
|
||||||
while read -r dir; do
|
# Copy/sync current_icon_theme_dir to flatpak_icons_dir
|
||||||
current_icon_theme_dir=${dir%/}/icons/${current_icon_theme}
|
[ -d "$current_icon_theme_dir" ] &&
|
||||||
if [ -d "$current_icon_theme_dir" ]; then
|
|
||||||
rsync -av --delete --progress "$current_icon_theme_dir" "$flatpak_icons_dir"
|
rsync -av --delete --progress "$current_icon_theme_dir" "$flatpak_icons_dir"
|
||||||
break
|
|
||||||
fi
|
|
||||||
done < <(printf '%s:%s\n' "$HOME/.local/share" "$XDG_DATA_DIRS" | tr ':' '\n')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sync_font() {
|
sync_font() {
|
||||||
|
@ -71,6 +128,7 @@ sync_font
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
case "$line" in
|
case "$line" in
|
||||||
'set: /Net/ThemeName') sync_theme ;;
|
'set: /Net/ThemeName') sync_theme ;;
|
||||||
|
'set: /Gdk/WindowScalingFactor') hdpi_theme_fix ;;
|
||||||
'set: /Net/IconThemeName') sync_icons ;;
|
'set: /Net/IconThemeName') sync_icons ;;
|
||||||
'set: /Gtk/FontName') sync_font ;;
|
'set: /Gtk/FontName') sync_font ;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in New Issue
Block a user