1
0
mirror of https://github.com/frebib/dotfiles.git synced 2024-06-14 12:57:23 +00:00
dotfiles/scripts/dpi

43 lines
978 B
Plaintext
Raw Normal View History

#!/bin/sh
set -eu
# Based on https://github.com/vincentbernat/awesome-configuration/blob/master/bin/xsettingsd-setup
CONF_DIR="${XDG_CONFIG_HOME:-$HOME/.config}"
dpi=$1
if [ -z "$1" ]; then
>&2 printf "Usage\n\t%s: <dpi>" "$(basename "$0")"
exit 1
fi
# Update picom and xorg
sed -i "s/strength =.*$/strength = $(( dpi*8/96 ));/" "$CONF_DIR/picom/picom.conf" &
xrandr --dpi "$dpi" &
scale=$(( dpi/96 ))
cursor=$(( dpi/6 ))
# Build xsettingsd.conf
mkdir -p "$CONF_DIR/xsettingsd"
{
cat "$CONF_DIR/xsettingsd.local" 2>/dev/null || true
echo "Xcursor/size $cursor"
echo "Gtk/CursorThemeSize $cursor"
echo "Xft/DPI $(( dpi*1024 ))"
echo "Gdk/WindowScalingFactor $scale"
echo "Gdk/UnscaledDPI $(( dpi*1024/scale ))"
} > "$CONF_DIR/xsettingsd/xsettingsd.conf"
{
echo "Xft.dpi: $dpi"
echo "Xcursor.size: $cursor"
} | xrdb -merge &
systemctl --user reload-or-restart xsettingsd &
wait
systemctl --user reload \
i3 \
polybar@i3bar