linutil/tabs/utils/monitor-control/extend_displays.sh

25 lines
699 B
Bash
Raw Normal View History

2024-08-15 03:41:41 +01:00
#!/bin/sh -e
2024-08-21 08:18:34 +01:00
. ./utility_functions.sh
2024-09-12 21:14:50 +01:00
. ../../common-script.sh
# Function to extend displays
extend_displays() {
2024-09-12 21:14:50 +01:00
monitors=$(detect_connected_monitors)
monitor_array=$(echo "$monitors" | tr '\n' ' ')
i=1
for monitor in $monitor_array; do
if [ "$i" -gt 1 ]; then
prev_monitor=$(echo "$monitor_array" | cut -d' ' -f$((i-1)))
if confirm_action "Extend $monitor to the right of $prev_monitor?"; then
printf "%b\n" "${GREEN}Extending $monitor to the right of $prev_monitor${RC}"
execute_command "xrandr --output $monitor --right-of $prev_monitor"
fi
fi
2024-09-12 21:14:50 +01:00
i=$((i + 1))
done
}
extend_displays