Dynamic display switching script for ATI
The proprietary fglrx driver from ATI allows dynamic display switching, e.g. to switch to an external display for a presentation. Xorg RandR 1.2 allows the same, but sometimes the newer version is not available, or not compatible e.g. when the proprietary ATI driver needs to be used for some reasons. The current version of it does not support the dynamic switching capabilities of XRandR 1.2.
In these cases, the following switching script provides the same functionality, which you can bind to a keypress such as Fn-F7 on Thinkpad laptops. The script uses ATI's aticonfig tool for switching, XRandR for resolution adjustment, and Xosd for displaying OSD status messages. Thus, it should work on most Linux-running laptops whith ATI graphics cards (tested with Ubuntu 7.04 and 7.10 on a Thinkpad T43). When an external display is connected, the script switches from internal to both internal and extarnal, then to external only, and finally back to internal display only.
Installation
- Download the files ati-toggle.sh and xosd.sh (for OSD support). Also, the fglrx driver from ATI needs to be installed. xosd with the tool osd_cat is optionally needed for OSD support.
- Place xosd.sh in /usr/local/bin/ and ati-toggle.sh in /etc/acpi/. Make them both executable.
- Create or adjust a hook to acpi-events listening to the right hotkey event (Fn-F7 on most Thinkpad laptops) in /etc/acpi/events/. On Ubuntu, that file is /etc/acpi/events/ibmvideobtn. Change it, so it looks like:
# /etc/acpi/events/ibmvideobtn # This is called when the user presses the video button. event=ibm/hotkey HKEY 00000080 00001007 action=/etc/acpi/ati-toggle.sh
The action entry needs to point to the new switching script. - After restarting the ACPI daemon by executing (on Debian or Ubuntu):
sudo /etc/init.d/acpid restart
pressing Fn-F7 should switch to an external display and back, if there is one connected.
Otherwise, you might have to change the names for internal and external display in ati-toggle.sh. On my Thinkpad, they are named lvds and crt1. You can find out their names by connecting an external display and executing as regular user:aticonfig --query-monitor