x-dpi-facesizes.sh: support an optional paramter

This commit is contained in:
Lucas 2022-06-22 01:01:59 +00:00
parent 7277f2057e
commit a1a25aa80a
1 changed files with 15 additions and 5 deletions

View File

@ -10,11 +10,22 @@
# Dedication along with this software. If not, see
# <http://creativecommons.org/publicdomain/zero/1.0/>.
usage()
{
printf "Usage: %s [targetdpi]\n" "${0##*/}" >&2
exit 1
}
if [ $# -gt 1 ]; then
usage
fi
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
if [ -n "$1" ]; then
targetdpi=$1
elif command -v xdpyinfo >/dev/null 2>&1; then
targetdpi=$(xdpyinfo | grep '^ resolution:' | {
min=
while read -r line; do
@ -29,13 +40,12 @@ if command -v xdpyinfo >/dev/null 2>&1; then
fi
done
if [ -z "$min" ]; then
echo 96
else
if [ -n "$min" ]; then
echo "$min / 2" | bc -l
fi
})
fi
: ${targetdpi:=96}
for facesize in $FACESIZES; do
echo "$BASEDPI * $facesize / $targetdpi"