-
-
Save dmelo/47f20170c90e5923c6f3 to your computer and use it in GitHub Desktop.
Shell script to control multiple displays.
This file contains 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 | |
# check the main display with xrandr and change this accordingly. | |
MAIN_DP=eDP1 | |
xrandr --output $MAIN_DP --mode 1920x1080 | |
# list of possible displays. (I have a set of adapters, each is addressed with | |
# a different name) | |
LIST=$(xrandr | grep connected | cut -d\ -f 1) | |
function reset_all { | |
for OUTPUT in $LIST | |
do | |
if [ $OUTPUT != $MAIN_DP ] | |
then | |
xrandr --output $OUTPUT --off | |
fi | |
done | |
} | |
function post_config { | |
fbsetbg /home/dmelo/wallpaper/one.jpg | |
} | |
case $1 in | |
'dual') | |
# second monitor at the right side. | |
reset_all | |
xrandr --addmode $2 1920x1080 | |
xrandr --output $2 --mode 1920x1080 | |
xrandr --output $2 --right-of $MAIN_DP | |
post_config | |
;; | |
'alone') | |
# only working with main monitor | |
reset_all | |
post_config | |
;; | |
'record') | |
# only one monitor. reduced resolution. | |
reset_all | |
xrandr --output $2 --mode 1024x768 | |
;; | |
'clone') | |
# mirrored screens | |
reset_all | |
xrandr --addmode $2 1920x1080 | |
xrandr --output $2 --mode 1920x1080 | |
post_config | |
;; | |
'home') | |
# second monitor placed above main monitor. | |
reset_all | |
xrandr --addmode $2 1920x1080 | |
xrandr --output $2 --mode 1920x1080 | |
xrandr --output $2 --above $MAIN_DP | |
post_config | |
;; | |
*) | |
echo "Usage:" | |
echo | |
echo "./m.sh MODE DISPLAY" | |
echo | |
echo " MODE: dual|alone|record|clone|home" | |
echo " DISPLAY: run xrandr without arguments, to see list of available displays." | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment