mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-07-09 01:34:21 +02:00
xsettingsd: improve automatic DPI detection
For laptops, we don't want the same as for regular screens.
This commit is contained in:
parent
57af83356b
commit
db5f5743b9
1 changed files with 10 additions and 2 deletions
|
@ -7,8 +7,16 @@ xrandr --current \
|
||||||
| sed -n 's/^\([^ ]\{1,\}\)* connected.* \([0-9]\{1,\}\)x.* \([0-9]\{1,\}\)mm x .*/\1 \2 \3/p' \
|
| sed -n 's/^\([^ ]\{1,\}\)* connected.* \([0-9]\{1,\}\)x.* \([0-9]\{1,\}\)mm x .*/\1 \2 \3/p' \
|
||||||
| while read output pixels mm; do
|
| while read output pixels mm; do
|
||||||
dpi=$(($pixels * 254 / 10 / $mm))
|
dpi=$(($pixels * 254 / 10 / $mm))
|
||||||
rounded=$(((dpi + 24) / 48 * 48))
|
# For laptop screens, we need to apply a correction factor
|
||||||
echo "$output: ${dpi}dpi (rounded to ${rounded}dpi)"
|
case $output in
|
||||||
|
eDP-1|eDP1) corrected=$(($dpi * 96/144)) ;;
|
||||||
|
*) corrected=$dpi
|
||||||
|
esac
|
||||||
|
# Authorized factors: 1, 1.5, 2, 3, 4, ...
|
||||||
|
rounded=$(((corrected + 24) / 48 * 48))
|
||||||
|
[ $rounded -gt 192 ] && rounded=$(((corrected + 48) / 96 * 96))
|
||||||
|
[ $rounded -lt 96 ] && rounded=96
|
||||||
|
echo "$output: ${dpi}dpi (corrected to ${corrected}dpi, rounded to ${rounded}dpi)" >&2
|
||||||
done
|
done
|
||||||
|
|
||||||
# Don't try to guess DPI. For a laptop, we don't want the same DPI as
|
# Don't try to guess DPI. For a laptop, we don't want the same DPI as
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue