diff --git a/scripts/dpi b/scripts/dpi index 361e1de..c61ecd2 100755 --- a/scripts/dpi +++ b/scripts/dpi @@ -1,7 +1,8 @@ #!/bin/sh -set -e +set -eu # Based on https://github.com/vincentbernat/awesome-configuration/blob/master/bin/xsettingsd-setup +CONF_DIR="${XDG_CONFIG_HOME:-$HOME/.config}" dpi=$1 @@ -10,27 +11,32 @@ if [ -z "$1" ]; then exit 1 fi -CONF_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/xsettingsd" -mkdir -p "$CONF_DIR" +# Update picom and xorg +sed -i "s/strength =.*$/strength = $(( dpi*8/96 ));/" "$CONF_DIR/picom/picom.conf" & +xrandr --dpi "$dpi" & -cursor=$(echo $dpi/6 | bc | cut -d. -f1) +scale=$(( dpi/96 )) +cursor=$(( dpi/6 )) -# Build xsettingsd.local +# Build xsettingsd.conf +mkdir -p "$CONF_DIR/xsettingsd" { - cat $CONF_DIR/xsettingsd.conf 2>/dev/null || true - echo Xcursor/size $cursor - echo Gtk/CursorThemeSize $cursor - echo Xft/DPI $(( dpi*1024 )) - echo Gdk/WindowScalingFactor $(( dpi/96 )) - echo Gdk/UnscaledDPI $(( dpi*1024/(dpi/96) )) -} > $CONF_DIR/xsettingsd.local + 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 + echo "Xft.dpi: $dpi" + echo "Xcursor.size: $cursor" +} | xrdb -merge & -xrandr --dpi $dpi +systemctl --user reload-or-restart xsettingsd & +wait -systemctl --user reload-or-restart xsettingsd -systemctl --user --no-block reload i3 polybar@i3bar +systemctl --user reload \ + i3 \ + polybar@i3bar