diff options
author | Yohann Leon <yohann@leon.re> | 2018-12-10 22:41:59 +0100 |
---|---|---|
committer | Yohann Leon <yohann@leon.re> | 2018-12-10 22:41:59 +0100 |
commit | 9e96fa323f158ed29a72c7fe6f8710cf1cd99e50 (patch) | |
tree | a91367df294bba3093afff7f53336ebfeafa279d | |
parent | 087ebfd1e0e2dbac9e7aeff79a8969325147b3f9 (diff) |
add: support for HiDPI screens
-rwxr-xr-x | betterlockscreen | 18 |
1 files 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 |