mirror of
https://git.adityakumar.xyz/betterlockscreen-openrc.git
synced 2024-11-09 18:49:45 +00:00
`multi-monitor` branch did not check for user set DPI in Xresources. It does now. Also, rather than parsing .Xresources file, we instead query xrdb to get the current value.
This commit is contained in:
parent
c025de7b8f
commit
66d9759159
1 changed files with 17 additions and 11 deletions
|
@ -184,24 +184,30 @@ logical_px() {
|
||||||
# $2: 1 for width. 2 for height
|
# $2: 1 for width. 2 for height
|
||||||
local pixels="$1"
|
local pixels="$1"
|
||||||
local direction="$2"
|
local direction="$2"
|
||||||
|
local dpi
|
||||||
|
|
||||||
# get dpi value from xdpyinfo
|
# use DPI set by user in .Xresources
|
||||||
local DPI
|
dpi=$(xrdb -q | grep -oP '^\s*Xft.dpi:\s*\K\d+' | bc)
|
||||||
DPI=$(xdpyinfo | sed -En "s/\s*resolution:\s*([0-9]*)x([0-9]*)\s.*/\\$direction/p" | head -n1)
|
|
||||||
|
|
||||||
# return the default value if no DPI is set
|
# or get dpi value from xdpyinfo
|
||||||
if [ -z "$DPI" ]; then
|
if [ -z "$dpi" ]; then
|
||||||
echo "$pixels"
|
dpi=$(xdpyinfo | sed -En "s/\s*resolution:\s*([0-9]*)x([0-9]*)\s.*/\\$direction/p" | head -n1)
|
||||||
else
|
fi
|
||||||
local SCALE
|
|
||||||
SCALE=$(echo "scale=2; $DPI / 96.0" | bc)
|
# adjust scaling
|
||||||
|
if [ -n "$dpi" ]; then
|
||||||
|
local scale
|
||||||
|
scale=$(echo "scale=2; $dpi / 96.0" | bc)
|
||||||
|
|
||||||
# check if scaling the value is worthy
|
# check if scaling the value is worthy
|
||||||
if [ "$(echo "$SCALE > 1.25" | bc -l)" -eq 0 ]; then
|
if [ "$(echo "$scale > 1.25" | bc -l)" -eq 0 ]; then
|
||||||
echo "$pixels"
|
echo "$pixels"
|
||||||
else
|
else
|
||||||
echo "$SCALE * $pixels / 1" | bc
|
echo "$scale * $pixels / 1" | bc
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
# return the default value if no DPI is set
|
||||||
|
echo "$pixels"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue