From eb5028e0851ba6de4c97b4e0b20938c6f4ff3c65 Mon Sep 17 00:00:00 2001 From: JEEVITHA KANNAN K S Date: Fri, 16 Aug 2024 12:16:31 +0530 Subject: [PATCH] Fix monitor utility not working in debian --- .../monitor-control/change_orientation.sh | 2 +- .../utils/monitor-control/disable_monitor.sh | 2 +- .../utils/monitor-control/enable_monitor.sh | 2 +- .../monitor-control/manage_arrangement.sh | 2 +- .../utils/monitor-control/reset_scaling.sh | 2 +- .../utils/monitor-control/scale_monitor.sh | 2 +- .../monitor-control/set_primary_monitor.sh | 2 +- .../utils/monitor-control/set_resolutions.sh | 2 +- .../monitor-control/utility_functions.sh | 31 +++++++++---------- 9 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/commands/utils/monitor-control/change_orientation.sh b/src/commands/utils/monitor-control/change_orientation.sh index e1083f59..c3290181 100644 --- a/src/commands/utils/monitor-control/change_orientation.sh +++ b/src/commands/utils/monitor-control/change_orientation.sh @@ -5,7 +5,7 @@ # Function to change monitor orientation change_orientation() { monitor_list=$(detect_connected_monitors) - IFS=$'\n' read -r -d '' -a monitor_array <<<"$monitor_list" + IFS=$'\n' read -r -a monitor_array <<<"$monitor_list" clear echo -e "${BLUE}=========================================${RESET}" diff --git a/src/commands/utils/monitor-control/disable_monitor.sh b/src/commands/utils/monitor-control/disable_monitor.sh index 555e77ab..1e270c02 100644 --- a/src/commands/utils/monitor-control/disable_monitor.sh +++ b/src/commands/utils/monitor-control/disable_monitor.sh @@ -13,7 +13,7 @@ CYAN='\033[36m' # Function to disable a monitor disable_monitor() { monitor_list=$(detect_connected_monitors) - IFS=$'\n' read -r -d '' -a monitor_array <<<"$monitor_list" + IFS=$'\n' read -r -a monitor_array <<<"$monitor_list" clear echo -e "${BLUE}=========================================${RESET}" diff --git a/src/commands/utils/monitor-control/enable_monitor.sh b/src/commands/utils/monitor-control/enable_monitor.sh index bc4af215..bd88cb84 100644 --- a/src/commands/utils/monitor-control/enable_monitor.sh +++ b/src/commands/utils/monitor-control/enable_monitor.sh @@ -13,7 +13,7 @@ CYAN='\033[36m' # Function to enable a monitor enable_monitor() { monitor_list=$(detect_connected_monitors) - IFS=$'\n' read -r -d '' -a monitor_array <<<"$monitor_list" + IFS=$'\n' read -r -a monitor_array <<<"$monitor_list" clear echo -e "${BLUE}=========================================${RESET}" diff --git a/src/commands/utils/monitor-control/manage_arrangement.sh b/src/commands/utils/monitor-control/manage_arrangement.sh index ea03f4ee..5df5f1e3 100644 --- a/src/commands/utils/monitor-control/manage_arrangement.sh +++ b/src/commands/utils/monitor-control/manage_arrangement.sh @@ -5,7 +5,7 @@ # Function to manage monitor arrangement manage_arrangement() { monitor_list=$(detect_connected_monitors) - IFS=$'\n' read -r -d '' -a monitor_array <<<"$monitor_list" + IFS=$'\n' read -r -a monitor_array <<<"$monitor_list" clear echo -e "${BLUE}=========================================${RESET}" diff --git a/src/commands/utils/monitor-control/reset_scaling.sh b/src/commands/utils/monitor-control/reset_scaling.sh index 5b6caaca..bd70d17b 100644 --- a/src/commands/utils/monitor-control/reset_scaling.sh +++ b/src/commands/utils/monitor-control/reset_scaling.sh @@ -9,7 +9,7 @@ reset_scaling() { echo -e "${BLUE}=========================================${RESET}" monitor_list=$(detect_connected_monitors) - IFS=$'\n' read -r -d '' -a monitor_array <<<"$monitor_list" + IFS=$'\n' read -r -a monitor_array <<<"$monitor_list" for monitor in "${monitor_array[@]}"; do echo -e "${CYAN}Resetting scaling for $monitor to 1x1 (native resolution)${RESET}" diff --git a/src/commands/utils/monitor-control/scale_monitor.sh b/src/commands/utils/monitor-control/scale_monitor.sh index 624c850f..062ec454 100644 --- a/src/commands/utils/monitor-control/scale_monitor.sh +++ b/src/commands/utils/monitor-control/scale_monitor.sh @@ -9,7 +9,7 @@ scale_monitors() { echo -e "${BLUE}=========================================${RESET}" monitor_list=$(detect_connected_monitors) - IFS=$'\n' read -r -d '' -a monitor_array <<<"$monitor_list" + IFS=$'\n' read -r -a monitor_array <<<"$monitor_list" # Get the highest resolution among all monitors max_width=0 diff --git a/src/commands/utils/monitor-control/set_primary_monitor.sh b/src/commands/utils/monitor-control/set_primary_monitor.sh index c9e46dcd..dd39fc89 100644 --- a/src/commands/utils/monitor-control/set_primary_monitor.sh +++ b/src/commands/utils/monitor-control/set_primary_monitor.sh @@ -5,7 +5,7 @@ # Function to set a monitor as primary set_primary_monitor() { monitor_list=$(detect_connected_monitors) - IFS=$'\n' read -r -d '' -a monitor_array <<<"$monitor_list" + IFS=$'\n' read -r -a monitor_array <<<"$monitor_list" clear echo -e "${BLUE}=========================================${RESET}" diff --git a/src/commands/utils/monitor-control/set_resolutions.sh b/src/commands/utils/monitor-control/set_resolutions.sh index c0641a28..37a90095 100644 --- a/src/commands/utils/monitor-control/set_resolutions.sh +++ b/src/commands/utils/monitor-control/set_resolutions.sh @@ -13,7 +13,7 @@ CYAN='\033[36m' # Function to set resolutions set_resolutions() { monitor_list=$(detect_connected_monitors) - IFS=$'\n' read -r -d '' -a monitor_array <<<"$monitor_list" + IFS=$'\n' read -r -a monitor_array <<<"$monitor_list" while true; do clear diff --git a/src/commands/utils/monitor-control/utility_functions.sh b/src/commands/utils/monitor-control/utility_functions.sh index b9c7a9b8..5bec47a1 100644 --- a/src/commands/utils/monitor-control/utility_functions.sh +++ b/src/commands/utils/monitor-control/utility_functions.sh @@ -7,15 +7,15 @@ setup_xrandr() { echo "Install xrandr if not already installed..." if ! command_exists xrandr; then case ${PACKAGER} in - pacman) - sudo "${PACKAGER}" -S --noconfirm xorg-xrandr - ;; - apt-get) - sudo "${PACKAGER}" install -y x11-xserver-utils - ;; - *) - sudo "${PACKAGER}" install -y xorg-x11-server-utils - ;; + pacman) + sudo "${PACKAGER}" -S --noconfirm xorg-xrandr + ;; + apt-get) + sudo "${PACKAGER}" install -y x11-xserver-utils + ;; + *) + sudo "${PACKAGER}" install -y xorg-x11-server-utils + ;; esac else echo "xrandr is already installed." @@ -27,11 +27,11 @@ colored_echo() { local color=$1 local text=$2 case $color in - red) echo -e "\033[31m$text\033[0m" ;; - green) echo -e "\033[32m$text\033[0m" ;; - yellow) echo -e "\033[33m$text\033[0m" ;; - blue) echo -e "\033[34m$text\033[0m" ;; - *) echo "$text" ;; + red) echo -e "\033[31m$text\033[0m" ;; + green) echo -e "\033[32m$text\033[0m" ;; + yellow) echo -e "\033[33m$text\033[0m" ;; + blue) echo -e "\033[34m$text\033[0m" ;; + *) echo "$text" ;; esac } @@ -40,9 +40,8 @@ check_display_server() { if [ "$XDG_SESSION_TYPE" = "wayland" ]; then colored_echo "red" "You are using Wayland." colored_echo "red" "This script is designed for X11. It may not work correctly on Wayland." - read -p "Do you want to continue anyway? (y/n): " response - if [[ ! "$response" =~ ^[Yy]$ ]]; then + if ! confirm_action "Do you want to continue anyway?"; then echo "Exiting script." exit 1 fi