From 829379473f57bf7990afe202897f622fe053fb22 Mon Sep 17 00:00:00 2001 From: nnyyxxxx Date: Wed, 18 Sep 2024 15:32:34 -0400 Subject: [PATCH] Remove bashisms from set resolutions --- tabs/utils/monitor-control/set_resolutions.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tabs/utils/monitor-control/set_resolutions.sh b/tabs/utils/monitor-control/set_resolutions.sh index 1a6c6fa71..94eb1b379 100755 --- a/tabs/utils/monitor-control/set_resolutions.sh +++ b/tabs/utils/monitor-control/set_resolutions.sh @@ -22,7 +22,8 @@ set_resolutions() { i=$((i + 1)) done - read -p "Enter the choice (or 'q' to quit): " monitor_choice + printf "%b\n" "Enter the choice (or 'q' to quit): " + read -r monitor_choice if [ "$monitor_choice" = "q" ]; then printf "%b\n" "${RED}Exiting...${RC}" @@ -43,7 +44,7 @@ set_resolutions() { i=1 while read -r resolution; do - resolution_map[$i]="$resolution" + echo "$resolution" >> "$temp_res_file" i=$((i + 1)) done < "$temp_res_file" @@ -54,7 +55,8 @@ set_resolutions() { awk '{print $1 ". " $2}' "$temp_res_file" while true; do - read -p "Enter the choice (or 'q' to quit): " resolution_choice + printf "%b\n" "Enter the choice (or 'q' to quit): " + read -r resolution_choice if [ "$resolution_choice" = "q" ]; then printf "%b\n" "${RED}Exiting...${RC}" @@ -67,10 +69,10 @@ set_resolutions() { continue fi - # Map the index to the actual resolution - selected_resolution=${resolution_map[$resolution_choice]} + selected_resolution=$(awk "NR==$resolution_choice" "$temp_res_file") - read -p "Set resolution for $monitor_name to $selected_resolution? (y/n): " confirm + printf "%b\n" "Set resolution for $monitor_name to $selected_resolution? (y/n): " + read -r confirm if echo "$confirm" | grep -qE '^[Yy]$'; then printf "%b\n" "${GREEN}Setting resolution for $monitor_name to $selected_resolution${RC}" execute_command "xrandr --output $monitor_name --mode $selected_resolution"