mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-07-10 10:14:20 +02:00
xsettingsd: allow 1.25 scale for text
This commit is contained in:
parent
2011bdc9fc
commit
93348863a3
1 changed files with 33 additions and 17 deletions
|
@ -1,26 +1,42 @@
|
|||
#!/bin/sh
|
||||
|
||||
showdpi() {
|
||||
output=$1
|
||||
pixels=$2
|
||||
mm=$3
|
||||
|
||||
# Compute DPI
|
||||
dpi=$((pixels * 254 / 10 / mm))
|
||||
|
||||
# For laptop screens, we need to apply a correction factor as the
|
||||
# screen is nearer
|
||||
case $output in
|
||||
eDP-1|eDP1) corrected=$((dpi * 96/144)) ;;
|
||||
*) corrected=$dpi ;;
|
||||
esac
|
||||
|
||||
# Authorized factors: 1, 1.25, 1.5, 2, 3, 4, ...
|
||||
rounded=$(((corrected + 12) / 24 * 24))
|
||||
[ $rounded -gt 168 ] && rounded=$(((corrected + 48) / 96 * 96))
|
||||
[ $rounded -lt 96 ] && rounded=96
|
||||
|
||||
echo "$output: ${dpi}dpi (corrected to ${corrected}dpi, rounded to ${rounded}dpi)" >&2
|
||||
echo "$rounded"
|
||||
}
|
||||
|
||||
# Examples:
|
||||
# showdpi HDMI-A-0 3840 527
|
||||
# HDMI-A-0: 185dpi (corrected to 185dpi, rounded to 192dpi)
|
||||
# showdpi DisplayPort-3 3840 880
|
||||
# DisplayPort-3: 110dpi (corrected to 110dpi, rounded to 120dpi)
|
||||
# showdpi eDP-1 2560 310
|
||||
# eDP-1: 209dpi (corrected to 139dpi, rounded to 144dpi)
|
||||
|
||||
# Compute DPI of each screens
|
||||
dpis=$(xrandr --current \
|
||||
| sed -En 's/^([^ ]+)* connected.* ([0-9]+)x.* ([0-9]+)mm x .*/\1 \2 \3/p' \
|
||||
| while read output pixels mm; do
|
||||
|
||||
# Compute DPI
|
||||
dpi=$((pixels * 254 / 10 / mm))
|
||||
|
||||
# For laptop screens, we need to apply a correction factor
|
||||
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
|
||||
echo "$rounded"
|
||||
showdpi $output $pixels $mm
|
||||
done \
|
||||
| tr '\n' ' ')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue