Eu usei polling para a tela externa EDID. Eu instalei o pacote read-edid, adicionei uma linha em visudo
%sudo ALL=(ALL:ALL) NOPASSWD:/usr/bin/get-edid
para permitir a utilização sem senha e usar o seguinte loop:
#!/bin/bash # edid_based_automatic_display_loop.sh export NEW_CONNECTION=1 export NEW_DISCONNECTION=1 while : do sleep 1 sudo get-edid 2>/dev/null|parse-edid 2>/dev/null|grep "PHL 271S7Q">/dev/null _DISCONNECTED='echo $?' # echo "DISCONNECTED $_DISCONNECTED" if [ $_DISCONNECTED = "0" -a $NEW_CONNECTION = "1" ] ; then export NEW_DISCONNECTION=1; export NEW_CONNECTION=0; bash /home/bruno/.screenlayout/only_external.sh elif [ $_DISCONNECTED = "1" -a $NEW_DISCONNECTION = "1" ] ; then export NEW_DISCONNECTION=0; export NEW_CONNECTION=1; bash /home/bruno/.screenlayout/only_laptop.sh fi done