2024-03-15 23:00:32 +02:00

25 lines
766 B
Bash
Executable File

#!/bin/bash
# Check if both monitor names are provided as arguments
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <monitor_to_turn_on> <monitor_to_turn_off>"
echo "Connected monitors:"
xrandr | grep " connected" | awk '{print $1}'
exit 1
fi
# Define monitor names from command-line arguments
MONITOR_TO_TURN_ON="$1"
MONITOR_TO_TURN_OFF="$2"
# Check if the monitor to turn on is connected
if xrandr | grep "$MONITOR_TO_TURN_ON connected" > /dev/null; then
# Monitor to turn on is connected, switch monitors
xrandr --output "$MONITOR_TO_TURN_OFF" --off --output "$MONITOR_TO_TURN_ON" --auto
echo "Switched to $MONITOR_TO_TURN_ON and turned off $MONITOR_TO_TURN_OFF."
else
echo "Error: $MONITOR_TO_TURN_ON is not connected."
exit 1
fi