Files
csr_setup/screen.sh
lucas_csr 925c624351 Reorga of functions
moved all functions into files
Redid RAM to be more useable
2026-07-14 16:45:44 +02:00

38 lines
1.1 KiB
Bash

#!/bin/bash
function SCREEN(){
local OUT_FILE=$1
# 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 -e "No connected display found." >>"$OUT_FILE"
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 -e "Could not determine physical screen size." >>"$OUT_FILE"
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)
echo -e "Screen:\t ${diagonal_in%.*}" >>"$OUT_FILE"
return 0
}