Created
April 14, 2020 21:09
-
-
Save igancev/31dd717b37b437569a737846e8ef7fab to your computer and use it in GitHub Desktop.
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 | |
connected=$(xrandr | grep 'HDMI-2 connected') | |
# подключен ли монитор | |
if [[ -z "$connected" ]]; then | |
echo 'Монитор не подключен' | |
# выключим отображение, если вдруг оно активно (просто был выдернут шнур) | |
xrandr --output HDMI-2 --off | |
else | |
# монитор подключен | |
# проверим отображается ли он | |
displayed=$(xrandr | grep 'HDMI-2 connected 1920x1080+1920+0') | |
if [[ -z "$displayed" ]]; then | |
# не отображается, включим отображение | |
echo 'не отображается, включим отображение' | |
xrandr --output HDMI-2 --mode 1920x1080 --pos 1920x0 | |
else | |
# отображается, выключим отображение | |
echo 'отображается, выключим отображение' | |
xrandr --output HDMI-2 --off | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment