diff --git a/betterlockscreen b/betterlockscreen index d58d8aa..8f98f7f 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -145,9 +145,11 @@ lockselect() { postlock } +# $1: number of pixels to convert +# $2: 1 for width. 2 for height logical_px() { # get dpi value from xrdb - local DPI=$(xrdb -query | awk '/Xft.dpi/ {print $2}') + local DPI=$(xdpyinfo | sed -En "s/\s*resolution:\s*([0-9]*)x([0-9]*)\s.*/\\$2/p" | head -n1) # return the default value if no DPI is set if [ -z "$DPI" ]; then @@ -175,9 +177,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]} + $(logical_px 25))) - CY=$((${SRA[1]} - $(logical_px 30))) - rectangles+="rectangle $CX,$CY $((CX+$(logical_px 300))),$((CY-$(logical_px 80))) " + CX=$((${SRA[2]} + $(logical_px 25 1))) + CY=$((${SRA[1]} - $(logical_px 30 2))) + rectangles+="rectangle $CX,$CY $((CX+$(logical_px 300 1))),$((CY-$(logical_px 80 2))) " done # User supplied Image