From e33fc1dacb7b3ed4e84fb007b72ad486f462cc87 Mon Sep 17 00:00:00 2001 From: Yohann Leon Date: Wed, 12 Dec 2018 00:29:17 +0100 Subject: [PATCH] fix: return default dpi pixel coordinates if no dpi is set --- betterlockscreen | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/betterlockscreen b/betterlockscreen index 0cef78d..2ef6208 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -123,13 +123,19 @@ lockselect() { logical_px() { # get dpi value from xrdb local DPI=$(xrdb -query | awk '/Xft.dpi/ {print $2}') - local SCALE=$(echo "scale=2; $DPI / 96.0" | bc) - - # check if scaling the value is worthy - if [ $(echo "$SCALE > 1.25" | bc -l) -eq 0 ]; then + + # return the default value if no DPI is set + if [ -z "$DPI"]; then echo $1 else - echo "$SCALE * $1 / 1" | bc + local SCALE=$(echo "scale=2; $DPI / 96.0" | bc) + + # check if scaling the value is worthy + if [ $(echo "$SCALE > 1.25" | bc -l) -eq 0 ]; then + echo $1 + else + echo "$SCALE * $1 / 1" | bc + fi fi }