#!/bin/sh # Compute DPI. We extract the value from xrandr output. The screen # size is correctly reported (while the X server is lying to respect # the provided DPI). We round to the nearest quarter of 96 DPI (96, # 120, 144, 168, 192...). eval $(xrandr --current | sed -n 's/.* connected primary \([0-9]*\)x.* \([0-9]*\)mm x .*/wd=\1\nwm=\2/p') if [ -n "$wd" -a -n "$wm" ]; then dpi=$(echo "$wd/($wm*0.03937)" | bc) dpi=$(printf "%.0f" $(echo "scale=1;$dpi*4/96" | bc)) dpi=$((dpi*96/4)) else dpi=96 fi # Build xsettingsd.local cp ~/.config/awesome/xsettingsd ~/.config/awesome/xsettingsd.local echo Xft/DPI $(( $dpi * 1024 )) >> ~/.config/awesome/xsettingsd.local # Signal xsettingsd pid=$(xprop -name xsettingsd _NET_WM_PID 2> /dev/null | awk '{print $NF}') if [ x"$pid" = x ]; then xsettingsd -c ~/.config/awesome/xsettingsd.local & else kill -HUP $pid fi # Also use xrdb for very old stuff (you know, LibreOffice) echo Xft.dpi: $dpi | xrdb -merge