2021-02-15 12:02:09 -06:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
exists() {
|
|
|
|
xrandr | grep ' connected' | grep "${1}" | wc -l
|
|
|
|
}
|
|
|
|
|
2021-02-15 17:16:23 -06:00
|
|
|
# commands
|
|
|
|
|
|
|
|
[ "$1" = "big" ] && \
|
|
|
|
xrandr --output LVDS1 --off && \
|
|
|
|
exit 0 || exit 1
|
|
|
|
|
|
|
|
[ "$1" = "small" ] && \
|
|
|
|
xrandr --output HDMI2 --off && \
|
|
|
|
exit 0 || exit 1
|
|
|
|
|
2021-02-15 12:02:09 -06:00
|
|
|
# usual setup: thinkpad x220 on dock connected to external
|
|
|
|
# monitor
|
|
|
|
|
|
|
|
[ $(exists "HDMI2") -gt 0 ] && \
|
|
|
|
[ $(exists "LVDS1") -gt 0 ] && \
|
|
|
|
xrandr --output LVDS1 --below HDMI2 --auto && \
|
|
|
|
exit 0 || exit 1
|
|
|
|
|
|
|
|
# thinkpad x220 connected to display on local port
|
|
|
|
|
|
|
|
[ $(exists "HDMI1") -gt 0 ] && \
|
|
|
|
[ $(exists "LVDS1") -gt 0 ] && \
|
|
|
|
xrandr --output LVDS1 --below HDMI1 --auto && \
|
|
|
|
exit 0 || exit 1
|
|
|
|
|
|
|
|
# only the thinkpad
|
|
|
|
|
|
|
|
[ $(exists "HDMI2") -eq 0 ] && \
|
|
|
|
[ $(exists "LVDS1") -gt 0 ] && \
|
2021-02-15 17:16:23 -06:00
|
|
|
xrandr --output HDMI2 --off && \
|
2021-02-15 12:02:09 -06:00
|
|
|
exit 0 || exit 1
|
|
|
|
|
|
|
|
exit 1
|