From 9e96fa323f158ed29a72c7fe6f8710cf1cd99e50 Mon Sep 17 00:00:00 2001 From: Yohann Leon Date: Mon, 10 Dec 2018 22:41:59 +0100 Subject: [PATCH 1/4] add: support for HiDPI screens --- betterlockscreen | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/betterlockscreen b/betterlockscreen index d9f90af..4f286be 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -120,6 +120,18 @@ lockselect() { postlock } +logical_px() { + # get dpi value from xrdb + local DPI=$(xrdb -query | awk '/Xft.dpi/ {print $2}') + local SCALE=$(echo "scale=2; 150 / 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 +} update() { # use @@ -132,9 +144,9 @@ update() { SR=$(xrandr --query | grep ' connected' | grep -o '[0-9][0-9]*x[0-9][0-9]*[^ ]*') for RES in $SR; do SRA=(${RES//[x+]/ }) - CX=$((${SRA[2]} + 25)) - CY=$((${SRA[1]} - 30)) - rectangles+="rectangle $CX,$CY $((CX+300)),$((CY-80)) " + CX=$((${SRA[2]} + $(logical_px 25))) + CY=$((${SRA[1]} - $(logical_px 30))) + rectangles+="rectangle $CX,$CY $((CX+$(logical_px 300))),$((CY-$(logical_px 80))) " done # User supplied Image From 271bb033685aeb7cfc5e1e0e4cb850ae5fcba3f7 Mon Sep 17 00:00:00 2001 From: Yohann Leon Date: Tue, 11 Dec 2018 17:41:00 +0100 Subject: [PATCH 2/4] fix: hardcoded DPI value in logical_px() --- betterlockscreen | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/betterlockscreen b/betterlockscreen index 4f286be..0cef78d 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -123,7 +123,7 @@ lockselect() { logical_px() { # get dpi value from xrdb local DPI=$(xrdb -query | awk '/Xft.dpi/ {print $2}') - local SCALE=$(echo "scale=2; 150 / 96.0" | 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 From e33fc1dacb7b3ed4e84fb007b72ad486f462cc87 Mon Sep 17 00:00:00 2001 From: Yohann Leon Date: Wed, 12 Dec 2018 00:29:17 +0100 Subject: [PATCH 3/4] 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 } From 5a2fbbadddfa5cfe557901efb62385f6c85e270f Mon Sep 17 00:00:00 2001 From: Philipp Hemmelmayr Date: Sat, 5 Jan 2019 18:44:47 +0100 Subject: [PATCH 4/4] removed warnings --- betterlockscreen | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/betterlockscreen b/betterlockscreen index 2ef6208..be67bd0 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -125,7 +125,7 @@ logical_px() { local DPI=$(xrdb -query | awk '/Xft.dpi/ {print $2}') # return the default value if no DPI is set - if [ -z "$DPI"]; then + if [ -z "$DPI" ]; then echo $1 else local SCALE=$(echo "scale=2; $DPI / 96.0" | bc)