Adjust dk border widths based on monitor DPI

This commit is contained in:
natemaia 2022-11-26 11:33:45 -08:00
parent 00ce6f6d6c
commit 0dd6b4aa34

View File

@ -20,19 +20,20 @@ if hash lemonbar bar >/dev/null 2>&1; then
bar 2>/dev/null &
fi
# adjust border widths based on the DPI of the monitor
px=$(xrandr | grep ' connected' | tail -n1 | grep -o '[0-9]\+x[0-9]\+' | cut -d'x' -f2)
mm=$(xrandr | grep ' connected' | tail -n1 | grep -o '[0-9]\+mm' | tail -n1 | sed 's/mm//')
dpi=$(( (px / mm) * 25 ))
if (( dpi >= 140 )); then
:
elif (( dpi >= 120 )); then
:
elif (( dpi >= 100 )); then
:
if [ $dpi -ge 140 ]; then
border_width=5
border_outer_width=3
elif [ $dpi -ge 120 ]; then
border_width=4
border_outer_width=2
else
:
border_width=2
border_outer_width=1
fi
@ -114,7 +115,7 @@ fi
# alternative
# enable split borders and colours, width is overall width, outer width consumes some of width.
# outer width must be less than width, outer width of 0 will be single borders
dkcmd set border width=5 outer_width=3 \
dkcmd set border width=$border_width outer_width=$border_outer_width \
colour \
focus='#6699cc' \
unfocus='#444444' \