Fix monitor utility not working in debian

This commit is contained in:
JEEVITHA KANNAN K S 2024-08-16 12:16:31 +05:30
parent 4119804683
commit eb5028e085
No known key found for this signature in database
GPG Key ID: 5904C34A2F7CE333
9 changed files with 23 additions and 24 deletions

View File

@ -5,7 +5,7 @@
# Function to change monitor orientation # Function to change monitor orientation
change_orientation() { change_orientation() {
monitor_list=$(detect_connected_monitors) 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 clear
echo -e "${BLUE}=========================================${RESET}" echo -e "${BLUE}=========================================${RESET}"

View File

@ -13,7 +13,7 @@ CYAN='\033[36m'
# Function to disable a monitor # Function to disable a monitor
disable_monitor() { disable_monitor() {
monitor_list=$(detect_connected_monitors) 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 clear
echo -e "${BLUE}=========================================${RESET}" echo -e "${BLUE}=========================================${RESET}"

View File

@ -13,7 +13,7 @@ CYAN='\033[36m'
# Function to enable a monitor # Function to enable a monitor
enable_monitor() { enable_monitor() {
monitor_list=$(detect_connected_monitors) 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 clear
echo -e "${BLUE}=========================================${RESET}" echo -e "${BLUE}=========================================${RESET}"

View File

@ -5,7 +5,7 @@
# Function to manage monitor arrangement # Function to manage monitor arrangement
manage_arrangement() { manage_arrangement() {
monitor_list=$(detect_connected_monitors) 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 clear
echo -e "${BLUE}=========================================${RESET}" echo -e "${BLUE}=========================================${RESET}"

View File

@ -9,7 +9,7 @@ reset_scaling() {
echo -e "${BLUE}=========================================${RESET}" echo -e "${BLUE}=========================================${RESET}"
monitor_list=$(detect_connected_monitors) 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 for monitor in "${monitor_array[@]}"; do
echo -e "${CYAN}Resetting scaling for $monitor to 1x1 (native resolution)${RESET}" echo -e "${CYAN}Resetting scaling for $monitor to 1x1 (native resolution)${RESET}"

View File

@ -9,7 +9,7 @@ scale_monitors() {
echo -e "${BLUE}=========================================${RESET}" echo -e "${BLUE}=========================================${RESET}"
monitor_list=$(detect_connected_monitors) 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 # Get the highest resolution among all monitors
max_width=0 max_width=0

View File

@ -5,7 +5,7 @@
# Function to set a monitor as primary # Function to set a monitor as primary
set_primary_monitor() { set_primary_monitor() {
monitor_list=$(detect_connected_monitors) 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 clear
echo -e "${BLUE}=========================================${RESET}" echo -e "${BLUE}=========================================${RESET}"

View File

@ -13,7 +13,7 @@ CYAN='\033[36m'
# Function to set resolutions # Function to set resolutions
set_resolutions() { set_resolutions() {
monitor_list=$(detect_connected_monitors) 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 while true; do
clear clear

View File

@ -7,15 +7,15 @@ setup_xrandr() {
echo "Install xrandr if not already installed..." echo "Install xrandr if not already installed..."
if ! command_exists xrandr; then if ! command_exists xrandr; then
case ${PACKAGER} in case ${PACKAGER} in
pacman) pacman)
sudo "${PACKAGER}" -S --noconfirm xorg-xrandr sudo "${PACKAGER}" -S --noconfirm xorg-xrandr
;; ;;
apt-get) apt-get)
sudo "${PACKAGER}" install -y x11-xserver-utils sudo "${PACKAGER}" install -y x11-xserver-utils
;; ;;
*) *)
sudo "${PACKAGER}" install -y xorg-x11-server-utils sudo "${PACKAGER}" install -y xorg-x11-server-utils
;; ;;
esac esac
else else
echo "xrandr is already installed." echo "xrandr is already installed."
@ -27,11 +27,11 @@ colored_echo() {
local color=$1 local color=$1
local text=$2 local text=$2
case $color in case $color in
red) echo -e "\033[31m$text\033[0m" ;; red) echo -e "\033[31m$text\033[0m" ;;
green) echo -e "\033[32m$text\033[0m" ;; green) echo -e "\033[32m$text\033[0m" ;;
yellow) echo -e "\033[33m$text\033[0m" ;; yellow) echo -e "\033[33m$text\033[0m" ;;
blue) echo -e "\033[34m$text\033[0m" ;; blue) echo -e "\033[34m$text\033[0m" ;;
*) echo "$text" ;; *) echo "$text" ;;
esac esac
} }
@ -40,9 +40,8 @@ check_display_server() {
if [ "$XDG_SESSION_TYPE" = "wayland" ]; then if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
colored_echo "red" "You are using Wayland." colored_echo "red" "You are using Wayland."
colored_echo "red" "This script is designed for X11. It may not work correctly on 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." echo "Exiting script."
exit 1 exit 1
fi fi