23 lines
685 B
Bash
Executable File
23 lines
685 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>"
|
|
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
|
|
|