mirror of
https://git.adityakumar.xyz/betterlockscreen-openrc.git
synced 2024-11-09 10:39:45 +00:00
Automatically deduce DPI (#110)
With this commit the DPI doesn't have to be listed in the ~/.Xresources and will be deduced automatically.
This commit is contained in:
parent
d022301c38
commit
cdb603a3f2
1 changed files with 6 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue