Skip to content

Commit

Permalink
Remove bashisms from set resolutions
Browse files Browse the repository at this point in the history
  • Loading branch information
nnyyxxxx committed Sep 18, 2024
1 parent 719548f commit 8293794
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tabs/utils/monitor-control/set_resolutions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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"

Expand All @@ -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}"
Expand All @@ -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"
Expand Down

0 comments on commit 8293794

Please sign in to comment.