diff options
author | pks <pks@pks.rocks> | 2022-06-11 15:35:29 +0200 |
---|---|---|
committer | pks <pks@pks.rocks> | 2022-06-11 15:35:29 +0200 |
commit | 2883a731e8e700336fb8d6c8590ec450e8ee07bc (patch) | |
tree | 1d608d7af66b2c65096228cb6494b55b14994e75 | |
parent | dfe9b68f37bc0db9524ae45eb7b1f8066f2bd5cd (diff) |
dpi: fix
-rwxr-xr-x | dpi | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -1,11 +1,15 @@ #!/usr/bin/env zsh -res=$(xdpyinfo | grep 'dimensions:' | strips | cut -d" " -f 5) +res=$(xrandr 2>/dev/null | grep "primary" | cut -d" " -f 4) res_x=$(echo $res | cut -d"x" -f 1) -res_y=$(echo $res | cut -d"x" -f 2) -size_x=$(xrandr | grep " connected" | cut -d" " -f 13 | sed "s|mm||") -size_y=$(xrandr | grep " connected" | cut -d" " -f 15 | sed "s|mm||") -dpi=$(python -c "import math; print(round(math.sqrt($res_x**2 + $res_y**2) / math.sqrt(($size_x*0.0393701)**2 + ($size_y*0.0393701)**2)))") - +res_y=$(echo $res | cut -d"x" -f 2 | cut -d+ -f 1) +size_x=$(xrandr 2>/dev/null | grep " primary" | cut -d" " -f 14 | sed "s|mm||") +if [[ $size_x == "x" ]]; then + size_x=$(xrandr 2>/dev/null | grep " primary" | cut -d" " -f 13 | sed "s|mm||") +fi +size_y=$(xrandr 2>/dev/null | grep " primary" | cut -d" " -f 16 | sed "s|mm||") +if [[ $size_y == "" ]]; then + size_y=$(xrandr 2>/dev/null | grep " primary" | cut -d" " -f 15 | sed "s|mm||") +fi +dpi=$(python3 -c "import math; print(round(math.sqrt($res_x**2 + $res_y**2) / math.sqrt(($size_x*0.0393701)**2 + ($size_y*0.0393701)**2)))") echo $dpi - |