xsettingsd: use first screen DPI as DPI for the session

This commit is contained in:
Vincent Bernat 2020-01-31 07:24:52 +01:00
parent 498606b38e
commit 9eab93570d

View file

@ -2,7 +2,8 @@
DISPLAY=${DISPLAY%.0}
# For information
# Compute DPI of each screens
dpis=""
for info in $(xrandr --current \
| sed -n 's/^\([^ ]\{1,\}\)* connected.* \([0-9]\{1,\}\)x.* \([0-9]\{1,\}\)mm x .*/\1,\2,\3/p'); do
output=${info%%,*}
@ -19,17 +20,13 @@ for info in $(xrandr --current \
rounded=$(((corrected + 24) / 48 * 48))
[ $rounded -gt 192 ] && rounded=$(((corrected + 48) / 96 * 96))
[ $rounded -lt 96 ] && rounded=96
dpis="$dpis$rounded "
echo "$output: ${dpi}dpi (corrected to ${corrected}dpi, rounded to ${rounded}dpi)" >&2
done
# Don't try to guess DPI. For a laptop, we don't want the same DPI as
# for an external screen or for a TV. Just hardcode stuff...
case $(hostname),$(autorandr --current) in
zoro,default) dpi=144 ;;
guybrush,default) dpi=144 ;;
neo,*) dpi=192 ;;
*,*) dpi=96 ;;
esac
# Use first screen DPI
dpi=${dpis## *}
dpi=${dpi:-96}
echo "using ${dpi}dpi" >&2
xrandr --dpi $dpi