ordered into /lib

put all subscripts into lib for readability
This commit is contained in:
2026-07-14 16:56:28 +02:00
parent 925c624351
commit 20781c9d90
11 changed files with 6 additions and 20 deletions

38
lib/screen.sh Normal file
View File

@@ -0,0 +1,38 @@
#!/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
}