Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- main=LVDS1
- a=VGA1
- b=HDMI1
- dir=left
- function on {
- echo Switching $1 on
- xrandr --output $1 --auto --$dir-of $main
- }
- function off {
- echo Switching $1 off
- xrandr --output $1 --off
- }
- function check {
- xrandr | egrep "$1 connected" >/dev/null
- echo $?
- }
- outa=$(check $a)
- outb=$(check $b)
- [[ $outa -ne 0 ]] && off $a
- [[ $outb -ne 0 ]] && off $b
- [[ $outa -ne 0 && $outb -ne 0 ]] && exit
- [[ $outa -eq 0 && $outb -ne 0 ]] && on $a && exit
- [[ $outa -ne 0 && $outb -eq 0 ]] && on $b && exit
- xrandr | egrep "$a connected [0-9]+" >/dev/null
- outa=$?
- xrandr | egrep "$b connected [0-9]+" >/dev/null
- outb=$?
- if [[ $outa -eq 0 ]]; then
- off $a
- on $b
- else
- off $b
- on $a
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement