@@ -22,7 +22,8 @@ set_resolutions() {
22
22
i=$(( i + 1 ))
23
23
done
24
24
25
- read -p " Enter the choice (or 'q' to quit): " monitor_choice
25
+ printf " %b\n" " Enter the choice (or 'q' to quit): "
26
+ read -r monitor_choice
26
27
27
28
if [ " $monitor_choice " = " q" ]; then
28
29
printf " %b\n" " ${RED} Exiting...${RC} "
@@ -31,7 +32,8 @@ set_resolutions() {
31
32
32
33
if ! echo " $monitor_choice " | grep -qE ' ^[0-9]+$' || [ " $monitor_choice " -lt 1 ] || [ " $monitor_choice " -gt " $(( i - 1 )) " ]; then
33
34
printf " %b\n" " ${RED} Invalid selection. Please try again.${RC} "
34
- read -p " Press [Enter] to continue..."
35
+ printf " %b\n" " Press [Enter] to continue..."
36
+ read -r dummy
35
37
continue
36
38
fi
37
39
@@ -43,7 +45,7 @@ set_resolutions() {
43
45
44
46
i=1
45
47
while read -r resolution; do
46
- resolution_map[ $i ]= " $resolution "
48
+ echo " $resolution " >> " $temp_res_file "
47
49
i=$(( i + 1 ))
48
50
done < " $temp_res_file "
49
51
@@ -54,7 +56,8 @@ set_resolutions() {
54
56
awk ' {print $1 ". " $2}' " $temp_res_file "
55
57
56
58
while true ; do
57
- read -p " Enter the choice (or 'q' to quit): " resolution_choice
59
+ printf " %b\n" " Enter the choice (or 'q' to quit): "
60
+ read -r resolution_choice
58
61
59
62
if [ " $resolution_choice " = " q" ]; then
60
63
printf " %b\n" " ${RED} Exiting...${RC} "
@@ -67,10 +70,10 @@ set_resolutions() {
67
70
continue
68
71
fi
69
72
70
- # Map the index to the actual resolution
71
- selected_resolution=${resolution_map[$resolution_choice]}
73
+ selected_resolution=$( awk " NR==$resolution_choice " " $temp_res_file " )
72
74
73
- read -p " Set resolution for $monitor_name to $selected_resolution ? (y/n): " confirm
75
+ printf " %b\n" " Set resolution for $monitor_name to $selected_resolution ? (y/n): "
76
+ read -r confirm
74
77
if echo " $confirm " | grep -qE ' ^[Yy]$' ; then
75
78
printf " %b\n" " ${GREEN} Setting resolution for $monitor_name to $selected_resolution ${RC} "
76
79
execute_command " xrandr --output $monitor_name --mode $selected_resolution "
0 commit comments