This commit is contained in:
2026-03-02 08:51:35 +00:00
parent 21a4b1ced6
commit 3a8b3ac9d1
3 changed files with 181 additions and 0 deletions

33
screen.sh Normal file
View File

@@ -0,0 +1,33 @@
#!/bin/bash
# Get primary display name
display=$(xrandr --query | awk '/ connected primary/{print $1}')
# If no primary, use first connected
if [ -z "$display" ]; then
display=$(xrandr --query | awk '/ connected/{print $1; exit}')
fi
if [ -z "$display" ]; then
echo "No connected display found."
exit 1
fi
# Get physical dimensions line for that display
dim_line=$(xrandr --query | grep "^$display connected")
# Extract width and height in mm
width_mm=$(echo "$dim_line" | sed -n 's/.* \([0-9]\+\)mm x \([0-9]\+\)mm.*/\1/p')
height_mm=$(echo "$dim_line" | sed -n 's/.* \([0-9]\+\)mm x \([0-9]\+\)mm.*/\2/p')
if [ -z "$width_mm" ] || [ -z "$height_mm" ]; then
echo "Could not determine physical screen size."
exit 1
fi
# Calculate diagonal in mm
diagonal_mm=$(echo "scale=4; sqrt($width_mm^2 + $height_mm^2)" | bc -l)
# Convert to inches
diagonal_in=$(echo "scale=2; $diagonal_mm / 25.4" | bc -l)
return ${diagonal_in%.*}