Last active
February 21, 2017 08:48
-
-
Save porst17/498090724b2653088b064d9dc0d097b7 to your computer and use it in GitHub Desktop.
Automatically mirror main display to other connected displays
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$#" -lt 2 ]; then | |
if [ "$#" -eq 1 ]; then | |
DISPLAYS=`xrandr | grep " connected" | sed "s/ .*$//" | grep -v "$1"` | |
DISPLAYS="$1 $DISPLAYS" | |
else | |
DISPLAYS=`xrandr | grep " connected" | sed "s/ .*$//"` | |
fi | |
ARR_DISPLAYS=( $DISPLAYS ) | |
NUM_DISPLAYS=${#ARR_DISPLAYS[@]} | |
if [ $NUM_DISPLAYS -ge 2 ]; then | |
exec $0 $DISPLAYS | |
else | |
echo Only $NUM_DISPLAYS display found | |
exit 1 | |
fi | |
else | |
MAIN=$1 | |
CMD="xrandr --output $MAIN --auto" | |
shift | |
for d in "$@" | |
do | |
CMD="$CMD --output $d --auto --same-as $MAIN" | |
done | |
notify-send "$CMD" | |
exec $CMD | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment