54 lines
1.3 KiB
Bash
54 lines
1.3 KiB
Bash
|
#!/bin/sh
|
||
|
# env
|
||
|
# Written in 2022 by Lucas
|
||
|
# CC0 1.0 Universal/Public domain - No rights reserved
|
||
|
#
|
||
|
# To the extent possible under law, the author(s) have dedicated all
|
||
|
# copyright and related and neighboring rights to this software to the
|
||
|
# public domain worldwide. This software is distributed without any
|
||
|
# warranty. You should have received a copy of the CC0 Public Domain
|
||
|
# Dedication along with this software. If not, see
|
||
|
# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||
|
|
||
|
FACESIZES="10.5 6.0 8.0 9.0 10.5 12.0 18.0"
|
||
|
BASEDPI=96
|
||
|
|
||
|
targetdpi=96
|
||
|
if command -v xdpyinfo >/dev/null 2>&1; then
|
||
|
targetdpi=$(xdpyinfo | grep '^ resolution:' | {
|
||
|
min=
|
||
|
while read -r line; do
|
||
|
set -- $line
|
||
|
dpi_x=${2%%x*}
|
||
|
dpi_y=${2##*x}
|
||
|
dpi_sum=$(( $dpi_x + $dpi_y ))
|
||
|
if [ -z "$min" ]; then
|
||
|
min=$dpi_sum
|
||
|
else
|
||
|
min=$(( $dpi_sum < $min ? $dpi_sum : $dpi ))
|
||
|
fi
|
||
|
done
|
||
|
|
||
|
if [ -z "$min" ]; then
|
||
|
echo 96
|
||
|
else
|
||
|
echo "$min / 2" | bc -l
|
||
|
fi
|
||
|
})
|
||
|
fi
|
||
|
|
||
|
for facesize in $FACESIZES; do
|
||
|
echo "$BASEDPI * $facesize / $targetdpi"
|
||
|
done | bc -l | {
|
||
|
i=0
|
||
|
printf "Xft.dpi:\t%.1f\n" "$targetdpi"
|
||
|
while read -r v; do
|
||
|
if [ $i -eq 0 ]; then
|
||
|
printf "XTerm.VT100.faceSize:\t%.1f\n" "$v"
|
||
|
else
|
||
|
printf "XTerm.VT100.faceSize%d:\t%.1f\n" $i "$v"
|
||
|
fi
|
||
|
i=$(($i + 1))
|
||
|
done
|
||
|
} | xrdb -merge
|