2018-11-20 15:06:09 +00:00
|
|
|
#!/bin/sh
|
2021-08-01 19:05:07 +00:00
|
|
|
set -eu
|
2018-11-20 15:06:09 +00:00
|
|
|
|
|
|
|
# Based on https://github.com/vincentbernat/awesome-configuration/blob/master/bin/xsettingsd-setup
|
2021-08-01 19:05:07 +00:00
|
|
|
CONF_DIR="${XDG_CONFIG_HOME:-$HOME/.config}"
|
2018-11-20 15:06:09 +00:00
|
|
|
|
|
|
|
dpi=$1
|
|
|
|
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
>&2 printf "Usage\n\t%s: <dpi>" "$(basename "$0")"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-08-01 19:05:07 +00:00
|
|
|
# Update picom and xorg
|
|
|
|
sed -i "s/strength =.*$/strength = $(( dpi*8/96 ));/" "$CONF_DIR/picom/picom.conf" &
|
|
|
|
xrandr --dpi "$dpi" &
|
2018-11-20 15:06:09 +00:00
|
|
|
|
2021-08-01 19:05:07 +00:00
|
|
|
scale=$(( dpi/96 ))
|
|
|
|
cursor=$(( dpi/6 ))
|
2021-01-30 11:47:07 +00:00
|
|
|
|
2021-08-01 19:05:07 +00:00
|
|
|
# Build xsettingsd.conf
|
|
|
|
mkdir -p "$CONF_DIR/xsettingsd"
|
2018-11-20 15:06:09 +00:00
|
|
|
{
|
2021-08-01 19:05:07 +00:00
|
|
|
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"
|
2018-11-20 15:06:09 +00:00
|
|
|
|
2021-01-30 11:47:07 +00:00
|
|
|
{
|
2021-08-01 19:05:07 +00:00
|
|
|
echo "Xft.dpi: $dpi"
|
|
|
|
echo "Xcursor.size: $cursor"
|
|
|
|
} | xrdb -merge &
|
2021-01-30 11:47:07 +00:00
|
|
|
|
2021-08-01 19:05:07 +00:00
|
|
|
systemctl --user reload-or-restart xsettingsd &
|
|
|
|
wait
|
2020-03-21 23:20:05 +00:00
|
|
|
|
2021-08-01 19:05:07 +00:00
|
|
|
systemctl --user reload \
|
|
|
|
i3 \
|
|
|
|
polybar@i3bar
|