2024-08-15 03:41:41 +01:00
|
|
|
#!/bin/sh -e
|
|
|
|
|
2024-08-21 08:18:34 +01:00
|
|
|
. ./utility_functions.sh
|
2024-08-05 20:24:05 +01:00
|
|
|
|
2024-09-12 21:14:50 +01:00
|
|
|
. ../../common-script.sh
|
|
|
|
|
2024-08-05 20:24:05 +01:00
|
|
|
# Function to scale smaller monitors to the highest resolution of a bigger monitor
|
|
|
|
scale_monitors() {
|
2024-09-12 21:14:50 +01:00
|
|
|
printf "%b\n" "${YELLOW}=========================================${RC}"
|
|
|
|
printf "%b\n" "${YELLOW} Scale Monitors to Highest Resolution${RC}"
|
|
|
|
printf "%b\n" "${YELLOW}=========================================${RC}"
|
2024-08-05 20:24:05 +01:00
|
|
|
|
|
|
|
monitor_list=$(detect_connected_monitors)
|
2024-09-12 21:14:50 +01:00
|
|
|
monitor_array=$(echo "$monitor_list" | tr '\n' ' ')
|
2024-08-05 20:24:05 +01:00
|
|
|
|
|
|
|
max_width=0
|
|
|
|
max_height=0
|
|
|
|
|
2024-09-12 21:14:50 +01:00
|
|
|
for monitor in $monitor_array; do
|
2024-08-05 20:24:05 +01:00
|
|
|
res=$(xrandr | grep -A1 "^$monitor connected" | tail -1 | awk '{print $1}')
|
2024-09-12 21:14:50 +01:00
|
|
|
width=$(echo "$res" | awk -Fx '{print $1}')
|
|
|
|
height=$(echo "$res" | awk -Fx '{print $2}')
|
2024-08-05 20:24:05 +01:00
|
|
|
|
2024-09-12 21:14:50 +01:00
|
|
|
if [ "$width" -gt "$max_width" ]; then
|
2024-08-05 20:24:05 +01:00
|
|
|
max_width=$width
|
|
|
|
fi
|
|
|
|
|
2024-09-12 21:14:50 +01:00
|
|
|
if [ "$height" -gt "$max_height" ]; then
|
2024-08-05 20:24:05 +01:00
|
|
|
max_height=$height
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2024-09-12 21:14:50 +01:00
|
|
|
printf "%b\n" "${YELLOW}Highest resolution found: ${max_width}x${max_height}${RC}"
|
2024-08-05 20:24:05 +01:00
|
|
|
|
2024-09-12 21:14:50 +01:00
|
|
|
for monitor in $monitor_array; do
|
|
|
|
printf "%b\n" "${YELLOW}Scaling $monitor to ${max_width}x${max_height}${RC}"
|
2024-08-05 20:24:05 +01:00
|
|
|
execute_command "xrandr --output $monitor --scale-from ${max_width}x${max_height}"
|
|
|
|
done
|
|
|
|
|
2024-09-12 21:14:50 +01:00
|
|
|
printf "%b\n" "${GREEN}Scaling complete. All monitors are now scaled to ${max_width}x${max_height}.${RC}"
|
2024-08-05 20:24:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Call the scale_monitors function
|
|
|
|
scale_monitors
|