mirror of
https://github.com/frebib/dotfiles.git
synced 2024-06-14 12:57:23 +00:00
Joe Groocock
5035afc8b4
Other minor tweaks to the dpi script to ensure everything gets updated correctly. Signed-off-by: Joe Groocock <me@frebib.net>
66 lines
1.6 KiB
Bash
Executable File
66 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
set -eu
|
|
|
|
# Based on https://github.com/vincentbernat/awesome-configuration/blob/master/bin/xsettingsd-setup
|
|
CONF_DIR="${XDG_CONFIG_HOME:-$HOME/.config}"
|
|
|
|
xrdbget() {
|
|
set -o pipefail
|
|
xrdb -query | grep -i -m1 "$1" | sed 's/^.*:\s//g' || echo "$2"
|
|
}
|
|
|
|
xsetting_bool() {
|
|
case "$1" in
|
|
true) echo 1;;
|
|
false) echo 0;;
|
|
default) echo -1;;
|
|
*) echo -1;;
|
|
esac
|
|
}
|
|
|
|
|
|
if [ -z "$1" ] || [ "$1" -gt 200 ] || [ "$1" -lt 96 ]; then
|
|
>&2 printf "Usage\n\t%s: value\n\n value\t Value must be within 96-200 inclusive\n" "$(basename "$0")"
|
|
exit 1
|
|
fi
|
|
|
|
dpi=$1
|
|
scale=$(( dpi/96 ))
|
|
cursor=$(( dpi/6 ))
|
|
|
|
# Update picom scale
|
|
sed -i -e "s/strength =.*$/strength = $(( dpi*8/96 ));/" \
|
|
-e "s/corner-radius =.*$/corner-radius = $(( dpi/13 ));/" \
|
|
"$CONF_DIR/picom/picom.conf" &
|
|
|
|
# Build xsettingsd.conf
|
|
mkdir -p "$CONF_DIR/xsettingsd"
|
|
{
|
|
cat "$CONF_DIR/xsettingsd.local" 2>/dev/null || :
|
|
echo "Xcursor/size $cursor"
|
|
echo "Gtk/CursorThemeSize $cursor"
|
|
echo "Gtk/CursorThemeName \"$(xrdbget Xcursor.theme Adwaita)\""
|
|
echo "Xft/HintStyle \"$(xrdbget Xft.hintstyle hintfull)\""
|
|
echo "Xft/Hinting $(xsetting_bool "$(xrdbget Xft.hinting default)")"
|
|
echo "Xft/RGBA \"$(xrdbget Xft.rgba rgb)\""
|
|
echo "Xft/DPI $(( dpi*1024 ))"
|
|
echo "Gdk/WindowScalingFactor $scale"
|
|
echo "Gdk/UnscaledDPI $(( dpi*1024/scale ))"
|
|
} > "$CONF_DIR/xsettingsd/xsettingsd.conf"
|
|
|
|
xrdb -merge <<EOF &
|
|
Xft.dpi: $dpi
|
|
Xcursor.size: $cursor
|
|
EOF
|
|
xrandr --dpi "$dpi" &
|
|
systemctl --user reload-or-restart xsettingsd &
|
|
wait
|
|
|
|
systemctl --user reload \
|
|
i3 \
|
|
polybar@i3bar &
|
|
systemctl --user restart \
|
|
dunst &
|
|
|
|
wait
|