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