xrandr: add utility to switch between monitors
This commit is contained in:
parent
f50a8650f3
commit
9f2ecebede
22
xrandr/toggle
Executable file
22
xrandr/toggle
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
#!/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
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user