#!/usr/bin/env zsh 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 | 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