I have a T430 and sometimes I'm using an HDMI Screen with a mDP to HDMI adapter as a secondary or the only monitor.
I would like to have a script that automatically detects when I unplug the external monitor and switches back to "internal monitor only"-mode.
How can I do this? Where can I get the event from? I don't want to have a script that checks every n secs if the external monitor is still there. An event based script would be better.
Last edited by XenGi (2013-07-19 04:00:13)
# got root?█
# /etc/udev/rules.d/99-hotplug.rules SUBSYSTEM=="drm", ACTION=="change", RUN+="/my/awesome/script.sh"
# /my/awesome/script.sh export DISPLAY=:0 export XAUTHORITY=/home/<user>/.Xauthority <do xrandr stuff>
I've used this with intel and nouveau, works quite well. This won't work with the binary nvidia drivers because they don't trigger a udev event. No idea about ATI.
I have a T430 with Intel only grafics and this doesn't work.
I've enable the HDMI out and disabled the LVDS out. Then I disconnected the HDMI cable. Nothing happens. When I reattach the HDMI cable the HDMI screen doesn't come back but my LVDS screen comes on.
So it seems to work but only if I reattach the HDMI screen. That's not the behavier I wanted.
Here are my scripts:
#!/bin/bash export DISPLAY=:0 export XAUTHORITY=/home/xengi/.Xauthority STATUS="`xrandr --current | grep HDMI1 | cut -d \ -f 2`" if [[ "$STATUS" == "disconnected" ]] ; then # switch HDMI off and LVDS on xrandr --output HDMI1 --off xrandr --output LVDS1 --mode 1600x900 --rate 60 fi
This works great when I run it manually.
## enable LVDS on HDMI disconnect KERNEL=="card0", SUBSYSTEM=="drm", ACTION=="change", RUN+="su xengi -c /usr/local/bin/displaymagic.sh"
This seems to be the tricky part.
I got it working! Here it is in case somebody else wants it too. Thx for your help.
Last edited by XenGi (2013-05-02 02:33:09)
# got root?█