From f21ba590e7b09b77954edb4e1767a9f5a175713b Mon Sep 17 00:00:00 2001 From: Chris Titus Date: Thu, 29 Aug 2024 16:27:36 -0500 Subject: [PATCH] fix resolutions --- .../utils/monitor-control/utility_functions.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/commands/utils/monitor-control/utility_functions.sh b/src/commands/utils/monitor-control/utility_functions.sh index 9a467bfd..e9bfee1b 100755 --- a/src/commands/utils/monitor-control/utility_functions.sh +++ b/src/commands/utils/monitor-control/utility_functions.sh @@ -20,7 +20,20 @@ detect_connected_monitors() { get_unique_resolutions() { local monitor="$1" xrandr_output=$(xrandr) - echo "$xrandr_output" | grep -A 10 "$monitor connected" | grep -oP '\d+x\d+' | sort -u + # Get available resolutions from xrandr + available_resolutions=$(echo "$xrandr_output" | grep -A 10 "$monitor connected" | grep -oP '\d+x\d+' | sort -u) + + # Define standard resolutions + standard_resolutions="1920x1080 1280x720 1600x900 2560x1440 3840x2160" + + # Filter standard resolutions to include only those available for the monitor + filtered_standard_resolutions=$(echo "$standard_resolutions" | tr ' ' '\n' | grep -xF -f <(echo "$available_resolutions")) + + # Get remaining available resolutions (excluding standard ones) + remaining_resolutions=$(comm -23 <(echo "$available_resolutions" | sort) <(echo "$filtered_standard_resolutions" | sort)) + + # Combine filtered standard resolutions and remaining resolutions, and limit to 10 results + echo -e "$filtered_standard_resolutions\n$remaining_resolutions" | head -n 10 } # Function to prompt for confirmation