fix: return default dpi pixel coordinates if no dpi is set

This commit is contained in:
Yohann Leon 2018-12-12 00:29:17 +01:00
parent 271bb03368
commit e33fc1dacb

View file

@ -123,6 +123,11 @@ lockselect() {
logical_px() { logical_px() {
# get dpi value from xrdb # get dpi value from xrdb
local DPI=$(xrdb -query | awk '/Xft.dpi/ {print $2}') local DPI=$(xrdb -query | awk '/Xft.dpi/ {print $2}')
# return the default value if no DPI is set
if [ -z "$DPI"]; then
echo $1
else
local SCALE=$(echo "scale=2; $DPI / 96.0" | bc) local SCALE=$(echo "scale=2; $DPI / 96.0" | bc)
# check if scaling the value is worthy # check if scaling the value is worthy
@ -131,6 +136,7 @@ logical_px() {
else else
echo "$SCALE * $1 / 1" | bc echo "$SCALE * $1 / 1" | bc
fi fi
fi
} }
update() { update() {