<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.thinkwiki.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Seva</id>
	<title>ThinkWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.thinkwiki.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Seva"/>
	<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/wiki/Special:Contributions/Seva"/>
	<updated>2026-06-30T21:26:58Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.12</generator>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=37773</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=37773"/>
		<updated>2008-05-19T21:30:56Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide will help you configure Fn-F7 key combination to toggle between internal, mirror, external, or both screens.  This was tested on ThinkPad X60s running Fedora 8, please comment if it works or does not work for you.&lt;br /&gt;
&lt;br /&gt;
Works like a charm on X61s with Xubuntu 7.10.&lt;br /&gt;
Working with R60e with some modifications noted below.&lt;br /&gt;
&lt;br /&gt;
The script does not work when using [[fglrx]] or a version of XRandR &amp;lt; 1.2, because there is no dynamic display switching support then. When fglrx is used, aticonfig can be used for the switching in this [[Script for Dynamic Display Management with fglrx]].&lt;br /&gt;
&lt;br /&gt;
==configuring the virtual screen size==&lt;br /&gt;
Add a &amp;quot;Virtual&amp;quot; statement to your /etc/X11/xorg.conf, the total resolution should be large enough to fit all your screens in the configuration you want, for example if you have 1600x1200 monitor to the left of your internal 1024x768 monitor, your total max resolution is 2624x1200 (See [[Xorg RandR 1.2]] for more details):&lt;br /&gt;
&lt;br /&gt;
 Section &amp;quot;Screen&amp;quot;&lt;br /&gt;
        Identifier &amp;quot;Screen0&amp;quot;&lt;br /&gt;
        Device     &amp;quot;Videocard0&amp;quot;&lt;br /&gt;
        DefaultDepth     24&lt;br /&gt;
         SubSection &amp;quot;Display&amp;quot;&lt;br /&gt;
                Viewport   0 0&lt;br /&gt;
                Depth     24&lt;br /&gt;
                &amp;lt;b&amp;gt;Virtual   2624 1200&amp;lt;/b&amp;gt;&lt;br /&gt;
        EndSubSection&lt;br /&gt;
 EndSection&lt;br /&gt;
&lt;br /&gt;
Restart X server at this point (i.e. logout and login).&lt;br /&gt;
&lt;br /&gt;
== configuring acpi ==&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&lt;br /&gt;
or you may (eg Ubuntu 7.10) already have /etc/acpi/events/ibm-videobtn&lt;br /&gt;
    # /etc/acpi/events/ibm-videobtn&lt;br /&gt;
    # This is called when the user presses the video button. It is currently&lt;br /&gt;
    # a placeholder.&lt;br /&gt;
    event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
    action=/bin/true&lt;br /&gt;
&lt;br /&gt;
in which case modify the line 'action=/bin/true' to run the script as above.&lt;br /&gt;
&lt;br /&gt;
It may also be necessary to enable acpi events as per [[How to get special keys to work]] with (in root terminal)&lt;br /&gt;
{{cmdroot|echo enable,0x084e &amp;gt; /proc/acpi/ibm/hotkey}}&lt;br /&gt;
Note this command isn't persistent. so you will also need to add the line to /etc/rc.local to enable hotkeys at boot, and to re-enable the hotkeys after suspend to disk or RAM, create the file&lt;br /&gt;
/etc/acpi/resume.d/91-ibm-hotkey-enable.sh consisting of&lt;br /&gt;
&lt;br /&gt;
    #!/bin/bash&lt;br /&gt;
    # enable ibm-hotkeys (specifically Fn2, Fn7)&lt;br /&gt;
    # 12 bit mask, little end is F1 default 0x080c = F12+F4+F3&lt;br /&gt;
    echo enable,0x084e &amp;gt; /proc/acpi/ibm/hotkey&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ref: [[http://tilmanfrosch.de/wp/index.php/2007/05/05/howto-make-a-ubuntu-linux-on-an-ibm-t41-thinkpad-work-with-an-external-widescreen-wxga-display/  frosch.org.uk]] and [[http://ibm-acpi.sourceforge.net/README ibm-acpi.sourceforge]]&lt;br /&gt;
&lt;br /&gt;
==identify output devices==&lt;br /&gt;
Note the names of your output devices as you will have to change EXTERNAL_OUTPUT and INTERNAL_OUTPUT to what xrandr shows, for example VGA and LVDS in this case:&lt;br /&gt;
&lt;br /&gt;
 $ xrandr -q&lt;br /&gt;
 '''VGA''' connected 1600x1200+0+0 (normal left inverted right x axis y axis) 432mm x 324mm&lt;br /&gt;
 ...&lt;br /&gt;
 '''LVDS''' connected (normal left inverted right x axis y axis)&lt;br /&gt;
&lt;br /&gt;
==The bash script==&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7, you can set EXTERNAL_LOCATION to one of: left, right, above, or below.&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# External output may be &amp;quot;VGA&amp;quot; or &amp;quot;VGA-0&amp;quot; or &amp;quot;DVI-0&amp;quot;&lt;br /&gt;
EXTERNAL_OUTPUT=&amp;quot;VGA&amp;quot;&lt;br /&gt;
INTERNAL_OUTPUT=&amp;quot;LVDS&amp;quot;&lt;br /&gt;
EXTERNAL_LOCATION=&amp;quot;left&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Figure out which user and X11 display to work on&lt;br /&gt;
# TODO there has to be a better way to do this?&lt;br /&gt;
X_USER=$(w -h -s | grep &amp;quot;:[0-9]\W&amp;quot; | head -1 | awk '{print $1}')&lt;br /&gt;
export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]\W&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
&lt;br /&gt;
# Switch to X user if necessary&lt;br /&gt;
if [ &amp;quot;$X_USER&amp;quot; != &amp;quot;$USER&amp;quot; ]; then&lt;br /&gt;
       SU=&amp;quot;su $X_USER -c&amp;quot;&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
case &amp;quot;$EXTERNAL_LOCATION&amp;quot; in&lt;br /&gt;
       left|LEFT)&lt;br /&gt;
               EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
               ;;&lt;br /&gt;
       right|RIGHT)&lt;br /&gt;
               EXTERNAL_LOCATION=&amp;quot;--right-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
               ;;&lt;br /&gt;
       top|TOP|above|ABOVE)&lt;br /&gt;
               EXTERNAL_LOCATION=&amp;quot;--above $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
               ;;&lt;br /&gt;
       bottom|BOTTOM|below|BELOW)&lt;br /&gt;
               EXTERNAL_LOCATION=&amp;quot;--below $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
               ;;&lt;br /&gt;
       *)&lt;br /&gt;
               EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
               ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
# Figure out current state&lt;br /&gt;
INTERNAL_STATE=$($SU xrandr | grep ^$INTERNAL_OUTPUT | grep con | sed &amp;quot;s/.*connected //&amp;quot; | sed &amp;quot;s/(.*//&amp;quot;)&lt;br /&gt;
EXTERNAL_STATE=$($SU xrandr | grep ^$EXTERNAL_OUTPUT | grep con | sed &amp;quot;s/.*connected //&amp;quot; | sed &amp;quot;s/(.*//&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
if [ -z &amp;quot;$INTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
       STATE=&amp;quot;external&amp;quot;&lt;br /&gt;
elif [ -z &amp;quot;$EXTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
       STATE=&amp;quot;internal&amp;quot;&lt;br /&gt;
else&lt;br /&gt;
       INTERNAL_STATE=$(echo $INTERNAL_STATE | sed &amp;quot;s/[0-9]*x[0-9]*//&amp;quot;)&lt;br /&gt;
       EXTERNAL_STATE=$(echo $EXTERNAL_STATE | sed &amp;quot;s/[0-9]*x[0-9]*//&amp;quot;)&lt;br /&gt;
       if [ &amp;quot;$INTERNAL_STATE&amp;quot; = &amp;quot;$EXTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
               STATE=&amp;quot;mirror&amp;quot;&lt;br /&gt;
       else&lt;br /&gt;
               STATE=&amp;quot;both&amp;quot;&lt;br /&gt;
       fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
function screen_external(){&lt;br /&gt;
       $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
       $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function screen_internal(){&lt;br /&gt;
       $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
       $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function screen_mirror(){&lt;br /&gt;
       $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
       $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function screen_both(){&lt;br /&gt;
       $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
       $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function screen_toggle(){&lt;br /&gt;
       case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
               internal)&lt;br /&gt;
                       screen_mirror&lt;br /&gt;
                       ;;&lt;br /&gt;
               mirror)&lt;br /&gt;
                       screen_external&lt;br /&gt;
                       ;;&lt;br /&gt;
               external)&lt;br /&gt;
                       screen_both&lt;br /&gt;
                       ;;&lt;br /&gt;
               both)&lt;br /&gt;
                       screen_internal&lt;br /&gt;
                       ;;&lt;br /&gt;
               *)&lt;br /&gt;
                       screen_internal&lt;br /&gt;
                       ;;&lt;br /&gt;
       esac&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# What should we do?&lt;br /&gt;
DO=&amp;quot;$1&amp;quot;&lt;br /&gt;
if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
       if [ $(basename $0) = &amp;quot;thinkpad-fn-f7&amp;quot; ]; then&lt;br /&gt;
               DO=&amp;quot;toggle&amp;quot;&lt;br /&gt;
       fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
       toggle)&lt;br /&gt;
               screen_toggle&lt;br /&gt;
               ;;&lt;br /&gt;
       internal)&lt;br /&gt;
               screen_internal&lt;br /&gt;
               ;;&lt;br /&gt;
       external)&lt;br /&gt;
               screen_external&lt;br /&gt;
               ;;&lt;br /&gt;
       mirror)&lt;br /&gt;
               screen_mirror&lt;br /&gt;
               ;;&lt;br /&gt;
       both)&lt;br /&gt;
               screen_both&lt;br /&gt;
               ;;&lt;br /&gt;
       status)&lt;br /&gt;
               echo &amp;quot;Current Fn-F7 state is: $STATE&amp;quot;&lt;br /&gt;
               echo&lt;br /&gt;
               echo &amp;quot;Attached monitors:&amp;quot;&lt;br /&gt;
               $SU xrandr | grep &amp;quot;\Wconnected&amp;quot; | sed &amp;quot;s/^/ /&amp;quot;&lt;br /&gt;
               ;;&lt;br /&gt;
       *)&lt;br /&gt;
               echo &amp;quot;usage: $0 &amp;lt;command&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
               echo &amp;gt;&amp;amp;2&lt;br /&gt;
               echo &amp;quot;  commands:&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
               echo &amp;quot;          status&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
               echo &amp;quot;          internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
               echo &amp;quot;          external&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
               echo &amp;quot;          mirror&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
               echo &amp;quot;          both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
               echo &amp;quot;          toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
               echo &amp;gt;&amp;amp;2&lt;br /&gt;
               ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== set permissions and restart acpi ==&lt;br /&gt;
As root, or using sudo run the following commands,&lt;br /&gt;
&lt;br /&gt;
 {{cmduser|sudo chmod 755 /usr/local/sbin/thinkpad-fn-f7}}&lt;br /&gt;
 {{cmduser|sudo service acpid restart}}&lt;br /&gt;
 OR&lt;br /&gt;
 {{cmduser|sudo /etc/init.d/acpid restart}}&lt;br /&gt;
&lt;br /&gt;
You should be ready to go, just press Fn-F7 to try.&lt;br /&gt;
&lt;br /&gt;
==Alternative script using .Xauthority rather than su ==&lt;br /&gt;
Use this script as an alternative &lt;br /&gt;
 action=/usr/local/sbin/toggle-display.sh&lt;br /&gt;
for /etc/acpi/events/ibm-videobtn&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # usr/local/sbin/toggle-display.sh &lt;br /&gt;
 # based on /etc/acpi/screenblank.sh (Ubuntu 7.10)&lt;br /&gt;
 #&lt;br /&gt;
 # . /usr/share/acpi-support/power-funcs         # for getXuser&lt;br /&gt;
 umask 022;&lt;br /&gt;
 PATH=&amp;quot;$PATH:/usr/bin/X11&amp;quot;&lt;br /&gt;
 getXuser() {&lt;br /&gt;
        user=`finger| grep -m1 &amp;quot;:$displaynum &amp;quot; | awk '{print $1}'`&lt;br /&gt;
        if [ x&amp;quot;$user&amp;quot; = x&amp;quot;&amp;quot; ]; then&lt;br /&gt;
                user=`finger| grep -m1 &amp;quot;:$displaynum&amp;quot; | awk '{print $1}'`&lt;br /&gt;
        fi&lt;br /&gt;
        if [ x&amp;quot;$user&amp;quot; != x&amp;quot;&amp;quot; ]; then&lt;br /&gt;
                userhome=`getent passwd $user | cut -d: -f6`&lt;br /&gt;
                export XAUTHORITY=$userhome/.Xauthority&lt;br /&gt;
        else&lt;br /&gt;
                export XAUTHORITY=&amp;quot;&amp;quot;&lt;br /&gt;
        fi&lt;br /&gt;
 }&lt;br /&gt;
 # end of getXuser from /usr/share/acpi-support/power-funcs&lt;br /&gt;
 #&lt;br /&gt;
 for x in /tmp/.X11-unix/*; do&lt;br /&gt;
    displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`&lt;br /&gt;
    getXuser;&lt;br /&gt;
    if [ x&amp;quot;$XAUTHORITY&amp;quot; != x&amp;quot;&amp;quot; ]; then&lt;br /&gt;
        export DISPLAY=&amp;quot;:$displaynum&amp;quot;&lt;br /&gt;
 ##     . /usr/share/acpi-support/screenblank.sh&lt;br /&gt;
        /usr/local/bin/toggle.py&lt;br /&gt;
    fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
Each user has an ~/.Xauthority file with one line for each X display containing a 'magic cookie' (Run {{cmduser| xauth list}} to see the contents).  The Xserver reads the record in  ~/.Xauthority matching its display. When an X client application starts it also looks for that record and passes the magic cookie to the server. If it matches, the connection to the Xserver is allowed. The above example  runs the python script below but could run a modified version of /usr/local/sbin/thinkpad-fn-f7 without the USER, and DISPLAY detection SU commands.&lt;br /&gt;
&lt;br /&gt;
== A Python Toggle script ==&lt;br /&gt;
This is a somewhat over-elaborate script which could be cut down when run by the /usr/local/sbin/toggle-display.sh script above. It was written to explore all the possibilities rather than economy of execution. The functions 'toggle_full', 'position', 'toggle_limited' and the OptionParser in 'main'  may be omitted with suitable changes to function7. The appropriate outputs can be specified on the command line and it is not necessary to call it via acpi.&lt;br /&gt;
eg you can run it as {{cmduser|/usr/local/bin/toggle.py --help}}&lt;br /&gt;
&lt;br /&gt;
 #! /usr/bin/python&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 #&lt;br /&gt;
 # stinkpad(a)blueyonder.co.uk	2007-11-26&lt;br /&gt;
 &amp;quot;&amp;quot;&amp;quot;Toggle internal and external displays (equivalent to ThinkPad Fn7)&lt;br /&gt;
 Simple; cloned: on+off, on+on, off+on. &lt;br /&gt;
 Full; as simple plus xinerama: right, below,  left, above. &lt;br /&gt;
 Limited; as full but display will overlap if virtual screen is too small. &lt;br /&gt;
 Use 'xrandr -q' to determine output names. &lt;br /&gt;
 Further information: http://www.thinkwiki.org/wiki/Xorg_RandR_1.2 &lt;br /&gt;
 &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
 __usage__ = &amp;quot;usage: %prog [--help]|[[-i internal][-e external][-d displays]]&amp;quot;&lt;br /&gt;
 __version__ = &amp;quot;toggle [djclark.eu 2007-11-26]&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Output names; Intel: LVDS VGA TV TMDS-1 TMDS-2&lt;br /&gt;
 #               ATI:   LVDS VGA-0 S-video DVI-0&lt;br /&gt;
 LAPTOP = 'LVDS' &lt;br /&gt;
 MONITOR = 'VGA'&lt;br /&gt;
 SEQUENCE = 'simple'&lt;br /&gt;
 #&lt;br /&gt;
 import sys&lt;br /&gt;
 import os&lt;br /&gt;
 import re&lt;br /&gt;
&lt;br /&gt;
 # &amp;quot;LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&amp;quot;&lt;br /&gt;
 REGEX_OUTPUT = re.compile(r&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
 	(?x)					# ignore whitespace&lt;br /&gt;
 	^					# start of string&lt;br /&gt;
 	(?P&amp;lt;output&amp;gt;[A-Za-z0-9\-]*)[ ] 		# LVDS VGA etc&lt;br /&gt;
 	(?P&amp;lt;connect&amp;gt;(dis)?connected)[ ]		# dis/connected&lt;br /&gt;
 	((					# a group&lt;br /&gt;
  	(?P&amp;lt;width&amp;gt;\d+)x 			# either 1024x768+0+0&lt;br /&gt;
 	(?P&amp;lt;height&amp;gt;\d+)[+]  &lt;br /&gt;
  	(?P&amp;lt;horizontal&amp;gt;\d+)[+]&lt;br /&gt;
 	(?P&amp;lt;vertical&amp;gt;\d+)&lt;br /&gt;
 	)|[\D])					# or not a digit&lt;br /&gt;
 	.*					# ignore rest of line&lt;br /&gt;
 	&amp;quot;&amp;quot;&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
 # &amp;quot;Screen 0: minimum 320 x 200, current 1024 x 768, maximum 2624 x 1968&amp;quot;&lt;br /&gt;
 REGEX_SCREEN = re.compile(r&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
 	(?x) 				# ignore whitespace&lt;br /&gt;
 	^				# start of string&lt;br /&gt;
 	Screen[ ]			&lt;br /&gt;
 	(?P&amp;lt;screen&amp;gt;\d)[: ]+&lt;br /&gt;
 	minimum[ ]&lt;br /&gt;
 	(?P&amp;lt;minWidth&amp;gt;\d+)[ x]+&lt;br /&gt;
 	(?P&amp;lt;minHeight&amp;gt;\d+)[, ]+&lt;br /&gt;
 	current[ ]+&lt;br /&gt;
 	(?P&amp;lt;curWidth&amp;gt;\d+)[ x]+&lt;br /&gt;
 	(?P&amp;lt;curHeight&amp;gt;\d+)[, ]+&lt;br /&gt;
 	maximum[ ]+&lt;br /&gt;
 	(?P&amp;lt;maxWidth&amp;gt;\d+)[ x]+&lt;br /&gt;
 	(?P&amp;lt;maxHeight&amp;gt;\d+)&lt;br /&gt;
 	&amp;quot;&amp;quot;&amp;quot;)	&lt;br /&gt;
&lt;br /&gt;
 def toggle_simple(d0, d1):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Toggle display states: on+off, on+on, off+on&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    if d1['connect'] == 'disconnected': 	# external unplugged&lt;br /&gt;
        return ('auto','off',&amp;quot;&amp;quot;) 		#     switch off external&lt;br /&gt;
    if d1['width'] is 0: 			# external off&lt;br /&gt;
        return ('auto','auto',&amp;quot;&amp;quot;) 		#     both on&lt;br /&gt;
    if d0['width'] is 0: 			# laptop off&lt;br /&gt;
        return ('auto','off',&amp;quot;&amp;quot;) 		#    laptop on&lt;br /&gt;
    return ('off','auto',&amp;quot;&amp;quot;) 			# both on, laptop off&lt;br /&gt;
&lt;br /&gt;
 def toggle_full(d0, d1):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Toggle display states: 1+0, 1+1, 0+1, 1+E, 1+S, 1+W, 1+N&amp;quot;&amp;quot;&amp;quot; &lt;br /&gt;
    if d1['connect'] == 'disconnected': 	# external unplugged&lt;br /&gt;
        return ('auto','off',&amp;quot;&amp;quot;) 		#     switch off external&lt;br /&gt;
    place = '--%s ' + d0['output']&lt;br /&gt;
    if d1['width'] == 0: 			# external off&lt;br /&gt;
        return ('auto','auto',place%'same-as') 	#     external on&lt;br /&gt;
    if d0['width'] == 0: 			# laptop off&lt;br /&gt;
        return ('auto','off',&amp;quot;&amp;quot;) 		#    laptop on&lt;br /&gt;
    if d1['horizontal'] &amp;gt; 0: 			# external to right&lt;br /&gt;
        return ('auto','auto',place%'below') 	#     make below&lt;br /&gt;
    if d1['vertical'] &amp;gt; 0: 			# external below&lt;br /&gt;
        return ('auto','auto',place%'left-of') 	#     make left&lt;br /&gt;
    if d0['horizontal'] &amp;gt; 0: 			# external left&lt;br /&gt;
        return ('auto','auto',place%'above') 	#     make above&lt;br /&gt;
    if d0['vertical'] &amp;gt; 0: 			# external above&lt;br /&gt;
        return ('off','auto',&amp;quot;&amp;quot;)  		#     laptop off&lt;br /&gt;
    return ('auto','auto',place%'right-of') 	# is same, make right&lt;br /&gt;
&lt;br /&gt;
 def position(orientation, da, db, screen):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Calculate offset position of second display&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    p = 'auto --pos %sx%s'&lt;br /&gt;
    if orientation == 'V':&lt;br /&gt;
        if (da['height'] + db['height']) &amp;lt;= screen['maxHeight']:&lt;br /&gt;
            return p%(0, da['height'])&lt;br /&gt;
        return p%(0, screen['maxHeight'] - db['height'])&lt;br /&gt;
    else:&lt;br /&gt;
        if (da['width'] + db['width']) &amp;lt;= screen['maxWidth']:&lt;br /&gt;
            return p%(da['width'],0)&lt;br /&gt;
        return p%(screen['maxWidth'] - db['width'],0)&lt;br /&gt;
&lt;br /&gt;
 def toggle_limited(d0, d1, sz):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Toggle display states (overlapped): 1+0,1+1,0+1,1+E,1+S,1+W,1+N&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    if d1['connect'] == 'disconnected': 	# external unplugged&lt;br /&gt;
        return ('auto','off') 			#     switch off external&lt;br /&gt;
    if d1['width'] == 0: 				# external off&lt;br /&gt;
        return ('auto --pos 0x0','auto --pos 0x0') 	#     both on&lt;br /&gt;
    if d0['width'] == 0: 				# laptop off&lt;br /&gt;
        return ('auto --pos 0x0','off') 		#     laptop on&lt;br /&gt;
    if d1['horizontal'] &amp;gt; 0: 				# external to right&lt;br /&gt;
        return ('auto --pos 0x0',position('V',d0,d1,sz)) #     put *below&lt;br /&gt;
    if d1['vertical'] &amp;gt; 0: 				# external below&lt;br /&gt;
        return (position('H',d1,d0,sz),'auto --pos 0x0') #     put *left&lt;br /&gt;
    if d0['horizontal'] &amp;gt; 0: 				# external left&lt;br /&gt;
        return (position('V',d1,d0,sz),'auto --pos 0x0') #     put *above&lt;br /&gt;
    if d0['vertical'] &amp;gt; 0: 				# external above&lt;br /&gt;
        return ('off','auto --pos 0x0')  		#     laptop off&lt;br /&gt;
    return ('auto --pos 0x0',position('H',d0,d1,sz)) 	# both, put*right&lt;br /&gt;
&lt;br /&gt;
 class DisplayNameError(UnboundLocalError):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Internal or External Display Name not found by xrandr -q &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 def function7(disp0=LAPTOP, disp1=MONITOR, seq=SEQUENCE):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Use xrandr to read current display state and change state&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    for line in os.popen('xrandr -q').read().splitlines():&lt;br /&gt;
        if line.startswith(disp0,0) :&lt;br /&gt;
            d0_state = REGEX_OUTPUT.match(line).groupdict()&lt;br /&gt;
        elif line.startswith(disp1,0):&lt;br /&gt;
            d1_state = REGEX_OUTPUT.match(line).groupdict()&lt;br /&gt;
        elif line.startswith('Screen',0):&lt;br /&gt;
            screen_size = REGEX_SCREEN.match(line).groupdict()&lt;br /&gt;
        else:&lt;br /&gt;
            pass&lt;br /&gt;
    for i in ('width','height','horizontal','vertical'):&lt;br /&gt;
        try:&lt;br /&gt;
            d0_state[i] = int(d0_state[i])&lt;br /&gt;
        except TypeError:&lt;br /&gt;
            d0_state[i] = 0&lt;br /&gt;
        except UnboundLocalError:&lt;br /&gt;
            raise DisplayNameError, 'Internal Display: %s not found'% disp0&lt;br /&gt;
        try:&lt;br /&gt;
            d1_state[i] = int(d1_state[i])&lt;br /&gt;
        except TypeError:&lt;br /&gt;
            d1_state[i] = 0&lt;br /&gt;
        except UnboundLocalError:&lt;br /&gt;
            raise DisplayNameError, 'External Display: %s not found'% disp1&lt;br /&gt;
    for i in screen_size.keys():&lt;br /&gt;
        try:&lt;br /&gt;
            screen_size[i] = int(screen_size[i])&lt;br /&gt;
        except TypeError:&lt;br /&gt;
            screen_size[i] = 0&lt;br /&gt;
    #&lt;br /&gt;
    toggle = toggle_simple&lt;br /&gt;
    xrandr ='xrandr --output '+disp0+' --%s --output '+disp1+' --%s %s'&lt;br /&gt;
    if seq == 'full':&lt;br /&gt;
        toggle = toggle_full&lt;br /&gt;
    if seq == 'limited':&lt;br /&gt;
        toggle = toggle_limited&lt;br /&gt;
        xrandr ='xrandr --output '+disp0+' --%s --output '+disp1+' --%s'&lt;br /&gt;
        os.popen(xrandr % toggle(d0_state, d1_state, screen_size))&lt;br /&gt;
    else:&lt;br /&gt;
        os.popen(xrandr % toggle(d0_state, d1_state))&lt;br /&gt;
&lt;br /&gt;
 def main():&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot; Command line options &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    global LAPTOP,MONITOR,SEQUENCE&lt;br /&gt;
    from optparse import OptionParser&lt;br /&gt;
    p = OptionParser(usage=__usage__, version=__version__, description=__doc__)  &lt;br /&gt;
    p.set_defaults(internal=LAPTOP, external=MONITOR, displays=SEQUENCE)&lt;br /&gt;
    p.add_option('-i','--internal', dest=&amp;quot;internal&amp;quot;, metavar=LAPTOP,&lt;br /&gt;
 	help=&amp;quot;internal display&amp;quot;)&lt;br /&gt;
    p.add_option('-e','--external', dest=&amp;quot;external&amp;quot;, metavar=MONITOR,&lt;br /&gt;
  	help=&amp;quot;external display&amp;quot;)&lt;br /&gt;
    p.add_option('-d','--displays', dest=&amp;quot;displays&amp;quot;, action=&amp;quot;store&amp;quot;,&lt;br /&gt;
 	choices=('simple', 'limited', 'full'), metavar=SEQUENCE,&lt;br /&gt;
 	help='simple/limited/full')&lt;br /&gt;
    (opt, args) = p.parse_args()&lt;br /&gt;
    try:&lt;br /&gt;
        function7(opt.internal, opt.external, opt.displays)&lt;br /&gt;
    except DisplayNameError, err:&lt;br /&gt;
        print '\n'+str(err)+'\n'&lt;br /&gt;
        print os.popen('xrandr -q').read()&lt;br /&gt;
 #&lt;br /&gt;
 if __name__ == '__main__': 	#only when run from cmd line&lt;br /&gt;
    main()&lt;br /&gt;
&lt;br /&gt;
===Python XRandR===&lt;br /&gt;
[[http://www.glatzor.de/blog/blog-details/article/initial-release-of-python-xrandr Python XRandR]] is a set of python bindings to xrandr. The code is currently in development and the following code though much simpler than the python code above may not work reliably.&lt;br /&gt;
&lt;br /&gt;
  from xrandr import xrandr&lt;br /&gt;
  def toggle_simple():&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Toggle display states: on+off, off+on, on+on off+off&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    screen = xrandr.get_current_screen()&lt;br /&gt;
    outputs = screen.get_outputs()&lt;br /&gt;
    for o in outputs:&lt;br /&gt;
        if o.is_connected():&lt;br /&gt;
            if o.is_active():&lt;br /&gt;
                o.disable()&lt;br /&gt;
                print 'disable %s'% o.name&lt;br /&gt;
            else:&lt;br /&gt;
                o.set_to_preferred_mode()&lt;br /&gt;
                print 'set to preferred mode %s'% o.name&lt;br /&gt;
                break&lt;br /&gt;
    screen.apply_output_config()&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[[http://gitweb.freedesktop.org/?p=xorg/app/grandr.git grandr]] graphical interface to xrandr  using GTK+ libraries.&lt;br /&gt;
&lt;br /&gt;
[[https://edge.launchpad.net/python-xrandr python-xrandr]] Python bindings to xrandr which should enable a less clunky version of the python script above. Under development.&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Talk:Sample_Fn-F7_script&amp;diff=35296</id>
		<title>Talk:Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Talk:Sample_Fn-F7_script&amp;diff=35296"/>
		<updated>2007-12-23T20:02:14Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Note: you will need to change the internal and external resolution until someone fixes this script to figure it out from xrandr, you may also need to change output names from &amp;quot;VGA&amp;quot; and &amp;quot;LVDS&amp;quot; to what your xrandr tells you.&lt;br /&gt;
&lt;br /&gt;
why not just use --auto ?&lt;br /&gt;
&lt;br /&gt;
 xrandr --output LVDS --auto --output VGA --off&lt;br /&gt;
 xrandr --output LVDS --off  --output VGA --auto&lt;br /&gt;
 &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Good point, made the changes --seva&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
# This is to figure out which user and X11 display to work on&lt;br /&gt;
 # TODO there has to be a better way to do this?&lt;br /&gt;
SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
concerning detecting what is currently active from xrandr. with VGA off xrandrq shows&lt;br /&gt;
&lt;br /&gt;
 Screen 0: minimum 320 x 200, current 1024 x 768, maximum 2048 x 2048&lt;br /&gt;
 VGA connected (normal left inverted right)&lt;br /&gt;
    1600x1200      60.0 +   59.9  &lt;br /&gt;
   1280x1024      75.0     59.9  &lt;br /&gt;
   1152x864       74.8  &lt;br /&gt;
   1024x768       75.1     60.0  &lt;br /&gt;
   800x600        75.0     60.3  &lt;br /&gt;
   640x480        75.0     60.0  &lt;br /&gt;
   720x400        70.1  &lt;br /&gt;
 LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&lt;br /&gt;
   1024x768       60.0*+   50.0  &lt;br /&gt;
   800x600        60.3  &lt;br /&gt;
   640x480        60.0     59.9 &lt;br /&gt;
&lt;br /&gt;
with VGA on &lt;br /&gt;
 VGA connected 1600x1200+0+0 (normal left inverted right) 367mm x 275mm&lt;br /&gt;
   1600x1200      60.0*+   59.9  &lt;br /&gt;
   1280x1024      75.0     59.9  &lt;br /&gt;
   1152x864       74.8  &lt;br /&gt;
   1024x768       75.1     60.0  &lt;br /&gt;
   800x600        75.0     60.3  &lt;br /&gt;
   640x480        75.0     60.0  &lt;br /&gt;
   720x400        70.1  &lt;br /&gt;
 LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&lt;br /&gt;
   1024x768       60.0*+   50.0  &lt;br /&gt;
   800x600        60.3  &lt;br /&gt;
   640x480        60.0     59.9  &lt;br /&gt;
&lt;br /&gt;
with LVDS off:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 djc@Twingo:~$ xrandr --output LVDS --off --output VGA --auto&lt;br /&gt;
 djc@Twingo:~$ xrandr -q&lt;br /&gt;
 Screen 0: minimum 320 x 200, current 1600 x 1200, maximum 2048 x 2048&lt;br /&gt;
 VGA connected 1600x1200+0+0 (normal left inverted right) 367mm x 275mm&lt;br /&gt;
   1600x1200      60.0*+   59.9  &lt;br /&gt;
   1280x1024      75.0     59.9  &lt;br /&gt;
   1152x864       74.8  &lt;br /&gt;
   1024x768       75.1     60.0  &lt;br /&gt;
   800x600        75.0     60.3  &lt;br /&gt;
   640x480        75.0     60.0  &lt;br /&gt;
   720x400        70.1  &lt;br /&gt;
 LVDS connected (normal left inverted right)&lt;br /&gt;
   1024x768       60.0 +   50.0  &lt;br /&gt;
   800x600        60.3  &lt;br /&gt;
   640x480        60.0     59.9  &lt;br /&gt;
&lt;br /&gt;
so detection should be possible on the differences between&lt;br /&gt;
 VGA connected 1600x1200+0+0 (normal left inverted right) 367mm x 275mm&lt;br /&gt;
 VGA connected (normal left inverted right)&lt;br /&gt;
 LVDS connected (normal left inverted right)&lt;br /&gt;
 LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&lt;br /&gt;
&lt;br /&gt;
eg between '''xxxx connected nnnnxnn+0+0 (''' and '''xxxx connected ('''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Regarding 1. acpid runs as root, so I switch to a user account before runinng xrandr, however I need to figure out which user to switch to -- hence the hack.&lt;br /&gt;
&lt;br /&gt;
Regarding 2. that doesn't tell us if screens are being mirrored or exended, just active, i think that in combination with some other tools (xwininfo -root perhaps?) could work.&lt;br /&gt;
&lt;br /&gt;
--seva&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
 djc@Twingo:~$ xrandr --output LVDS --auto --output VGA --auto --below LVDS&lt;br /&gt;
 djc@Twingo:~$ xrandr -q&lt;br /&gt;
 Screen 0: minimum 320 x 200, current 1600 x 1968, maximum 2048 x 2048&lt;br /&gt;
 VGA connected 1600x1200+0+768 (normal left inverted right) 367mm x 275mm&lt;br /&gt;
 ...&lt;br /&gt;
 LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&lt;br /&gt;
&lt;br /&gt;
so the position is in the +0+768&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Akw, I don't think the script needs to be colorized, it better to leave things the user needs to change in bold instead.&lt;br /&gt;
&lt;br /&gt;
Ordonnateur, I've made the changes so the script now figures out the state from xrandr and doesn't need to store it to a file.&lt;br /&gt;
&lt;br /&gt;
--seva&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This is great work, better than I could do. But here is another bug for you: grep connected is also picking up disconnected.&lt;br /&gt;
&lt;br /&gt;
  status)&lt;br /&gt;
               echo &amp;quot;Current Fn-F7 state is: $STATE&amp;quot;&lt;br /&gt;
               echo&lt;br /&gt;
               echo &amp;quot;Attached monitors:&amp;quot;&lt;br /&gt;
               xrandr | grep connected | sed &amp;quot;s/^/ /&amp;quot;&lt;br /&gt;
&lt;br /&gt;
gives&lt;br /&gt;
&lt;br /&gt;
 djc@Twingo:~$ Desktop/thinkpad-fn-f7.sh status&lt;br /&gt;
 Current Fn-F7 state is: internal&lt;br /&gt;
&lt;br /&gt;
 Attached monitors:&lt;br /&gt;
  VGA disconnected (normal left inverted right)&lt;br /&gt;
  LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
fixed --seva&lt;br /&gt;
&lt;br /&gt;
Re detecting the X user, it may be just as ugly but have you looked at &lt;br /&gt;
  /usr/share/acpi-support/power-funcs&lt;br /&gt;
&lt;br /&gt;
for example this is the /etc/acpi/screenblank.sh in Ubuntu 7.10&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 . /etc/default/acpi-support&lt;br /&gt;
 . /usr/share/acpi-support/power-funcs&lt;br /&gt;
 for x in /tmp/.X11-unix/*; do&lt;br /&gt;
    displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`&lt;br /&gt;
    getXuser;&lt;br /&gt;
    if [ x&amp;quot;$XAUTHORITY&amp;quot; != x&amp;quot;&amp;quot; ]; then&lt;br /&gt;
         export DISPLAY=&amp;quot;:$displaynum&amp;quot;&lt;br /&gt;
 	. /usr/share/acpi-support/screenblank&lt;br /&gt;
    fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Husky69, `w` output looks like this for me:&lt;br /&gt;
&lt;br /&gt;
 [seva@brain ~]$ w -h -s&lt;br /&gt;
 seva     tty7     :0                0.00s /usr/bin/gnome-session&lt;br /&gt;
&lt;br /&gt;
So `awk '{print $3}'` is correct, does w output look different for you?&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Talk:Sample_Fn-F7_script&amp;diff=35295</id>
		<title>Talk:Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Talk:Sample_Fn-F7_script&amp;diff=35295"/>
		<updated>2007-12-23T19:59:29Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Note: you will need to change the internal and external resolution until someone fixes this script to figure it out from xrandr, you may also need to change output names from &amp;quot;VGA&amp;quot; and &amp;quot;LVDS&amp;quot; to what your xrandr tells you.&lt;br /&gt;
&lt;br /&gt;
why not just use --auto ?&lt;br /&gt;
&lt;br /&gt;
 xrandr --output LVDS --auto --output VGA --off&lt;br /&gt;
 xrandr --output LVDS --off  --output VGA --auto&lt;br /&gt;
 &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Good point, made the changes --seva&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
# This is to figure out which user and X11 display to work on&lt;br /&gt;
 # TODO there has to be a better way to do this?&lt;br /&gt;
SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
concerning detecting what is currently active from xrandr. with VGA off xrandrq shows&lt;br /&gt;
&lt;br /&gt;
 Screen 0: minimum 320 x 200, current 1024 x 768, maximum 2048 x 2048&lt;br /&gt;
 VGA connected (normal left inverted right)&lt;br /&gt;
    1600x1200      60.0 +   59.9  &lt;br /&gt;
   1280x1024      75.0     59.9  &lt;br /&gt;
   1152x864       74.8  &lt;br /&gt;
   1024x768       75.1     60.0  &lt;br /&gt;
   800x600        75.0     60.3  &lt;br /&gt;
   640x480        75.0     60.0  &lt;br /&gt;
   720x400        70.1  &lt;br /&gt;
 LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&lt;br /&gt;
   1024x768       60.0*+   50.0  &lt;br /&gt;
   800x600        60.3  &lt;br /&gt;
   640x480        60.0     59.9 &lt;br /&gt;
&lt;br /&gt;
with VGA on &lt;br /&gt;
 VGA connected 1600x1200+0+0 (normal left inverted right) 367mm x 275mm&lt;br /&gt;
   1600x1200      60.0*+   59.9  &lt;br /&gt;
   1280x1024      75.0     59.9  &lt;br /&gt;
   1152x864       74.8  &lt;br /&gt;
   1024x768       75.1     60.0  &lt;br /&gt;
   800x600        75.0     60.3  &lt;br /&gt;
   640x480        75.0     60.0  &lt;br /&gt;
   720x400        70.1  &lt;br /&gt;
 LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&lt;br /&gt;
   1024x768       60.0*+   50.0  &lt;br /&gt;
   800x600        60.3  &lt;br /&gt;
   640x480        60.0     59.9  &lt;br /&gt;
&lt;br /&gt;
with LVDS off:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 djc@Twingo:~$ xrandr --output LVDS --off --output VGA --auto&lt;br /&gt;
 djc@Twingo:~$ xrandr -q&lt;br /&gt;
 Screen 0: minimum 320 x 200, current 1600 x 1200, maximum 2048 x 2048&lt;br /&gt;
 VGA connected 1600x1200+0+0 (normal left inverted right) 367mm x 275mm&lt;br /&gt;
   1600x1200      60.0*+   59.9  &lt;br /&gt;
   1280x1024      75.0     59.9  &lt;br /&gt;
   1152x864       74.8  &lt;br /&gt;
   1024x768       75.1     60.0  &lt;br /&gt;
   800x600        75.0     60.3  &lt;br /&gt;
   640x480        75.0     60.0  &lt;br /&gt;
   720x400        70.1  &lt;br /&gt;
 LVDS connected (normal left inverted right)&lt;br /&gt;
   1024x768       60.0 +   50.0  &lt;br /&gt;
   800x600        60.3  &lt;br /&gt;
   640x480        60.0     59.9  &lt;br /&gt;
&lt;br /&gt;
so detection should be possible on the differences between&lt;br /&gt;
 VGA connected 1600x1200+0+0 (normal left inverted right) 367mm x 275mm&lt;br /&gt;
 VGA connected (normal left inverted right)&lt;br /&gt;
 LVDS connected (normal left inverted right)&lt;br /&gt;
 LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&lt;br /&gt;
&lt;br /&gt;
eg between '''xxxx connected nnnnxnn+0+0 (''' and '''xxxx connected ('''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Regarding 1. acpid runs as root, so I switch to a user account before runinng xrandr, however I need to figure out which user to switch to -- hence the hack.&lt;br /&gt;
&lt;br /&gt;
Regarding 2. that doesn't tell us if screens are being mirrored or exended, just active, i think that in combination with some other tools (xwininfo -root perhaps?) could work.&lt;br /&gt;
&lt;br /&gt;
--seva&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
 djc@Twingo:~$ xrandr --output LVDS --auto --output VGA --auto --below LVDS&lt;br /&gt;
 djc@Twingo:~$ xrandr -q&lt;br /&gt;
 Screen 0: minimum 320 x 200, current 1600 x 1968, maximum 2048 x 2048&lt;br /&gt;
 VGA connected 1600x1200+0+768 (normal left inverted right) 367mm x 275mm&lt;br /&gt;
 ...&lt;br /&gt;
 LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&lt;br /&gt;
&lt;br /&gt;
so the position is in the +0+768&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Akw, I don't think the script needs to be colorized, it better to leave things the user needs to change in bold instead.&lt;br /&gt;
&lt;br /&gt;
Ordonnateur, I've made the changes so the script now figures out the state from xrandr and doesn't need to store it to a file.&lt;br /&gt;
&lt;br /&gt;
--seva&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This is great work, better than I could do. But here is another bug for you: grep connected is also picking up disconnected.&lt;br /&gt;
&lt;br /&gt;
  status)&lt;br /&gt;
               echo &amp;quot;Current Fn-F7 state is: $STATE&amp;quot;&lt;br /&gt;
               echo&lt;br /&gt;
               echo &amp;quot;Attached monitors:&amp;quot;&lt;br /&gt;
               xrandr | grep connected | sed &amp;quot;s/^/ /&amp;quot;&lt;br /&gt;
&lt;br /&gt;
gives&lt;br /&gt;
&lt;br /&gt;
 djc@Twingo:~$ Desktop/thinkpad-fn-f7.sh status&lt;br /&gt;
 Current Fn-F7 state is: internal&lt;br /&gt;
&lt;br /&gt;
 Attached monitors:&lt;br /&gt;
  VGA disconnected (normal left inverted right)&lt;br /&gt;
  LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
fixed --seva&lt;br /&gt;
&lt;br /&gt;
Re detecting the X user, it may be just as ugly but have you looked at &lt;br /&gt;
  /usr/share/acpi-support/power-funcs&lt;br /&gt;
&lt;br /&gt;
for example this is the /etc/acpi/screenblank.sh in Ubuntu 7.10&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 . /etc/default/acpi-support&lt;br /&gt;
 . /usr/share/acpi-support/power-funcs&lt;br /&gt;
 for x in /tmp/.X11-unix/*; do&lt;br /&gt;
    displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`&lt;br /&gt;
    getXuser;&lt;br /&gt;
    if [ x&amp;quot;$XAUTHORITY&amp;quot; != x&amp;quot;&amp;quot; ]; then&lt;br /&gt;
         export DISPLAY=&amp;quot;:$displaynum&amp;quot;&lt;br /&gt;
 	. /usr/share/acpi-support/screenblank&lt;br /&gt;
    fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
`w` output looks like this for me:&lt;br /&gt;
&lt;br /&gt;
 [seva@brain ~]$ w -h -s&lt;br /&gt;
 seva     tty7     :0                0.00s /usr/bin/gnome-session&lt;br /&gt;
&lt;br /&gt;
So `awk '{print $3}'` is correct, does w output look different for you?&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=35292</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=35292"/>
		<updated>2007-12-23T19:57:17Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide will help you configure Fn-F7 key combination to toggle between internal, mirror, external, or both screens.  This was tested on ThinkPad X60s running Fedora 8, please comment if it works or does not work for you.&lt;br /&gt;
&lt;br /&gt;
Works like a charm on X61s with Xubuntu 7.10.&lt;br /&gt;
Working with R60e with some modifications noted below.&lt;br /&gt;
&lt;br /&gt;
==configuring the virtual screen size==&lt;br /&gt;
Add a &amp;quot;Virtual&amp;quot; statement to your /etc/X11/xorg.conf, the total resolution should be large enough to fit all your screens in the configuration you want, for example if you have 1600x1200 monitor to the left of your internal 1024x768 monitor, your total max resolution is 2624x1200 (See [[Xorg RandR 1.2]] for more details):&lt;br /&gt;
&lt;br /&gt;
 Section &amp;quot;Screen&amp;quot;&lt;br /&gt;
        Identifier &amp;quot;Screen0&amp;quot;&lt;br /&gt;
        Device     &amp;quot;Videocard0&amp;quot;&lt;br /&gt;
        DefaultDepth     24&lt;br /&gt;
         SubSection &amp;quot;Display&amp;quot;&lt;br /&gt;
                Viewport   0 0&lt;br /&gt;
                Depth     24&lt;br /&gt;
                &amp;lt;b&amp;gt;Virtual   2624 1200&amp;lt;/b&amp;gt;&lt;br /&gt;
        EndSubSection&lt;br /&gt;
 EndSection&lt;br /&gt;
&lt;br /&gt;
Restart X server at this point (i.e. logout and login).&lt;br /&gt;
&lt;br /&gt;
== configuring acpi ==&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&lt;br /&gt;
or you may (eg Ubuntu 7.10) already have /etc/acpi/events/ibm-videobtn&lt;br /&gt;
    # /etc/acpi/events/ibm-videobtn&lt;br /&gt;
    # This is called when the user presses the video button. It is currently&lt;br /&gt;
    # a placeholder.&lt;br /&gt;
    event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
    action=/bin/true&lt;br /&gt;
&lt;br /&gt;
in which case modify the line 'action=/bin/true' to run the script as above.&lt;br /&gt;
&lt;br /&gt;
It may also be necessary to enable acpi events as per [[How to get special keys to work]] with (in root terminal)&lt;br /&gt;
{{cmdroot|echo enable,0x084e &amp;gt; /proc/acpi/ibm/hotkey}}&lt;br /&gt;
Note this command isn't persistent. so you will also need to add the line to /etc/rc.local to enable hotkeys at boot, and to re-enable the hotkeys after suspend to disk or RAM, create the file&lt;br /&gt;
/etc/acpi/resume.d/91-ibm-hotkey-enable.sh consisting of&lt;br /&gt;
&lt;br /&gt;
    #!/bin/bash&lt;br /&gt;
    # enable ibm-hotkeys (specifically Fn2, Fn7)&lt;br /&gt;
    # 12 bit mask, little end is F1 default 0x080c = F12+F4+F3&lt;br /&gt;
    echo enable,0x084e &amp;gt; /proc/acpi/ibm/hotkey&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ref: [[http://tilmanfrosch.de/wp/index.php/2007/05/05/howto-make-a-ubuntu-linux-on-an-ibm-t41-thinkpad-work-with-an-external-widescreen-wxga-display/  frosch.org.uk]] and [[http://ibm-acpi.sourceforge.net/README ibm-acpi.sourceforge]]&lt;br /&gt;
&lt;br /&gt;
==identify output devices==&lt;br /&gt;
Note the names of your output devices as you will have to change EXTERNAL_OUTPUT and INTERNAL_OUTPUT to what xrandr shows, for example VGA and LVDS in this case:&lt;br /&gt;
&lt;br /&gt;
 $ xrandr -q&lt;br /&gt;
 '''VGA''' connected 1600x1200+0+0 (normal left inverted right x axis y axis) 432mm x 324mm&lt;br /&gt;
 ...&lt;br /&gt;
 '''LVDS''' connected (normal left inverted right x axis y axis)&lt;br /&gt;
&lt;br /&gt;
==The bash script==&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7, you can set EXTERNAL_LOCATION to one of: left, right, above, or below.&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 &lt;br /&gt;
 # External output may be &amp;quot;VGA&amp;quot; or &amp;quot;VGA-0&amp;quot; or &amp;quot;DVI-0&amp;quot;&lt;br /&gt;
 EXTERNAL_OUTPUT=&amp;quot;'''VGA'''&amp;quot;&lt;br /&gt;
 INTERNAL_OUTPUT=&amp;quot;'''LVDS'''&amp;quot;&lt;br /&gt;
 EXTERNAL_LOCATION=&amp;quot;'''left'''&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # Figure out which user and X11 display to work on&lt;br /&gt;
 # TODO there has to be a better way to do this?&lt;br /&gt;
 X_USER=$(w -h -s | grep &amp;quot;:[0-9]\W&amp;quot; | head -1 | awk '{print $1}')&lt;br /&gt;
 export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]\W&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
 &lt;br /&gt;
 # Switch to X user if necessary&lt;br /&gt;
 if [ &amp;quot;$X_USER&amp;quot; != &amp;quot;$USER&amp;quot; ]; then&lt;br /&gt;
        SU=&amp;quot;su $X_USER -c&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$EXTERNAL_LOCATION&amp;quot; in&lt;br /&gt;
        left|LEFT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        right|RIGHT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--right-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        top|TOP|above|ABOVE)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--above $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        bottom|BOTTOM|below|BELOW)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--below $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
 &lt;br /&gt;
 # Figure out current state&lt;br /&gt;
 INTERNAL_STATE=$($SU xrandr | grep ^$INTERNAL_OUTPUT | grep con | sed &amp;quot;s/.*connected //&amp;quot; | sed &amp;quot;s/(.*//&amp;quot;)&lt;br /&gt;
 EXTERNAL_STATE=$($SU xrandr | grep ^$EXTERNAL_OUTPUT | grep con | sed &amp;quot;s/.*connected //&amp;quot; | sed &amp;quot;s/(.*//&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
 if [ -z &amp;quot;$INTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
        STATE=&amp;quot;external&amp;quot;&lt;br /&gt;
 elif [ -z &amp;quot;$EXTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
        STATE=&amp;quot;internal&amp;quot;&lt;br /&gt;
 else&lt;br /&gt;
        INTERNAL_STATE=$(echo $INTERNAL_STATE | sed &amp;quot;s/[0-9]*x[0-9]*//&amp;quot;)&lt;br /&gt;
        EXTERNAL_STATE=$(echo $EXTERNAL_STATE | sed &amp;quot;s/[0-9]*x[0-9]*//&amp;quot;)&lt;br /&gt;
        if [ &amp;quot;$INTERNAL_STATE&amp;quot; = &amp;quot;$EXTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
                STATE=&amp;quot;mirror&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
                STATE=&amp;quot;both&amp;quot;&lt;br /&gt;
        fi&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_mirror(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_toggle(){&lt;br /&gt;
        case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                internal)&lt;br /&gt;
                        screen_mirror&lt;br /&gt;
                        ;;&lt;br /&gt;
                mirror)&lt;br /&gt;
                        screen_external&lt;br /&gt;
                        ;;&lt;br /&gt;
                external)&lt;br /&gt;
                        screen_both&lt;br /&gt;
                        ;;&lt;br /&gt;
                both)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
                *)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
        esac&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # What should we do?&lt;br /&gt;
 DO=&amp;quot;$1&amp;quot;&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        if [ $(basename $0) = &amp;quot;thinkpad-fn-f7&amp;quot; ]; then&lt;br /&gt;
                DO=&amp;quot;toggle&amp;quot;&lt;br /&gt;
        fi&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        toggle)&lt;br /&gt;
                screen_toggle&lt;br /&gt;
                ;;&lt;br /&gt;
        internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        mirror)&lt;br /&gt;
                screen_mirror&lt;br /&gt;
                ;;&lt;br /&gt;
        both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        status)&lt;br /&gt;
                echo &amp;quot;Current Fn-F7 state is: $STATE&amp;quot;&lt;br /&gt;
                echo&lt;br /&gt;
                echo &amp;quot;Attached monitors:&amp;quot;&lt;br /&gt;
                $SU xrandr | grep &amp;quot;\Wconnected&amp;quot; | sed &amp;quot;s/^/ /&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: $0 &amp;lt;command&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  commands:&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          status&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          external&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          mirror&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
&lt;br /&gt;
== set permissions and restart acpi ==&lt;br /&gt;
As root, or using sudo run the following commands,&lt;br /&gt;
&lt;br /&gt;
 {{cmduser|sudo chmod 755 /usr/local/sbin/thinkpad-fn-f7}}&lt;br /&gt;
 {{cmduser|sudo service acpid restart}}&lt;br /&gt;
 OR&lt;br /&gt;
 {{cmduser|sudo /etc/init.d/acpid restart}}&lt;br /&gt;
&lt;br /&gt;
You should be ready to go, just press Fn-F7 to try.&lt;br /&gt;
&lt;br /&gt;
==Alternative script using .Xauthority rather than su ==&lt;br /&gt;
Use this script as an alternative &lt;br /&gt;
 action=/usr/local/sbin/toggle-display.sh&lt;br /&gt;
for /etc/acpi/events/ibm-videobtn&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # usr/local/sbin/toggle-display.sh &lt;br /&gt;
 # based on /etc/acpi/screenblank.sh (Ubuntu 7.10)&lt;br /&gt;
 #&lt;br /&gt;
 # . /usr/share/acpi-support/power-funcs         # for getXuser&lt;br /&gt;
 umask 022;&lt;br /&gt;
 PATH=&amp;quot;$PATH:/usr/bin/X11&amp;quot;&lt;br /&gt;
 getXuser() {&lt;br /&gt;
        user=`finger| grep -m1 &amp;quot;:$displaynum &amp;quot; | awk '{print $1}'`&lt;br /&gt;
        if [ x&amp;quot;$user&amp;quot; = x&amp;quot;&amp;quot; ]; then&lt;br /&gt;
                user=`finger| grep -m1 &amp;quot;:$displaynum&amp;quot; | awk '{print $1}'`&lt;br /&gt;
        fi&lt;br /&gt;
        if [ x&amp;quot;$user&amp;quot; != x&amp;quot;&amp;quot; ]; then&lt;br /&gt;
                userhome=`getent passwd $user | cut -d: -f6`&lt;br /&gt;
                export XAUTHORITY=$userhome/.Xauthority&lt;br /&gt;
        else&lt;br /&gt;
                export XAUTHORITY=&amp;quot;&amp;quot;&lt;br /&gt;
        fi&lt;br /&gt;
 }&lt;br /&gt;
 # end of getXuser from /usr/share/acpi-support/power-funcs&lt;br /&gt;
 #&lt;br /&gt;
 for x in /tmp/.X11-unix/*; do&lt;br /&gt;
    displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`&lt;br /&gt;
    getXuser;&lt;br /&gt;
    if [ x&amp;quot;$XAUTHORITY&amp;quot; != x&amp;quot;&amp;quot; ]; then&lt;br /&gt;
        export DISPLAY=&amp;quot;:$displaynum&amp;quot;&lt;br /&gt;
 ##     . /usr/share/acpi-support/screenblank.sh&lt;br /&gt;
        /usr/local/bin/toggle.py&lt;br /&gt;
    fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
Each user has an ~/.Xauthority file with one line for each X display containing a 'magic cookie' (Run {{cmduser| xauth list}} to see the contents).  The Xserver reads the record in  ~/.Xauthority matching its display. When an X client application starts it also looks for that record and passes the magic cookie to the server. If it matches, the connection to the Xserver is allowed. The above example  runs the python script below but could run a modified version of /usr/local/sbin/thinkpad-fn-f7 without the USER, and DISPLAY detection SU commands.&lt;br /&gt;
&lt;br /&gt;
== A Python Toggle script ==&lt;br /&gt;
This is a somewhat over-elaborate script which could be cut down when run by the /usr/local/sbin/toggle-display.sh script above. It was written to explore all the possibilities rather than economy of execution. The functions 'toggle_full', 'position', 'toggle_limited' and the OptionParser in 'main'  may be omitted with suitable changes to function7. The appropriate outputs can be specified on the command line and it is not necessary to call it via acpi.&lt;br /&gt;
eg you can run it as {{cmduser|/usr/local/bin/toggle.py --help}}&lt;br /&gt;
&lt;br /&gt;
 #! /usr/bin/python&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 #&lt;br /&gt;
 # stinkpad(a)blueyonder.co.uk	2007-11-26&lt;br /&gt;
 &amp;quot;&amp;quot;&amp;quot;Toggle internal and external displays (equivalent to ThinkPad Fn7)&lt;br /&gt;
 Simple; cloned: on+off, on+on, off+on. &lt;br /&gt;
 Full; as simple plus xinerama: right, below,  left, above. &lt;br /&gt;
 Limited; as full but display will overlap if virtual screen is too small. &lt;br /&gt;
 Use 'xrandr -q' to determine output names. &lt;br /&gt;
 Further information: http://www.thinkwiki.org/wiki/Xorg_RandR_1.2 &lt;br /&gt;
 &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
 __usage__ = &amp;quot;usage: %prog [--help]|[[-i internal][-e external][-d displays]]&amp;quot;&lt;br /&gt;
 __version__ = &amp;quot;toggle [djclark.eu 2007-11-26]&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Output names; Intel: LVDS VGA TV TMDS-1 TMDS-2&lt;br /&gt;
 #               ATI:   LVDS VGA-0 S-video DVI-0&lt;br /&gt;
 LAPTOP = 'LVDS' &lt;br /&gt;
 MONITOR = 'VGA'&lt;br /&gt;
 SEQUENCE = 'simple'&lt;br /&gt;
 #&lt;br /&gt;
 import sys&lt;br /&gt;
 import os&lt;br /&gt;
 import re&lt;br /&gt;
&lt;br /&gt;
 # &amp;quot;LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&amp;quot;&lt;br /&gt;
 REGEX_OUTPUT = re.compile(r&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
 	(?x)					# ignore whitespace&lt;br /&gt;
 	^					# start of string&lt;br /&gt;
 	(?P&amp;lt;output&amp;gt;[A-Za-z0-9\-]*)[ ] 		# LVDS VGA etc&lt;br /&gt;
 	(?P&amp;lt;connect&amp;gt;(dis)?connected)[ ]		# dis/connected&lt;br /&gt;
 	((					# a group&lt;br /&gt;
  	(?P&amp;lt;width&amp;gt;\d+)x 			# either 1024x768+0+0&lt;br /&gt;
 	(?P&amp;lt;height&amp;gt;\d+)[+]  &lt;br /&gt;
  	(?P&amp;lt;horizontal&amp;gt;\d+)[+]&lt;br /&gt;
 	(?P&amp;lt;vertical&amp;gt;\d+)&lt;br /&gt;
 	)|[\D])					# or not a digit&lt;br /&gt;
 	.*					# ignore rest of line&lt;br /&gt;
 	&amp;quot;&amp;quot;&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
 # &amp;quot;Screen 0: minimum 320 x 200, current 1024 x 768, maximum 2624 x 1968&amp;quot;&lt;br /&gt;
 REGEX_SCREEN = re.compile(r&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
 	(?x) 				# ignore whitespace&lt;br /&gt;
 	^				# start of string&lt;br /&gt;
 	Screen[ ]			&lt;br /&gt;
 	(?P&amp;lt;screen&amp;gt;\d)[: ]+&lt;br /&gt;
 	minimum[ ]&lt;br /&gt;
 	(?P&amp;lt;minWidth&amp;gt;\d+)[ x]+&lt;br /&gt;
 	(?P&amp;lt;minHeight&amp;gt;\d+)[, ]+&lt;br /&gt;
 	current[ ]+&lt;br /&gt;
 	(?P&amp;lt;curWidth&amp;gt;\d+)[ x]+&lt;br /&gt;
 	(?P&amp;lt;curHeight&amp;gt;\d+)[, ]+&lt;br /&gt;
 	maximum[ ]+&lt;br /&gt;
 	(?P&amp;lt;maxWidth&amp;gt;\d+)[ x]+&lt;br /&gt;
 	(?P&amp;lt;maxHeight&amp;gt;\d+)&lt;br /&gt;
 	&amp;quot;&amp;quot;&amp;quot;)	&lt;br /&gt;
&lt;br /&gt;
 def toggle_simple(d0, d1):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Toggle display states: on+off, on+on, off+on&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    if d1['connect'] == 'disconnected': 	# external unplugged&lt;br /&gt;
        return ('auto','off',&amp;quot;&amp;quot;) 		#     switch off external&lt;br /&gt;
    if d1['width'] is 0: 			# external off&lt;br /&gt;
        return ('auto','auto',&amp;quot;&amp;quot;) 		#     both on&lt;br /&gt;
    if d0['width'] is 0: 			# laptop off&lt;br /&gt;
        return ('auto','off',&amp;quot;&amp;quot;) 		#    laptop on&lt;br /&gt;
    return ('off','auto',&amp;quot;&amp;quot;) 			# both on, laptop off&lt;br /&gt;
&lt;br /&gt;
 def toggle_full(d0, d1):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Toggle display states: 1+0, 1+1, 0+1, 1+E, 1+S, 1+W, 1+N&amp;quot;&amp;quot;&amp;quot; &lt;br /&gt;
    if d1['connect'] == 'disconnected': 	# external unplugged&lt;br /&gt;
        return ('auto','off',&amp;quot;&amp;quot;) 		#     switch off external&lt;br /&gt;
    place = '--%s ' + d0['output']&lt;br /&gt;
    if d1['width'] == 0: 			# external off&lt;br /&gt;
        return ('auto','auto',place%'same-as') 	#     external on&lt;br /&gt;
    if d0['width'] == 0: 			# laptop off&lt;br /&gt;
        return ('auto','off',&amp;quot;&amp;quot;) 		#    laptop on&lt;br /&gt;
    if d1['horizontal'] &amp;gt; 0: 			# external to right&lt;br /&gt;
        return ('auto','auto',place%'below') 	#     make below&lt;br /&gt;
    if d1['vertical'] &amp;gt; 0: 			# external below&lt;br /&gt;
        return ('auto','auto',place%'left-of') 	#     make left&lt;br /&gt;
    if d0['horizontal'] &amp;gt; 0: 			# external left&lt;br /&gt;
        return ('auto','auto',place%'above') 	#     make above&lt;br /&gt;
    if d0['vertical'] &amp;gt; 0: 			# external above&lt;br /&gt;
        return ('off','auto',&amp;quot;&amp;quot;)  		#     laptop off&lt;br /&gt;
    return ('auto','auto',place%'right-of') 	# is same, make right&lt;br /&gt;
&lt;br /&gt;
 def position(orientation, da, db, screen):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Calculate offset position of second display&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    p = 'auto --pos %sx%s'&lt;br /&gt;
    if orientation == 'V':&lt;br /&gt;
        if (da['height'] + db['height']) &amp;lt;= screen['maxHeight']:&lt;br /&gt;
            return p%(0, da['height'])&lt;br /&gt;
        return p%(0, screen['maxHeight'] - db['height'])&lt;br /&gt;
    else:&lt;br /&gt;
        if (da['width'] + db['width']) &amp;lt;= screen['maxWidth']:&lt;br /&gt;
            return p%(da['width'],0)&lt;br /&gt;
        return p%(screen['maxWidth'] - db['width'],0)&lt;br /&gt;
&lt;br /&gt;
 def toggle_limited(d0, d1, sz):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Toggle display states (overlapped): 1+0,1+1,0+1,1+E,1+S,1+W,1+N&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    if d1['connect'] == 'disconnected': 	# external unplugged&lt;br /&gt;
        return ('auto','off') 			#     switch off external&lt;br /&gt;
    if d1['width'] == 0: 				# external off&lt;br /&gt;
        return ('auto --pos 0x0','auto --pos 0x0') 	#     both on&lt;br /&gt;
    if d0['width'] == 0: 				# laptop off&lt;br /&gt;
        return ('auto --pos 0x0','off') 		#     laptop on&lt;br /&gt;
    if d1['horizontal'] &amp;gt; 0: 				# external to right&lt;br /&gt;
        return ('auto --pos 0x0',position('V',d0,d1,sz)) #     put *below&lt;br /&gt;
    if d1['vertical'] &amp;gt; 0: 				# external below&lt;br /&gt;
        return (position('H',d1,d0,sz),'auto --pos 0x0') #     put *left&lt;br /&gt;
    if d0['horizontal'] &amp;gt; 0: 				# external left&lt;br /&gt;
        return (position('V',d1,d0,sz),'auto --pos 0x0') #     put *above&lt;br /&gt;
    if d0['vertical'] &amp;gt; 0: 				# external above&lt;br /&gt;
        return ('off','auto --pos 0x0')  		#     laptop off&lt;br /&gt;
    return ('auto --pos 0x0',position('H',d0,d1,sz)) 	# both, put*right&lt;br /&gt;
&lt;br /&gt;
 class DisplayNameError(UnboundLocalError):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Internal or External Display Name not found by xrandr -q &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 def function7(disp0=LAPTOP, disp1=MONITOR, seq=SEQUENCE):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Use xrandr to read current display state and change state&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    for line in os.popen('xrandr -q').read().splitlines():&lt;br /&gt;
        if line.startswith(disp0,0) :&lt;br /&gt;
            d0_state = REGEX_OUTPUT.match(line).groupdict()&lt;br /&gt;
        elif line.startswith(disp1,0):&lt;br /&gt;
            d1_state = REGEX_OUTPUT.match(line).groupdict()&lt;br /&gt;
        elif line.startswith('Screen',0):&lt;br /&gt;
            screen_size = REGEX_SCREEN.match(line).groupdict()&lt;br /&gt;
        else:&lt;br /&gt;
            pass&lt;br /&gt;
    for i in ('width','height','horizontal','vertical'):&lt;br /&gt;
        try:&lt;br /&gt;
            d0_state[i] = int(d0_state[i])&lt;br /&gt;
        except TypeError:&lt;br /&gt;
            d0_state[i] = 0&lt;br /&gt;
        except UnboundLocalError:&lt;br /&gt;
            raise DisplayNameError, 'Internal Display: %s not found'% disp0&lt;br /&gt;
        try:&lt;br /&gt;
            d1_state[i] = int(d1_state[i])&lt;br /&gt;
        except TypeError:&lt;br /&gt;
            d1_state[i] = 0&lt;br /&gt;
        except UnboundLocalError:&lt;br /&gt;
            raise DisplayNameError, 'External Display: %s not found'% disp1&lt;br /&gt;
    for i in screen_size.keys():&lt;br /&gt;
        try:&lt;br /&gt;
            screen_size[i] = int(screen_size[i])&lt;br /&gt;
        except TypeError:&lt;br /&gt;
            screen_size[i] = 0&lt;br /&gt;
    #&lt;br /&gt;
    toggle = toggle_simple&lt;br /&gt;
    xrandr ='xrandr --output '+disp0+' --%s --output '+disp1+' --%s %s'&lt;br /&gt;
    if seq == 'full':&lt;br /&gt;
        toggle = toggle_full&lt;br /&gt;
    if seq == 'limited':&lt;br /&gt;
        toggle = toggle_limited&lt;br /&gt;
        xrandr ='xrandr --output '+disp0+' --%s --output '+disp1+' --%s'&lt;br /&gt;
        os.popen(xrandr % toggle(d0_state, d1_state, screen_size))&lt;br /&gt;
    else:&lt;br /&gt;
        os.popen(xrandr % toggle(d0_state, d1_state))&lt;br /&gt;
&lt;br /&gt;
 def main():&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot; Command line options &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    global LAPTOP,MONITOR,SEQUENCE&lt;br /&gt;
    from optparse import OptionParser&lt;br /&gt;
    p = OptionParser(usage=__usage__, version=__version__, description=__doc__)  &lt;br /&gt;
    p.set_defaults(internal=LAPTOP, external=MONITOR, displays=SEQUENCE)&lt;br /&gt;
    p.add_option('-i','--internal', dest=&amp;quot;internal&amp;quot;, metavar=LAPTOP,&lt;br /&gt;
 	help=&amp;quot;internal display&amp;quot;)&lt;br /&gt;
    p.add_option('-e','--external', dest=&amp;quot;external&amp;quot;, metavar=MONITOR,&lt;br /&gt;
  	help=&amp;quot;external display&amp;quot;)&lt;br /&gt;
    p.add_option('-d','--displays', dest=&amp;quot;displays&amp;quot;, action=&amp;quot;store&amp;quot;,&lt;br /&gt;
 	choices=('simple', 'limited', 'full'), metavar=SEQUENCE,&lt;br /&gt;
 	help='simple/limited/full')&lt;br /&gt;
    (opt, args) = p.parse_args()&lt;br /&gt;
    try:&lt;br /&gt;
        function7(opt.internal, opt.external, opt.displays)&lt;br /&gt;
    except DisplayNameError, err:&lt;br /&gt;
        print '\n'+str(err)+'\n'&lt;br /&gt;
        print os.popen('xrandr -q').read()&lt;br /&gt;
 #&lt;br /&gt;
 if __name__ == '__main__': 	#only when run from cmd line&lt;br /&gt;
    main()&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[[http://gitweb.freedesktop.org/?p=xorg/app/grandr.git grandr]] graphical interface to xrandr  using GTK+ libraries.&lt;br /&gt;
&lt;br /&gt;
[[https://edge.launchpad.net/python-xrandr python-xrandr]] Python bindings to xrandr which should enable a less clunky version of the python script above. Under development.&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=35291</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=35291"/>
		<updated>2007-12-23T19:56:01Z</updated>

		<summary type="html">&lt;p&gt;Seva: Undo revision 35115 by Husky69 (Talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide will help you configure Fn-F7 key combination to toggle between internal, mirror, external, or both screens.  This was tested on ThinkPad X60s running Fedora 8, please comment if it works or does not work for you.&lt;br /&gt;
&lt;br /&gt;
Works like a charm on X61s with Xubuntu 7.10.&lt;br /&gt;
Working with R60e with some modifications noted below.&lt;br /&gt;
&lt;br /&gt;
==configuring the virtual screen size==&lt;br /&gt;
Add a &amp;quot;Virtual&amp;quot; statement to your /etc/X11/xorg.conf, the total resolution should be large enough to fit all your screens in the configuration you want, for example if you have 1600x1200 monitor to the left of your internal 1024x768 monitor, your total max resolution is 2624x1200 (See [[Xorg RandR 1.2]] for more details):&lt;br /&gt;
&lt;br /&gt;
 Section &amp;quot;Screen&amp;quot;&lt;br /&gt;
        Identifier &amp;quot;Screen0&amp;quot;&lt;br /&gt;
        Device     &amp;quot;Videocard0&amp;quot;&lt;br /&gt;
        DefaultDepth     24&lt;br /&gt;
         SubSection &amp;quot;Display&amp;quot;&lt;br /&gt;
                Viewport   0 0&lt;br /&gt;
                Depth     24&lt;br /&gt;
                &amp;lt;b&amp;gt;Virtual   2624 1200&amp;lt;/b&amp;gt;&lt;br /&gt;
        EndSubSection&lt;br /&gt;
 EndSection&lt;br /&gt;
&lt;br /&gt;
Restart X server at this point (i.e. logout and login).&lt;br /&gt;
&lt;br /&gt;
== configuring acpi ==&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&lt;br /&gt;
or you may (eg Ubuntu 7.10) already have /etc/acpi/events/ibm-videobtn&lt;br /&gt;
    # /etc/acpi/events/ibm-videobtn&lt;br /&gt;
    # This is called when the user presses the video button. It is currently&lt;br /&gt;
    # a placeholder.&lt;br /&gt;
    event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
    action=/bin/true&lt;br /&gt;
&lt;br /&gt;
in which case modify the line 'action=/bin/true' to run the script as above.&lt;br /&gt;
&lt;br /&gt;
It may also be necessary to enable acpi events as per [[How to get special keys to work]] with (in root terminal)&lt;br /&gt;
{{cmdroot|echo enable,0x084e &amp;gt; /proc/acpi/ibm/hotkey}}&lt;br /&gt;
Note this command isn't persistent. so you will also need to add the line to /etc/rc.local to enable hotkeys at boot, and to re-enable the hotkeys after suspend to disk or RAM, create the file&lt;br /&gt;
/etc/acpi/resume.d/91-ibm-hotkey-enable.sh consisting of&lt;br /&gt;
&lt;br /&gt;
    #!/bin/bash&lt;br /&gt;
    # enable ibm-hotkeys (specifically Fn2, Fn7)&lt;br /&gt;
    # 12 bit mask, little end is F1 default 0x080c = F12+F4+F3&lt;br /&gt;
    echo enable,0x084e &amp;gt; /proc/acpi/ibm/hotkey&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ref: [[http://tilmanfrosch.de/wp/index.php/2007/05/05/howto-make-a-ubuntu-linux-on-an-ibm-t41-thinkpad-work-with-an-external-widescreen-wxga-display/  frosch.org.uk]] and [[http://ibm-acpi.sourceforge.net/README ibm-acpi.sourceforge]]&lt;br /&gt;
&lt;br /&gt;
==identify output devices==&lt;br /&gt;
Note the names of your output devices as you will have to change EXTERNAL_OUTPUT and INTERNAL_OUTPUT to what xrandr shows, for example VGA and LVDS in this case:&lt;br /&gt;
&lt;br /&gt;
 $ xrandr -q&lt;br /&gt;
 '''VGA''' connected 1600x1200+0+0 (normal left inverted right x axis y axis) 432mm x 324mm&lt;br /&gt;
 ...&lt;br /&gt;
 '''LVDS''' connected (normal left inverted right x axis y axis)&lt;br /&gt;
&lt;br /&gt;
==The bash script==&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7, you can set EXTERNAL_LOCATION to one of: left, right, above, or below.&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 &lt;br /&gt;
 # External output may be &amp;quot;VGA&amp;quot; or &amp;quot;VGA-0&amp;quot; or &amp;quot;DVI-0&amp;quot;&lt;br /&gt;
 EXTERNAL_OUTPUT=&amp;quot;'''VGA'''&amp;quot;&lt;br /&gt;
 INTERNAL_OUTPUT=&amp;quot;'''LVDS'''&amp;quot;&lt;br /&gt;
 EXTERNAL_LOCATION=&amp;quot;'''left'''&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # Figure out which user and X11 display to work on&lt;br /&gt;
 # TODO there has to be a better way to do this?&lt;br /&gt;
 X_USER=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}')&lt;br /&gt;
 export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
 &lt;br /&gt;
 # Switch to X user if necessary&lt;br /&gt;
 if [ &amp;quot;$X_USER&amp;quot; != &amp;quot;$USER&amp;quot; ]; then&lt;br /&gt;
        SU=&amp;quot;su $X_USER -c&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$EXTERNAL_LOCATION&amp;quot; in&lt;br /&gt;
        left|LEFT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        right|RIGHT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--right-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        top|TOP|above|ABOVE)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--above $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        bottom|BOTTOM|below|BELOW)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--below $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
 &lt;br /&gt;
 # Figure out current state&lt;br /&gt;
 INTERNAL_STATE=$($SU xrandr | grep ^$INTERNAL_OUTPUT | grep con | sed &amp;quot;s/.*connected //&amp;quot; | sed &amp;quot;s/(.*//&amp;quot;)&lt;br /&gt;
 EXTERNAL_STATE=$($SU xrandr | grep ^$EXTERNAL_OUTPUT | grep con | sed &amp;quot;s/.*connected //&amp;quot; | sed &amp;quot;s/(.*//&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
 if [ -z &amp;quot;$INTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
        STATE=&amp;quot;external&amp;quot;&lt;br /&gt;
 elif [ -z &amp;quot;$EXTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
        STATE=&amp;quot;internal&amp;quot;&lt;br /&gt;
 else&lt;br /&gt;
        INTERNAL_STATE=$(echo $INTERNAL_STATE | sed &amp;quot;s/[0-9]*x[0-9]*//&amp;quot;)&lt;br /&gt;
        EXTERNAL_STATE=$(echo $EXTERNAL_STATE | sed &amp;quot;s/[0-9]*x[0-9]*//&amp;quot;)&lt;br /&gt;
        if [ &amp;quot;$INTERNAL_STATE&amp;quot; = &amp;quot;$EXTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
                STATE=&amp;quot;mirror&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
                STATE=&amp;quot;both&amp;quot;&lt;br /&gt;
        fi&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_mirror(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_toggle(){&lt;br /&gt;
        case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                internal)&lt;br /&gt;
                        screen_mirror&lt;br /&gt;
                        ;;&lt;br /&gt;
                mirror)&lt;br /&gt;
                        screen_external&lt;br /&gt;
                        ;;&lt;br /&gt;
                external)&lt;br /&gt;
                        screen_both&lt;br /&gt;
                        ;;&lt;br /&gt;
                both)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
                *)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
        esac&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # What should we do?&lt;br /&gt;
 DO=&amp;quot;$1&amp;quot;&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        if [ $(basename $0) = &amp;quot;thinkpad-fn-f7&amp;quot; ]; then&lt;br /&gt;
                DO=&amp;quot;toggle&amp;quot;&lt;br /&gt;
        fi&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        toggle)&lt;br /&gt;
                screen_toggle&lt;br /&gt;
                ;;&lt;br /&gt;
        internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        mirror)&lt;br /&gt;
                screen_mirror&lt;br /&gt;
                ;;&lt;br /&gt;
        both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        status)&lt;br /&gt;
                echo &amp;quot;Current Fn-F7 state is: $STATE&amp;quot;&lt;br /&gt;
                echo&lt;br /&gt;
                echo &amp;quot;Attached monitors:&amp;quot;&lt;br /&gt;
                $SU xrandr | grep &amp;quot;\Wconnected&amp;quot; | sed &amp;quot;s/^/ /&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: $0 &amp;lt;command&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  commands:&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          status&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          external&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          mirror&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
&lt;br /&gt;
== set permissions and restart acpi ==&lt;br /&gt;
As root, or using sudo run the following commands,&lt;br /&gt;
&lt;br /&gt;
 {{cmduser|sudo chmod 755 /usr/local/sbin/thinkpad-fn-f7}}&lt;br /&gt;
 {{cmduser|sudo service acpid restart}}&lt;br /&gt;
 OR&lt;br /&gt;
 {{cmduser|sudo /etc/init.d/acpid restart}}&lt;br /&gt;
&lt;br /&gt;
You should be ready to go, just press Fn-F7 to try.&lt;br /&gt;
&lt;br /&gt;
==Alternative script using .Xauthority rather than su ==&lt;br /&gt;
Use this script as an alternative &lt;br /&gt;
 action=/usr/local/sbin/toggle-display.sh&lt;br /&gt;
for /etc/acpi/events/ibm-videobtn&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # usr/local/sbin/toggle-display.sh &lt;br /&gt;
 # based on /etc/acpi/screenblank.sh (Ubuntu 7.10)&lt;br /&gt;
 #&lt;br /&gt;
 # . /usr/share/acpi-support/power-funcs         # for getXuser&lt;br /&gt;
 umask 022;&lt;br /&gt;
 PATH=&amp;quot;$PATH:/usr/bin/X11&amp;quot;&lt;br /&gt;
 getXuser() {&lt;br /&gt;
        user=`finger| grep -m1 &amp;quot;:$displaynum &amp;quot; | awk '{print $1}'`&lt;br /&gt;
        if [ x&amp;quot;$user&amp;quot; = x&amp;quot;&amp;quot; ]; then&lt;br /&gt;
                user=`finger| grep -m1 &amp;quot;:$displaynum&amp;quot; | awk '{print $1}'`&lt;br /&gt;
        fi&lt;br /&gt;
        if [ x&amp;quot;$user&amp;quot; != x&amp;quot;&amp;quot; ]; then&lt;br /&gt;
                userhome=`getent passwd $user | cut -d: -f6`&lt;br /&gt;
                export XAUTHORITY=$userhome/.Xauthority&lt;br /&gt;
        else&lt;br /&gt;
                export XAUTHORITY=&amp;quot;&amp;quot;&lt;br /&gt;
        fi&lt;br /&gt;
 }&lt;br /&gt;
 # end of getXuser from /usr/share/acpi-support/power-funcs&lt;br /&gt;
 #&lt;br /&gt;
 for x in /tmp/.X11-unix/*; do&lt;br /&gt;
    displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`&lt;br /&gt;
    getXuser;&lt;br /&gt;
    if [ x&amp;quot;$XAUTHORITY&amp;quot; != x&amp;quot;&amp;quot; ]; then&lt;br /&gt;
        export DISPLAY=&amp;quot;:$displaynum&amp;quot;&lt;br /&gt;
 ##     . /usr/share/acpi-support/screenblank.sh&lt;br /&gt;
        /usr/local/bin/toggle.py&lt;br /&gt;
    fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
Each user has an ~/.Xauthority file with one line for each X display containing a 'magic cookie' (Run {{cmduser| xauth list}} to see the contents).  The Xserver reads the record in  ~/.Xauthority matching its display. When an X client application starts it also looks for that record and passes the magic cookie to the server. If it matches, the connection to the Xserver is allowed. The above example  runs the python script below but could run a modified version of /usr/local/sbin/thinkpad-fn-f7 without the USER, and DISPLAY detection SU commands.&lt;br /&gt;
&lt;br /&gt;
== A Python Toggle script ==&lt;br /&gt;
This is a somewhat over-elaborate script which could be cut down when run by the /usr/local/sbin/toggle-display.sh script above. It was written to explore all the possibilities rather than economy of execution. The functions 'toggle_full', 'position', 'toggle_limited' and the OptionParser in 'main'  may be omitted with suitable changes to function7. The appropriate outputs can be specified on the command line and it is not necessary to call it via acpi.&lt;br /&gt;
eg you can run it as {{cmduser|/usr/local/bin/toggle.py --help}}&lt;br /&gt;
&lt;br /&gt;
 #! /usr/bin/python&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 #&lt;br /&gt;
 # stinkpad(a)blueyonder.co.uk	2007-11-26&lt;br /&gt;
 &amp;quot;&amp;quot;&amp;quot;Toggle internal and external displays (equivalent to ThinkPad Fn7)&lt;br /&gt;
 Simple; cloned: on+off, on+on, off+on. &lt;br /&gt;
 Full; as simple plus xinerama: right, below,  left, above. &lt;br /&gt;
 Limited; as full but display will overlap if virtual screen is too small. &lt;br /&gt;
 Use 'xrandr -q' to determine output names. &lt;br /&gt;
 Further information: http://www.thinkwiki.org/wiki/Xorg_RandR_1.2 &lt;br /&gt;
 &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
 __usage__ = &amp;quot;usage: %prog [--help]|[[-i internal][-e external][-d displays]]&amp;quot;&lt;br /&gt;
 __version__ = &amp;quot;toggle [djclark.eu 2007-11-26]&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Output names; Intel: LVDS VGA TV TMDS-1 TMDS-2&lt;br /&gt;
 #               ATI:   LVDS VGA-0 S-video DVI-0&lt;br /&gt;
 LAPTOP = 'LVDS' &lt;br /&gt;
 MONITOR = 'VGA'&lt;br /&gt;
 SEQUENCE = 'simple'&lt;br /&gt;
 #&lt;br /&gt;
 import sys&lt;br /&gt;
 import os&lt;br /&gt;
 import re&lt;br /&gt;
&lt;br /&gt;
 # &amp;quot;LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&amp;quot;&lt;br /&gt;
 REGEX_OUTPUT = re.compile(r&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
 	(?x)					# ignore whitespace&lt;br /&gt;
 	^					# start of string&lt;br /&gt;
 	(?P&amp;lt;output&amp;gt;[A-Za-z0-9\-]*)[ ] 		# LVDS VGA etc&lt;br /&gt;
 	(?P&amp;lt;connect&amp;gt;(dis)?connected)[ ]		# dis/connected&lt;br /&gt;
 	((					# a group&lt;br /&gt;
  	(?P&amp;lt;width&amp;gt;\d+)x 			# either 1024x768+0+0&lt;br /&gt;
 	(?P&amp;lt;height&amp;gt;\d+)[+]  &lt;br /&gt;
  	(?P&amp;lt;horizontal&amp;gt;\d+)[+]&lt;br /&gt;
 	(?P&amp;lt;vertical&amp;gt;\d+)&lt;br /&gt;
 	)|[\D])					# or not a digit&lt;br /&gt;
 	.*					# ignore rest of line&lt;br /&gt;
 	&amp;quot;&amp;quot;&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
 # &amp;quot;Screen 0: minimum 320 x 200, current 1024 x 768, maximum 2624 x 1968&amp;quot;&lt;br /&gt;
 REGEX_SCREEN = re.compile(r&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
 	(?x) 				# ignore whitespace&lt;br /&gt;
 	^				# start of string&lt;br /&gt;
 	Screen[ ]			&lt;br /&gt;
 	(?P&amp;lt;screen&amp;gt;\d)[: ]+&lt;br /&gt;
 	minimum[ ]&lt;br /&gt;
 	(?P&amp;lt;minWidth&amp;gt;\d+)[ x]+&lt;br /&gt;
 	(?P&amp;lt;minHeight&amp;gt;\d+)[, ]+&lt;br /&gt;
 	current[ ]+&lt;br /&gt;
 	(?P&amp;lt;curWidth&amp;gt;\d+)[ x]+&lt;br /&gt;
 	(?P&amp;lt;curHeight&amp;gt;\d+)[, ]+&lt;br /&gt;
 	maximum[ ]+&lt;br /&gt;
 	(?P&amp;lt;maxWidth&amp;gt;\d+)[ x]+&lt;br /&gt;
 	(?P&amp;lt;maxHeight&amp;gt;\d+)&lt;br /&gt;
 	&amp;quot;&amp;quot;&amp;quot;)	&lt;br /&gt;
&lt;br /&gt;
 def toggle_simple(d0, d1):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Toggle display states: on+off, on+on, off+on&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    if d1['connect'] == 'disconnected': 	# external unplugged&lt;br /&gt;
        return ('auto','off',&amp;quot;&amp;quot;) 		#     switch off external&lt;br /&gt;
    if d1['width'] is 0: 			# external off&lt;br /&gt;
        return ('auto','auto',&amp;quot;&amp;quot;) 		#     both on&lt;br /&gt;
    if d0['width'] is 0: 			# laptop off&lt;br /&gt;
        return ('auto','off',&amp;quot;&amp;quot;) 		#    laptop on&lt;br /&gt;
    return ('off','auto',&amp;quot;&amp;quot;) 			# both on, laptop off&lt;br /&gt;
&lt;br /&gt;
 def toggle_full(d0, d1):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Toggle display states: 1+0, 1+1, 0+1, 1+E, 1+S, 1+W, 1+N&amp;quot;&amp;quot;&amp;quot; &lt;br /&gt;
    if d1['connect'] == 'disconnected': 	# external unplugged&lt;br /&gt;
        return ('auto','off',&amp;quot;&amp;quot;) 		#     switch off external&lt;br /&gt;
    place = '--%s ' + d0['output']&lt;br /&gt;
    if d1['width'] == 0: 			# external off&lt;br /&gt;
        return ('auto','auto',place%'same-as') 	#     external on&lt;br /&gt;
    if d0['width'] == 0: 			# laptop off&lt;br /&gt;
        return ('auto','off',&amp;quot;&amp;quot;) 		#    laptop on&lt;br /&gt;
    if d1['horizontal'] &amp;gt; 0: 			# external to right&lt;br /&gt;
        return ('auto','auto',place%'below') 	#     make below&lt;br /&gt;
    if d1['vertical'] &amp;gt; 0: 			# external below&lt;br /&gt;
        return ('auto','auto',place%'left-of') 	#     make left&lt;br /&gt;
    if d0['horizontal'] &amp;gt; 0: 			# external left&lt;br /&gt;
        return ('auto','auto',place%'above') 	#     make above&lt;br /&gt;
    if d0['vertical'] &amp;gt; 0: 			# external above&lt;br /&gt;
        return ('off','auto',&amp;quot;&amp;quot;)  		#     laptop off&lt;br /&gt;
    return ('auto','auto',place%'right-of') 	# is same, make right&lt;br /&gt;
&lt;br /&gt;
 def position(orientation, da, db, screen):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Calculate offset position of second display&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    p = 'auto --pos %sx%s'&lt;br /&gt;
    if orientation == 'V':&lt;br /&gt;
        if (da['height'] + db['height']) &amp;lt;= screen['maxHeight']:&lt;br /&gt;
            return p%(0, da['height'])&lt;br /&gt;
        return p%(0, screen['maxHeight'] - db['height'])&lt;br /&gt;
    else:&lt;br /&gt;
        if (da['width'] + db['width']) &amp;lt;= screen['maxWidth']:&lt;br /&gt;
            return p%(da['width'],0)&lt;br /&gt;
        return p%(screen['maxWidth'] - db['width'],0)&lt;br /&gt;
&lt;br /&gt;
 def toggle_limited(d0, d1, sz):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Toggle display states (overlapped): 1+0,1+1,0+1,1+E,1+S,1+W,1+N&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    if d1['connect'] == 'disconnected': 	# external unplugged&lt;br /&gt;
        return ('auto','off') 			#     switch off external&lt;br /&gt;
    if d1['width'] == 0: 				# external off&lt;br /&gt;
        return ('auto --pos 0x0','auto --pos 0x0') 	#     both on&lt;br /&gt;
    if d0['width'] == 0: 				# laptop off&lt;br /&gt;
        return ('auto --pos 0x0','off') 		#     laptop on&lt;br /&gt;
    if d1['horizontal'] &amp;gt; 0: 				# external to right&lt;br /&gt;
        return ('auto --pos 0x0',position('V',d0,d1,sz)) #     put *below&lt;br /&gt;
    if d1['vertical'] &amp;gt; 0: 				# external below&lt;br /&gt;
        return (position('H',d1,d0,sz),'auto --pos 0x0') #     put *left&lt;br /&gt;
    if d0['horizontal'] &amp;gt; 0: 				# external left&lt;br /&gt;
        return (position('V',d1,d0,sz),'auto --pos 0x0') #     put *above&lt;br /&gt;
    if d0['vertical'] &amp;gt; 0: 				# external above&lt;br /&gt;
        return ('off','auto --pos 0x0')  		#     laptop off&lt;br /&gt;
    return ('auto --pos 0x0',position('H',d0,d1,sz)) 	# both, put*right&lt;br /&gt;
&lt;br /&gt;
 class DisplayNameError(UnboundLocalError):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Internal or External Display Name not found by xrandr -q &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 def function7(disp0=LAPTOP, disp1=MONITOR, seq=SEQUENCE):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Use xrandr to read current display state and change state&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    for line in os.popen('xrandr -q').read().splitlines():&lt;br /&gt;
        if line.startswith(disp0,0) :&lt;br /&gt;
            d0_state = REGEX_OUTPUT.match(line).groupdict()&lt;br /&gt;
        elif line.startswith(disp1,0):&lt;br /&gt;
            d1_state = REGEX_OUTPUT.match(line).groupdict()&lt;br /&gt;
        elif line.startswith('Screen',0):&lt;br /&gt;
            screen_size = REGEX_SCREEN.match(line).groupdict()&lt;br /&gt;
        else:&lt;br /&gt;
            pass&lt;br /&gt;
    for i in ('width','height','horizontal','vertical'):&lt;br /&gt;
        try:&lt;br /&gt;
            d0_state[i] = int(d0_state[i])&lt;br /&gt;
        except TypeError:&lt;br /&gt;
            d0_state[i] = 0&lt;br /&gt;
        except UnboundLocalError:&lt;br /&gt;
            raise DisplayNameError, 'Internal Display: %s not found'% disp0&lt;br /&gt;
        try:&lt;br /&gt;
            d1_state[i] = int(d1_state[i])&lt;br /&gt;
        except TypeError:&lt;br /&gt;
            d1_state[i] = 0&lt;br /&gt;
        except UnboundLocalError:&lt;br /&gt;
            raise DisplayNameError, 'External Display: %s not found'% disp1&lt;br /&gt;
    for i in screen_size.keys():&lt;br /&gt;
        try:&lt;br /&gt;
            screen_size[i] = int(screen_size[i])&lt;br /&gt;
        except TypeError:&lt;br /&gt;
            screen_size[i] = 0&lt;br /&gt;
    #&lt;br /&gt;
    toggle = toggle_simple&lt;br /&gt;
    xrandr ='xrandr --output '+disp0+' --%s --output '+disp1+' --%s %s'&lt;br /&gt;
    if seq == 'full':&lt;br /&gt;
        toggle = toggle_full&lt;br /&gt;
    if seq == 'limited':&lt;br /&gt;
        toggle = toggle_limited&lt;br /&gt;
        xrandr ='xrandr --output '+disp0+' --%s --output '+disp1+' --%s'&lt;br /&gt;
        os.popen(xrandr % toggle(d0_state, d1_state, screen_size))&lt;br /&gt;
    else:&lt;br /&gt;
        os.popen(xrandr % toggle(d0_state, d1_state))&lt;br /&gt;
&lt;br /&gt;
 def main():&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot; Command line options &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    global LAPTOP,MONITOR,SEQUENCE&lt;br /&gt;
    from optparse import OptionParser&lt;br /&gt;
    p = OptionParser(usage=__usage__, version=__version__, description=__doc__)  &lt;br /&gt;
    p.set_defaults(internal=LAPTOP, external=MONITOR, displays=SEQUENCE)&lt;br /&gt;
    p.add_option('-i','--internal', dest=&amp;quot;internal&amp;quot;, metavar=LAPTOP,&lt;br /&gt;
 	help=&amp;quot;internal display&amp;quot;)&lt;br /&gt;
    p.add_option('-e','--external', dest=&amp;quot;external&amp;quot;, metavar=MONITOR,&lt;br /&gt;
  	help=&amp;quot;external display&amp;quot;)&lt;br /&gt;
    p.add_option('-d','--displays', dest=&amp;quot;displays&amp;quot;, action=&amp;quot;store&amp;quot;,&lt;br /&gt;
 	choices=('simple', 'limited', 'full'), metavar=SEQUENCE,&lt;br /&gt;
 	help='simple/limited/full')&lt;br /&gt;
    (opt, args) = p.parse_args()&lt;br /&gt;
    try:&lt;br /&gt;
        function7(opt.internal, opt.external, opt.displays)&lt;br /&gt;
    except DisplayNameError, err:&lt;br /&gt;
        print '\n'+str(err)+'\n'&lt;br /&gt;
        print os.popen('xrandr -q').read()&lt;br /&gt;
 #&lt;br /&gt;
 if __name__ == '__main__': 	#only when run from cmd line&lt;br /&gt;
    main()&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[[http://gitweb.freedesktop.org/?p=xorg/app/grandr.git grandr]] graphical interface to xrandr  using GTK+ libraries.&lt;br /&gt;
&lt;br /&gt;
[[https://edge.launchpad.net/python-xrandr python-xrandr]] Python bindings to xrandr which should enable a less clunky version of the python script above. Under development.&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34535</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34535"/>
		<updated>2007-11-14T01:05:42Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide will help you configure Fn-F7 key combination to toggle between internal, mirror, external, or both screens.  This was tested on ThinkPad X60s running Fedora 8, please comment if it works or does not work for you.&lt;br /&gt;
&lt;br /&gt;
Add a &amp;quot;Virtual&amp;quot; statement to your /etc/X11/xorg.conf, the total resolution should be large enough to fit all your screens in the configuration you want, for example if you have 1600x1200 monitor to the left of your internal 1024x768 monitor, your total max resolution is 2624x1200 (See [[Xorg RandR 1.2]] for more details):&lt;br /&gt;
&lt;br /&gt;
 Section &amp;quot;Screen&amp;quot;&lt;br /&gt;
        Identifier &amp;quot;Screen0&amp;quot;&lt;br /&gt;
        Device     &amp;quot;Videocard0&amp;quot;&lt;br /&gt;
        DefaultDepth     24&lt;br /&gt;
        SubSection &amp;quot;Display&amp;quot;&lt;br /&gt;
                Viewport   0 0&lt;br /&gt;
                Depth     24&lt;br /&gt;
                &amp;lt;b&amp;gt;Virtual   2624 1200&amp;lt;/b&amp;gt;&lt;br /&gt;
        EndSubSection&lt;br /&gt;
 EndSection&lt;br /&gt;
&lt;br /&gt;
Restart X server at this point (i.e. logout and login).&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&lt;br /&gt;
Note the names of your output devices as you will have to change EXTERNAL_OUTPUT and INTERNAL_OUTPUT to what xrandr shows, for example VGA and LVDS in this case:&lt;br /&gt;
&lt;br /&gt;
 $ xrandr | grep connected&lt;br /&gt;
 '''VGA''' connected 1600x1200+0+0 (normal left inverted right x axis y axis) 432mm x 324mm&lt;br /&gt;
 '''LVDS''' connected (normal left inverted right x axis y axis)&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7, you can set EXTERNAL_LOCATION to one of: left, right, above, or below.&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 &lt;br /&gt;
 # External output may be &amp;quot;VGA&amp;quot; or &amp;quot;VGA-0&amp;quot; or &amp;quot;DVI-0&amp;quot;&lt;br /&gt;
 EXTERNAL_OUTPUT=&amp;quot;'''VGA'''&amp;quot;&lt;br /&gt;
 INTERNAL_OUTPUT=&amp;quot;'''LVDS'''&amp;quot;&lt;br /&gt;
 EXTERNAL_LOCATION=&amp;quot;'''left'''&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # Figure out which user and X11 display to work on&lt;br /&gt;
 # TODO there has to be a better way to do this?&lt;br /&gt;
 X_USER=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}')&lt;br /&gt;
 export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
 &lt;br /&gt;
 # Switch to X user if necessary&lt;br /&gt;
 if [ &amp;quot;$X_USER&amp;quot; != &amp;quot;$USER&amp;quot; ]; then&lt;br /&gt;
        SU=&amp;quot;su $X_USER -c&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$EXTERNAL_LOCATION&amp;quot; in&lt;br /&gt;
        left|LEFT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        right|RIGHT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--right-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        top|TOP|above|ABOVE)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--above $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        bottom|BOTTOM|below|BELOW)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--below $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
 &lt;br /&gt;
 # Figure out current state&lt;br /&gt;
 INTERNAL_STATE=$($SU xrandr | grep ^$INTERNAL_OUTPUT | grep con | sed &amp;quot;s/.*connected //&amp;quot; | sed &amp;quot;s/(.*//&amp;quot;)&lt;br /&gt;
 EXTERNAL_STATE=$($SU xrandr | grep ^$EXTERNAL_OUTPUT | grep con | sed &amp;quot;s/.*connected //&amp;quot; | sed &amp;quot;s/(.*//&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
 if [ -z &amp;quot;$INTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
        STATE=&amp;quot;external&amp;quot;&lt;br /&gt;
 elif [ -z &amp;quot;$EXTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
        STATE=&amp;quot;internal&amp;quot;&lt;br /&gt;
 else&lt;br /&gt;
        INTERNAL_STATE=$(echo $INTERNAL_STATE | sed &amp;quot;s/[0-9]*x[0-9]*//&amp;quot;)&lt;br /&gt;
        EXTERNAL_STATE=$(echo $EXTERNAL_STATE | sed &amp;quot;s/[0-9]*x[0-9]*//&amp;quot;)&lt;br /&gt;
        if [ &amp;quot;$INTERNAL_STATE&amp;quot; = &amp;quot;$EXTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
                STATE=&amp;quot;mirror&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
                STATE=&amp;quot;both&amp;quot;&lt;br /&gt;
        fi&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_mirror(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_toggle(){&lt;br /&gt;
        case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                internal)&lt;br /&gt;
                        screen_mirror&lt;br /&gt;
                        ;;&lt;br /&gt;
                mirror)&lt;br /&gt;
                        screen_external&lt;br /&gt;
                        ;;&lt;br /&gt;
                external)&lt;br /&gt;
                        screen_both&lt;br /&gt;
                        ;;&lt;br /&gt;
                both)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
                *)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
        esac&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # What should we do?&lt;br /&gt;
 DO=&amp;quot;$1&amp;quot;&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        if [ $(basename $0) = &amp;quot;thinkpad-fn-f7&amp;quot; ]; then&lt;br /&gt;
                DO=&amp;quot;toggle&amp;quot;&lt;br /&gt;
        fi&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        toggle)&lt;br /&gt;
                screen_toggle&lt;br /&gt;
                ;;&lt;br /&gt;
        internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        mirror)&lt;br /&gt;
                screen_mirror&lt;br /&gt;
                ;;&lt;br /&gt;
        both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        status)&lt;br /&gt;
                echo &amp;quot;Current Fn-F7 state is: $STATE&amp;quot;&lt;br /&gt;
                echo&lt;br /&gt;
                echo &amp;quot;Attached monitors:&amp;quot;&lt;br /&gt;
                $SU xrandr | grep &amp;quot;\Wconnected&amp;quot; | sed &amp;quot;s/^/ /&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: $0 &amp;lt;command&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  commands:&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          status&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          external&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          mirror&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As root, run the following commands,&lt;br /&gt;
&lt;br /&gt;
 {{cmdroot|chmod 755 /usr/local/sbin/thinkpad-fn-f7}}&lt;br /&gt;
 {{cmdroot|service acpid restart}}&lt;br /&gt;
&lt;br /&gt;
You should be ready to go, just press Fn-F7 to try.&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Talk:Sample_Fn-F7_script&amp;diff=34534</id>
		<title>Talk:Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Talk:Sample_Fn-F7_script&amp;diff=34534"/>
		<updated>2007-11-14T01:03:55Z</updated>

		<summary type="html">&lt;p&gt;Seva: fixed&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Note: you will need to change the internal and external resolution until someone fixes this script to figure it out from xrandr, you may also need to change output names from &amp;quot;VGA&amp;quot; and &amp;quot;LVDS&amp;quot; to what your xrandr tells you.&lt;br /&gt;
&lt;br /&gt;
why not just use --auto ?&lt;br /&gt;
&lt;br /&gt;
xrandr --output VGA --auto&lt;br /&gt;
&lt;br /&gt;
xrandr --output VGA --off&lt;br /&gt;
&lt;br /&gt;
xrandr --output LVDS --auto&lt;br /&gt;
 &lt;br /&gt;
xrandr --output LVDS --off&lt;br /&gt;
 &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Good point, made the changes --seva&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
# This is to figure out which user and X11 display to work on&lt;br /&gt;
 # TODO there has to be a better way to do this?&lt;br /&gt;
SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}'&lt;br /&gt;
&lt;br /&gt;
As the xrandr command can be run by the user is this necessary? if the script called by Fn7 can be run by an ordinary user then is it not equivalent to running the commands in an xterm?&lt;br /&gt;
 djc@Twingo:~$ xrandr --output LVDS --auto --output VGA --off&lt;br /&gt;
 djc@Twingo:~$ xrandr --output LVDS --off --output VGA --auto&lt;br /&gt;
 djc@Twingo:~$ xrandr --output LVDS --auto --output VGA --auto&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
concerning detecting what is currently active from xrandr. with VGA off xrandrq shows&lt;br /&gt;
&lt;br /&gt;
 Screen 0: minimum 320 x 200, current 1024 x 768, maximum 2048 x 2048&lt;br /&gt;
 VGA connected (normal left inverted right)&lt;br /&gt;
   1600x1200      60.0 +   59.9  &lt;br /&gt;
   1280x1024      75.0     59.9  &lt;br /&gt;
   1152x864       74.8  &lt;br /&gt;
   1024x768       75.1     60.0  &lt;br /&gt;
   800x600        75.0     60.3  &lt;br /&gt;
   640x480        75.0     60.0  &lt;br /&gt;
   720x400        70.1  &lt;br /&gt;
 LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&lt;br /&gt;
   1024x768       60.0*+   50.0  &lt;br /&gt;
   800x600        60.3  &lt;br /&gt;
   640x480        60.0     59.9 &lt;br /&gt;
&lt;br /&gt;
with VGA on &lt;br /&gt;
 VGA connected 1600x1200+0+0 (normal left inverted right) 367mm x 275mm&lt;br /&gt;
   1600x1200      60.0*+   59.9  &lt;br /&gt;
   1280x1024      75.0     59.9  &lt;br /&gt;
   1152x864       74.8  &lt;br /&gt;
   1024x768       75.1     60.0  &lt;br /&gt;
   800x600        75.0     60.3  &lt;br /&gt;
   640x480        75.0     60.0  &lt;br /&gt;
   720x400        70.1  &lt;br /&gt;
 LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&lt;br /&gt;
   1024x768       60.0*+   50.0  &lt;br /&gt;
   800x600        60.3  &lt;br /&gt;
   640x480        60.0     59.9  &lt;br /&gt;
&lt;br /&gt;
with LVDS off:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 djc@Twingo:~$ xrandr --output LVDS --off --output VGA --auto&lt;br /&gt;
 djc@Twingo:~$ xrandr -q&lt;br /&gt;
 Screen 0: minimum 320 x 200, current 1600 x 1200, maximum 2048 x 2048&lt;br /&gt;
 VGA connected 1600x1200+0+0 (normal left inverted right) 367mm x 275mm&lt;br /&gt;
   1600x1200      60.0*+   59.9  &lt;br /&gt;
   1280x1024      75.0     59.9  &lt;br /&gt;
   1152x864       74.8  &lt;br /&gt;
   1024x768       75.1     60.0  &lt;br /&gt;
   800x600        75.0     60.3  &lt;br /&gt;
   640x480        75.0     60.0  &lt;br /&gt;
   720x400        70.1  &lt;br /&gt;
 LVDS connected (normal left inverted right)&lt;br /&gt;
   1024x768       60.0 +   50.0  &lt;br /&gt;
   800x600        60.3  &lt;br /&gt;
   640x480        60.0     59.9  &lt;br /&gt;
&lt;br /&gt;
so detection should be possible on the differences between&lt;br /&gt;
 VGA connected 1600x1200+0+0 (normal left inverted right) 367mm x 275mm&lt;br /&gt;
 VGA connected (normal left inverted right)&lt;br /&gt;
 LVDS connected (normal left inverted right)&lt;br /&gt;
 LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&lt;br /&gt;
&lt;br /&gt;
eg between '''xxxx connected nnnnxnn+0+0 (''' and '''xxxx connected ('''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Regarding 1. acpid runs as root, so I switch to a user account before runinng xrandr, however I need to figure out which user to switch to -- hence the hack.&lt;br /&gt;
&lt;br /&gt;
Regarding 2. that doesn't tell us if screens are being mirrored or exended, just active, i think that in combination with some other tools (xwininfo -root perhaps?) could work.&lt;br /&gt;
&lt;br /&gt;
--seva&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
 djc@Twingo:~$ xrandr --output LVDS --auto --output VGA --auto --below LVDS&lt;br /&gt;
 djc@Twingo:~$ xrandr -q&lt;br /&gt;
 Screen 0: minimum 320 x 200, current 1600 x 1968, maximum 2048 x 2048&lt;br /&gt;
 VGA connected 1600x1200+0+768 (normal left inverted right) 367mm x 275mm&lt;br /&gt;
 ...&lt;br /&gt;
 LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&lt;br /&gt;
&lt;br /&gt;
so the position is in the +0+768&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Akw, I don't think the script needs to be colorized, it better to leave things the user needs to change in bold instead.&lt;br /&gt;
&lt;br /&gt;
Ordonnateur, I've made the changes so the script now figures out the state from xrandr and doesn't need to store it to a file.&lt;br /&gt;
&lt;br /&gt;
--seva&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This is great work, better than I could do. But here is another bug for you: grep connected is also picking up disconnected.&lt;br /&gt;
&lt;br /&gt;
  status)&lt;br /&gt;
               echo &amp;quot;Current Fn-F7 state is: $STATE&amp;quot;&lt;br /&gt;
               echo&lt;br /&gt;
               echo &amp;quot;Attached monitors:&amp;quot;&lt;br /&gt;
               xrandr | grep connected | sed &amp;quot;s/^/ /&amp;quot;&lt;br /&gt;
&lt;br /&gt;
gives&lt;br /&gt;
&lt;br /&gt;
 djc@Twingo:~$ Desktop/thinkpad-fn-f7.sh status&lt;br /&gt;
 Current Fn-F7 state is: internal&lt;br /&gt;
&lt;br /&gt;
 Attached monitors:&lt;br /&gt;
  VGA disconnected (normal left inverted right)&lt;br /&gt;
  LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
fixed --seva&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34533</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34533"/>
		<updated>2007-11-14T01:03:13Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide will help you configure Fn-F7 key combination to toggle between internal, mirror, external, or both screens.  This was tested on ThinkPad X60s running Fedora 8, please comment if it works or does not work for you.&lt;br /&gt;
&lt;br /&gt;
Add a &amp;quot;Virtual&amp;quot; statement to your /etc/X11/xorg.conf, the total resolution should be large enough to fit all your screens in the configuration you want, for example if you have 1600x1200 monitor to the left of your internal 1024x768 monitor, your total max resolution is 2624x1200 (See [[Xorg RandR 1.2]] for more details):&lt;br /&gt;
&lt;br /&gt;
 Section &amp;quot;Screen&amp;quot;&lt;br /&gt;
        Identifier &amp;quot;Screen0&amp;quot;&lt;br /&gt;
        Device     &amp;quot;Videocard0&amp;quot;&lt;br /&gt;
        DefaultDepth     24&lt;br /&gt;
        SubSection &amp;quot;Display&amp;quot;&lt;br /&gt;
                Viewport   0 0&lt;br /&gt;
                Depth     24&lt;br /&gt;
                &amp;lt;b&amp;gt;Virtual   2624 1200&amp;lt;/b&amp;gt;&lt;br /&gt;
        EndSubSection&lt;br /&gt;
 EndSection&lt;br /&gt;
&lt;br /&gt;
Restart X server at this point (i.e. logout and login).&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note the names of your output devices as you have change EXTERNAL_OUTPUT and INTERNAL_OUTPUT to what xrandr shows, for example VGA and LVDS in this case:&lt;br /&gt;
&lt;br /&gt;
 $ xrandr | grep connected&lt;br /&gt;
 '''VGA''' connected 1600x1200+0+0 (normal left inverted right x axis y axis) 432mm x 324mm&lt;br /&gt;
 '''LVDS''' connected (normal left inverted right x axis y axis)&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7, please set EXTERNAL_LOCATION to one of: left, right, above, or below.&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 &lt;br /&gt;
 # External output may be &amp;quot;VGA&amp;quot; or &amp;quot;VGA-0&amp;quot; or &amp;quot;DVI-0&amp;quot;&lt;br /&gt;
 EXTERNAL_OUTPUT=&amp;quot;'''VGA'''&amp;quot;&lt;br /&gt;
 INTERNAL_OUTPUT=&amp;quot;'''LVDS'''&amp;quot;&lt;br /&gt;
 EXTERNAL_LOCATION=&amp;quot;'''left'''&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # Figure out which user and X11 display to work on&lt;br /&gt;
 # TODO there has to be a better way to do this?&lt;br /&gt;
 X_USER=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}')&lt;br /&gt;
 export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
 &lt;br /&gt;
 # Switch to X user if necessary&lt;br /&gt;
 if [ &amp;quot;$X_USER&amp;quot; != &amp;quot;$USER&amp;quot; ]; then&lt;br /&gt;
        SU=&amp;quot;su $X_USER -c&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$EXTERNAL_LOCATION&amp;quot; in&lt;br /&gt;
        left|LEFT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        right|RIGHT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--right-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        top|TOP|above|ABOVE)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--above $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        bottom|BOTTOM|below|BELOW)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--below $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
 &lt;br /&gt;
 # Figure out current state&lt;br /&gt;
 INTERNAL_STATE=$($SU xrandr | grep ^$INTERNAL_OUTPUT | grep con | sed &amp;quot;s/.*connected //&amp;quot; | sed &amp;quot;s/(.*//&amp;quot;)&lt;br /&gt;
 EXTERNAL_STATE=$($SU xrandr | grep ^$EXTERNAL_OUTPUT | grep con | sed &amp;quot;s/.*connected //&amp;quot; | sed &amp;quot;s/(.*//&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
 if [ -z &amp;quot;$INTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
        STATE=&amp;quot;external&amp;quot;&lt;br /&gt;
 elif [ -z &amp;quot;$EXTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
        STATE=&amp;quot;internal&amp;quot;&lt;br /&gt;
 else&lt;br /&gt;
        INTERNAL_STATE=$(echo $INTERNAL_STATE | sed &amp;quot;s/[0-9]*x[0-9]*//&amp;quot;)&lt;br /&gt;
        EXTERNAL_STATE=$(echo $EXTERNAL_STATE | sed &amp;quot;s/[0-9]*x[0-9]*//&amp;quot;)&lt;br /&gt;
        if [ &amp;quot;$INTERNAL_STATE&amp;quot; = &amp;quot;$EXTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
                STATE=&amp;quot;mirror&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
                STATE=&amp;quot;both&amp;quot;&lt;br /&gt;
        fi&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_mirror(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_toggle(){&lt;br /&gt;
        case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                internal)&lt;br /&gt;
                        screen_mirror&lt;br /&gt;
                        ;;&lt;br /&gt;
                mirror)&lt;br /&gt;
                        screen_external&lt;br /&gt;
                        ;;&lt;br /&gt;
                external)&lt;br /&gt;
                        screen_both&lt;br /&gt;
                        ;;&lt;br /&gt;
                both)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
                *)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
        esac&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # What should we do?&lt;br /&gt;
 DO=&amp;quot;$1&amp;quot;&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        if [ $(basename $0) = &amp;quot;thinkpad-fn-f7&amp;quot; ]; then&lt;br /&gt;
                DO=&amp;quot;toggle&amp;quot;&lt;br /&gt;
        fi&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        toggle)&lt;br /&gt;
                screen_toggle&lt;br /&gt;
                ;;&lt;br /&gt;
        internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        mirror)&lt;br /&gt;
                screen_mirror&lt;br /&gt;
                ;;&lt;br /&gt;
        both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        status)&lt;br /&gt;
                echo &amp;quot;Current Fn-F7 state is: $STATE&amp;quot;&lt;br /&gt;
                echo&lt;br /&gt;
                echo &amp;quot;Attached monitors:&amp;quot;&lt;br /&gt;
                $SU xrandr | grep &amp;quot;\Wconnected&amp;quot; | sed &amp;quot;s/^/ /&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: $0 &amp;lt;command&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  commands:&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          status&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          external&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          mirror&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As root, run the following commands,&lt;br /&gt;
&lt;br /&gt;
 {{cmdroot|chmod 755 /usr/local/sbin/thinkpad-fn-f7}}&lt;br /&gt;
 {{cmdroot|service acpid restart}}&lt;br /&gt;
&lt;br /&gt;
You should be ready to go, just press Fn-F7 to try.&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34526</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34526"/>
		<updated>2007-11-13T18:26:23Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide will help you configure Fn-F7 key combination to toggle between internal, mirror, external, or both screens.  This was tested on ThinkPad X60s running Fedora 8, please comment if it works or does not work for you.&lt;br /&gt;
&lt;br /&gt;
Add a &amp;quot;Virtual&amp;quot; statement to your /etc/X11/xorg.conf, the total resolution should be large enough to fit all your screens in the configuration you want, for example if you have 1600x1200 monitor to the left of your internal 1024x768 monitor, your total max resolution is 2624x1200 (See [[Xorg RandR 1.2]] for more details):&lt;br /&gt;
&lt;br /&gt;
 Section &amp;quot;Screen&amp;quot;&lt;br /&gt;
        Identifier &amp;quot;Screen0&amp;quot;&lt;br /&gt;
        Device     &amp;quot;Videocard0&amp;quot;&lt;br /&gt;
        DefaultDepth     24&lt;br /&gt;
        SubSection &amp;quot;Display&amp;quot;&lt;br /&gt;
                Viewport   0 0&lt;br /&gt;
                Depth     24&lt;br /&gt;
                &amp;lt;b&amp;gt;Virtual   2624 1200&amp;lt;/b&amp;gt;&lt;br /&gt;
        EndSubSection&lt;br /&gt;
 EndSection&lt;br /&gt;
&lt;br /&gt;
Restart X server at this point (i.e. logout and login).&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note the names of your output devices as you have change EXTERNAL_OUTPUT and INTERNAL_OUTPUT to what xrandr shows, for example VGA and LVDS in this case:&lt;br /&gt;
&lt;br /&gt;
 $ xrandr | grep connected&lt;br /&gt;
 '''VGA''' connected 1600x1200+0+0 (normal left inverted right x axis y axis) 432mm x 324mm&lt;br /&gt;
 '''LVDS''' connected (normal left inverted right x axis y axis)&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7, please set EXTERNAL_LOCATION to one of: left, right, above, or below.&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 &lt;br /&gt;
 # External output may be &amp;quot;VGA&amp;quot; or &amp;quot;VGA-0&amp;quot; or &amp;quot;DVI-0&amp;quot;&lt;br /&gt;
 EXTERNAL_OUTPUT=&amp;quot;'''VGA'''&amp;quot;&lt;br /&gt;
 INTERNAL_OUTPUT=&amp;quot;'''LVDS'''&amp;quot;&lt;br /&gt;
 EXTERNAL_LOCATION=&amp;quot;'''left'''&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # Figure out which user and X11 display to work on&lt;br /&gt;
 # TODO there has to be a better way to do this?&lt;br /&gt;
 X_USER=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}')&lt;br /&gt;
 export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
 &lt;br /&gt;
 # Switch to X user if necessary&lt;br /&gt;
 if [ &amp;quot;$X_USER&amp;quot; != &amp;quot;$USER&amp;quot; ]; then&lt;br /&gt;
        SU=&amp;quot;su $X_USER -c&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$EXTERNAL_LOCATION&amp;quot; in&lt;br /&gt;
        left|LEFT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        right|RIGHT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--right-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        top|TOP|above|ABOVE)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--above $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        bottom|BOTTOM|below|BELOW)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--below $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
 &lt;br /&gt;
 # Figure out current state&lt;br /&gt;
 INTERNAL_STATE=$($SU xrandr | grep ^$INTERNAL_OUTPUT | grep con | sed &amp;quot;s/.*connected //&amp;quot; | sed &amp;quot;s/(.*//&amp;quot;)&lt;br /&gt;
 EXTERNAL_STATE=$($SU xrandr | grep ^$EXTERNAL_OUTPUT | grep con | sed &amp;quot;s/.*connected //&amp;quot; | sed &amp;quot;s/(.*//&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
 if [ -z &amp;quot;$INTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
        STATE=&amp;quot;external&amp;quot;&lt;br /&gt;
 elif [ -z &amp;quot;$EXTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
        STATE=&amp;quot;internal&amp;quot;&lt;br /&gt;
 else&lt;br /&gt;
        INTERNAL_STATE=$(echo $INTERNAL_STATE | sed &amp;quot;s/[0-9]*x[0-9]*//&amp;quot;)&lt;br /&gt;
        EXTERNAL_STATE=$(echo $EXTERNAL_STATE | sed &amp;quot;s/[0-9]*x[0-9]*//&amp;quot;)&lt;br /&gt;
        if [ &amp;quot;$INTERNAL_STATE&amp;quot; = &amp;quot;$EXTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
                STATE=&amp;quot;mirror&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
                STATE=&amp;quot;both&amp;quot;&lt;br /&gt;
        fi&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_mirror(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_toggle(){&lt;br /&gt;
        case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                internal)&lt;br /&gt;
                        screen_mirror&lt;br /&gt;
                        ;;&lt;br /&gt;
                mirror)&lt;br /&gt;
                        screen_external&lt;br /&gt;
                        ;;&lt;br /&gt;
                external)&lt;br /&gt;
                        screen_both&lt;br /&gt;
                        ;;&lt;br /&gt;
                both)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
                *)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
        esac&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # What should we do?&lt;br /&gt;
 DO=&amp;quot;$1&amp;quot;&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        if [ $(basename $0) = &amp;quot;thinkpad-fn-f7&amp;quot; ]; then&lt;br /&gt;
                DO=&amp;quot;toggle&amp;quot;&lt;br /&gt;
        fi&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        toggle)&lt;br /&gt;
                screen_toggle&lt;br /&gt;
                ;;&lt;br /&gt;
        internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        mirror)&lt;br /&gt;
                screen_mirror&lt;br /&gt;
                ;;&lt;br /&gt;
        both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        status)&lt;br /&gt;
                echo &amp;quot;Current Fn-F7 state is: $STATE&amp;quot;&lt;br /&gt;
                echo&lt;br /&gt;
                echo &amp;quot;Attached monitors:&amp;quot;&lt;br /&gt;
                xrandr | grep connected | sed &amp;quot;s/^/ /&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: $0 &amp;lt;command&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  commands:&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          status&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          external&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          mirror&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As root, run the following commands,&lt;br /&gt;
&lt;br /&gt;
 {{cmdroot|chmod 755 /usr/local/sbin/thinkpad-fn-f7}}&lt;br /&gt;
 {{cmdroot|service acpid restart}}&lt;br /&gt;
&lt;br /&gt;
You should be ready to go, just press Fn-F7 to try.&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Talk:Sample_Fn-F7_script&amp;diff=34525</id>
		<title>Talk:Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Talk:Sample_Fn-F7_script&amp;diff=34525"/>
		<updated>2007-11-13T18:24:27Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Note: you will need to change the internal and external resolution until someone fixes this script to figure it out from xrandr, you may also need to change output names from &amp;quot;VGA&amp;quot; and &amp;quot;LVDS&amp;quot; to what your xrandr tells you.&lt;br /&gt;
&lt;br /&gt;
why not just use --auto ?&lt;br /&gt;
&lt;br /&gt;
xrandr --output VGA --auto&lt;br /&gt;
&lt;br /&gt;
xrandr --output VGA --off&lt;br /&gt;
&lt;br /&gt;
xrandr --output LVDS --auto&lt;br /&gt;
 &lt;br /&gt;
xrandr --output LVDS --off&lt;br /&gt;
 &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Good point, made the changes --seva&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
# This is to figure out which user and X11 display to work on&lt;br /&gt;
 # TODO there has to be a better way to do this?&lt;br /&gt;
SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}'&lt;br /&gt;
&lt;br /&gt;
As the xrandr command can be run by the user is this necessary? if the script called by Fn7 can be run by an ordinary user then is it not equivalent to running the commands in an xterm?&lt;br /&gt;
 djc@Twingo:~$ xrandr --output LVDS --auto --output VGA --off&lt;br /&gt;
 djc@Twingo:~$ xrandr --output LVDS --off --output VGA --auto&lt;br /&gt;
 djc@Twingo:~$ xrandr --output LVDS --auto --output VGA --auto&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
concerning detecting what is currently active from xrandr. with VGA off xrandrq shows&lt;br /&gt;
&lt;br /&gt;
 Screen 0: minimum 320 x 200, current 1024 x 768, maximum 2048 x 2048&lt;br /&gt;
 VGA connected (normal left inverted right)&lt;br /&gt;
   1600x1200      60.0 +   59.9  &lt;br /&gt;
   1280x1024      75.0     59.9  &lt;br /&gt;
   1152x864       74.8  &lt;br /&gt;
   1024x768       75.1     60.0  &lt;br /&gt;
   800x600        75.0     60.3  &lt;br /&gt;
   640x480        75.0     60.0  &lt;br /&gt;
   720x400        70.1  &lt;br /&gt;
 LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&lt;br /&gt;
   1024x768       60.0*+   50.0  &lt;br /&gt;
   800x600        60.3  &lt;br /&gt;
   640x480        60.0     59.9 &lt;br /&gt;
&lt;br /&gt;
with VGA on &lt;br /&gt;
 VGA connected 1600x1200+0+0 (normal left inverted right) 367mm x 275mm&lt;br /&gt;
   1600x1200      60.0*+   59.9  &lt;br /&gt;
   1280x1024      75.0     59.9  &lt;br /&gt;
   1152x864       74.8  &lt;br /&gt;
   1024x768       75.1     60.0  &lt;br /&gt;
   800x600        75.0     60.3  &lt;br /&gt;
   640x480        75.0     60.0  &lt;br /&gt;
   720x400        70.1  &lt;br /&gt;
 LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&lt;br /&gt;
   1024x768       60.0*+   50.0  &lt;br /&gt;
   800x600        60.3  &lt;br /&gt;
   640x480        60.0     59.9  &lt;br /&gt;
&lt;br /&gt;
with LVDS off:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 djc@Twingo:~$ xrandr --output LVDS --off --output VGA --auto&lt;br /&gt;
 djc@Twingo:~$ xrandr -q&lt;br /&gt;
 Screen 0: minimum 320 x 200, current 1600 x 1200, maximum 2048 x 2048&lt;br /&gt;
 VGA connected 1600x1200+0+0 (normal left inverted right) 367mm x 275mm&lt;br /&gt;
   1600x1200      60.0*+   59.9  &lt;br /&gt;
   1280x1024      75.0     59.9  &lt;br /&gt;
   1152x864       74.8  &lt;br /&gt;
   1024x768       75.1     60.0  &lt;br /&gt;
   800x600        75.0     60.3  &lt;br /&gt;
   640x480        75.0     60.0  &lt;br /&gt;
   720x400        70.1  &lt;br /&gt;
 LVDS connected (normal left inverted right)&lt;br /&gt;
   1024x768       60.0 +   50.0  &lt;br /&gt;
   800x600        60.3  &lt;br /&gt;
   640x480        60.0     59.9  &lt;br /&gt;
&lt;br /&gt;
so detection should be possible on the differences between&lt;br /&gt;
 VGA connected 1600x1200+0+0 (normal left inverted right) 367mm x 275mm&lt;br /&gt;
 VGA connected (normal left inverted right)&lt;br /&gt;
 LVDS connected (normal left inverted right)&lt;br /&gt;
 LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&lt;br /&gt;
&lt;br /&gt;
eg between '''xxxx connected nnnnxnn+0+0 (''' and '''xxxx connected ('''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Regarding 1. acpid runs as root, so I switch to a user account before runinng xrandr, however I need to figure out which user to switch to -- hence the hack.&lt;br /&gt;
&lt;br /&gt;
Regarding 2. that doesn't tell us if screens are being mirrored or exended, just active, i think that in combination with some other tools (xwininfo -root perhaps?) could work.&lt;br /&gt;
&lt;br /&gt;
--seva&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
 djc@Twingo:~$ xrandr --output LVDS --auto --output VGA --auto --below LVDS&lt;br /&gt;
 djc@Twingo:~$ xrandr -q&lt;br /&gt;
 Screen 0: minimum 320 x 200, current 1600 x 1968, maximum 2048 x 2048&lt;br /&gt;
 VGA connected 1600x1200+0+768 (normal left inverted right) 367mm x 275mm&lt;br /&gt;
 ...&lt;br /&gt;
 LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&lt;br /&gt;
&lt;br /&gt;
so the position is in the +0+768&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Akw, I don't think the script needs to be colorized, it better to leave things the user needs to change in bold instead.&lt;br /&gt;
&lt;br /&gt;
Ordonnateur, I've made the changes so the script now figures out the state from xrandr and doesn't need to store it to a file.&lt;br /&gt;
&lt;br /&gt;
--seva&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34524</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34524"/>
		<updated>2007-11-13T18:22:06Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide will help you configure Fn-F7 key combination to toggle between internal, mirror, external, or both screens.  This was tested on ThinkPad X60s running Fedora 8, please comment if it works or does not work for you.&lt;br /&gt;
&lt;br /&gt;
Add a &amp;quot;Virtual&amp;quot; statement to your /etc/X11/xorg.conf, the total resolution should be large enough to fit all your screens in the configuration you want, for example if you have 1600x1200 monitor to the left of your internal 1024x768 monitor, your total max resolution is 2624x1200 (See [[Xorg RandR 1.2]] for more details):&lt;br /&gt;
&lt;br /&gt;
 Section &amp;quot;Screen&amp;quot;&lt;br /&gt;
        Identifier &amp;quot;Screen0&amp;quot;&lt;br /&gt;
        Device     &amp;quot;Videocard0&amp;quot;&lt;br /&gt;
        DefaultDepth     24&lt;br /&gt;
        SubSection &amp;quot;Display&amp;quot;&lt;br /&gt;
                Viewport   0 0&lt;br /&gt;
                Depth     24&lt;br /&gt;
                &amp;lt;b&amp;gt;Virtual   2624 1200&amp;lt;/b&amp;gt;&lt;br /&gt;
        EndSubSection&lt;br /&gt;
 EndSection&lt;br /&gt;
&lt;br /&gt;
Restart X server at this point (i.e. logout and login).&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note the names of your output devices as you have change EXTERNAL_OUTPUT and INTERNAL_OUTPUT to what xrandr shows, for example VGA and LVDS in this case:&lt;br /&gt;
&lt;br /&gt;
 $ xrandr | grep connected&lt;br /&gt;
 '''VGA''' connected 1600x1200+0+0 (normal left inverted right x axis y axis) 432mm x 324mm&lt;br /&gt;
 '''LVDS''' connected (normal left inverted right x axis y axis)&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7, please set EXTERNAL_LOCATION to one of: left, right, above, or below.&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 &lt;br /&gt;
 # External output may be &amp;quot;VGA&amp;quot; or &amp;quot;VGA-0&amp;quot; or &amp;quot;DVI-0&amp;quot;&lt;br /&gt;
 EXTERNAL_OUTPUT=&amp;quot;'''VGA'''&amp;quot;&lt;br /&gt;
 INTERNAL_OUTPUT=&amp;quot;'''LVDS'''&amp;quot;&lt;br /&gt;
 EXTERNAL_LOCATION=&amp;quot;'''left'''&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # Figure out which user and X11 display to work on&lt;br /&gt;
 # TODO there has to be a better way to do this?&lt;br /&gt;
 X_USER=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}')&lt;br /&gt;
 export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
 &lt;br /&gt;
 # Switch to X user if necessary&lt;br /&gt;
 if [ &amp;quot;$X_USER&amp;quot; != &amp;quot;$USER&amp;quot; ]; then&lt;br /&gt;
        SU=&amp;quot;su $X_USER -c&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$EXTERNAL_LOCATION&amp;quot; in&lt;br /&gt;
        left|LEFT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        right|RIGHT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--right-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        top|TOP|above|ABOVE)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--above $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        bottom|BOTTOM|below|BELOW)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--below $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
 &lt;br /&gt;
 # Figure out current state&lt;br /&gt;
 INTERNAL_STATE=$($SU xrandr | grep ^$INTERNAL_OUTPUT | grep con | sed &amp;quot;s/.* connected //&amp;quot; | sed &amp;quot;s/(.*//&amp;quot;)&lt;br /&gt;
 EXTERNAL_STATE=$($SU xrandr | grep ^$EXTERNAL_OUTPUT | grep con | sed &amp;quot;s/.* connected //&amp;quot; | sed &amp;quot;s/(.*//&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
 if [ -z &amp;quot;$INTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
        STATE=&amp;quot;external&amp;quot;&lt;br /&gt;
 elif [ -z &amp;quot;$EXTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
        STATE=&amp;quot;internal&amp;quot;&lt;br /&gt;
 else&lt;br /&gt;
        INTERNAL_STATE=$(echo $INTERNAL_STATE | sed &amp;quot;s/[0-9]*x[0-9]*//&amp;quot;)&lt;br /&gt;
        EXTERNAL_STATE=$(echo $EXTERNAL_STATE | sed &amp;quot;s/[0-9]*x[0-9]*//&amp;quot;)&lt;br /&gt;
        if [ &amp;quot;$INTERNAL_STATE&amp;quot; = &amp;quot;$EXTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
                STATE=&amp;quot;mirror&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
                STATE=&amp;quot;both&amp;quot;&lt;br /&gt;
        fi&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_mirror(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_toggle(){&lt;br /&gt;
        case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                internal)&lt;br /&gt;
                        screen_mirror&lt;br /&gt;
                        ;;&lt;br /&gt;
                mirror)&lt;br /&gt;
                        screen_external&lt;br /&gt;
                        ;;&lt;br /&gt;
                external)&lt;br /&gt;
                        screen_both&lt;br /&gt;
                        ;;&lt;br /&gt;
                both)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
                *)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
        esac&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # What should we do?&lt;br /&gt;
 DO=&amp;quot;$1&amp;quot;&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        if [ $(basename $0) = &amp;quot;thinkpad-fn-f7&amp;quot; ]; then&lt;br /&gt;
                DO=&amp;quot;toggle&amp;quot;&lt;br /&gt;
        fi&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        toggle)&lt;br /&gt;
                screen_toggle&lt;br /&gt;
                ;;&lt;br /&gt;
        internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        mirror)&lt;br /&gt;
                screen_mirror&lt;br /&gt;
                ;;&lt;br /&gt;
        both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        status)&lt;br /&gt;
                echo &amp;quot;Current Fn-F7 state is: $STATE&amp;quot;&lt;br /&gt;
                echo&lt;br /&gt;
                echo &amp;quot;Attached monitors:&amp;quot;&lt;br /&gt;
                xrandr | grep connected | sed &amp;quot;s/^/ /&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: $0 &amp;lt;command&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  commands:&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          status&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          external&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          mirror&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As root, run the following commands,&lt;br /&gt;
&lt;br /&gt;
 {{cmdroot|chmod 755 /usr/local/sbin/thinkpad-fn-f7}}&lt;br /&gt;
 {{cmdroot|service acpid restart}}&lt;br /&gt;
&lt;br /&gt;
You should be ready to go, just press Fn-F7 to try.&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34523</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34523"/>
		<updated>2007-11-13T18:20:44Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide will help you configure Fn-F7 key combination to toggle between internal, mirror, external, or both screens.  This was tested on ThinkPad X60s running Fedora 8, please comment if it works or does not work for you.&lt;br /&gt;
&lt;br /&gt;
Add a &amp;quot;Virtual&amp;quot; statement to your /etc/X11/xorg.conf, the total resolution should be large enough to fit all your screens in the configuration you want, for example if you have 1600x1200 monitor to the left of your internal 1024x768 monitor, your total max resolution is 2624x1200 (See [[Xorg RandR 1.2]] for more details):&lt;br /&gt;
&lt;br /&gt;
 Section &amp;quot;Screen&amp;quot;&lt;br /&gt;
        Identifier &amp;quot;Screen0&amp;quot;&lt;br /&gt;
        Device     &amp;quot;Videocard0&amp;quot;&lt;br /&gt;
        DefaultDepth     24&lt;br /&gt;
        SubSection &amp;quot;Display&amp;quot;&lt;br /&gt;
                Viewport   0 0&lt;br /&gt;
                Depth     24&lt;br /&gt;
                &amp;lt;b&amp;gt;Virtual   2624 1200&amp;lt;/b&amp;gt;&lt;br /&gt;
        EndSubSection&lt;br /&gt;
 EndSection&lt;br /&gt;
&lt;br /&gt;
Restart X server at this point (i.e. logout and login).&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7:&lt;br /&gt;
&lt;br /&gt;
Note: you will have change EXTERNAL_OUTPUT and INTERNAL_OUTPUT to what xrandr shows, for example VGA and LVDS in this case:&lt;br /&gt;
&lt;br /&gt;
 $ xrandr | grep connected&lt;br /&gt;
 '''VGA''' connected 1600x1200+0+0 (normal left inverted right x axis y axis) 432mm x 324mm&lt;br /&gt;
 '''LVDS''' connected (normal left inverted right x axis y axis)&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 &lt;br /&gt;
 # External output may be &amp;quot;VGA&amp;quot; or &amp;quot;VGA-0&amp;quot; or &amp;quot;DVI-0&amp;quot;&lt;br /&gt;
 EXTERNAL_OUTPUT=&amp;quot;'''VGA'''&amp;quot;&lt;br /&gt;
 INTERNAL_OUTPUT=&amp;quot;'''LVDS'''&amp;quot;&lt;br /&gt;
 EXTERNAL_LOCATION=&amp;quot;'''left'''&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # Figure out which user and X11 display to work on&lt;br /&gt;
 # TODO there has to be a better way to do this?&lt;br /&gt;
 X_USER=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}')&lt;br /&gt;
 export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
 &lt;br /&gt;
 # Switch to X user if necessary&lt;br /&gt;
 if [ &amp;quot;$X_USER&amp;quot; != &amp;quot;$USER&amp;quot; ]; then&lt;br /&gt;
        SU=&amp;quot;su $X_USER -c&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$EXTERNAL_LOCATION&amp;quot; in&lt;br /&gt;
        left|LEFT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        right|RIGHT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--right-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        top|TOP|above|ABOVE)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--above $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        bottom|BOTTOM|below|BELOW)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--below $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
 &lt;br /&gt;
 # Figure out current state&lt;br /&gt;
 INTERNAL_STATE=$($SU xrandr | grep ^$INTERNAL_OUTPUT | grep con | sed &amp;quot;s/.* connected //&amp;quot; | sed &amp;quot;s/(.*//&amp;quot;)&lt;br /&gt;
 EXTERNAL_STATE=$($SU xrandr | grep ^$EXTERNAL_OUTPUT | grep con | sed &amp;quot;s/.* connected //&amp;quot; | sed &amp;quot;s/(.*//&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
 if [ -z &amp;quot;$INTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
        STATE=&amp;quot;external&amp;quot;&lt;br /&gt;
 elif [ -z &amp;quot;$EXTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
        STATE=&amp;quot;internal&amp;quot;&lt;br /&gt;
 else&lt;br /&gt;
        INTERNAL_STATE=$(echo $INTERNAL_STATE | sed &amp;quot;s/[0-9]*x[0-9]*//&amp;quot;)&lt;br /&gt;
        EXTERNAL_STATE=$(echo $EXTERNAL_STATE | sed &amp;quot;s/[0-9]*x[0-9]*//&amp;quot;)&lt;br /&gt;
        if [ &amp;quot;$INTERNAL_STATE&amp;quot; = &amp;quot;$EXTERNAL_STATE&amp;quot; ]; then&lt;br /&gt;
                STATE=&amp;quot;mirror&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
                STATE=&amp;quot;both&amp;quot;&lt;br /&gt;
        fi&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_mirror(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_toggle(){&lt;br /&gt;
        case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                internal)&lt;br /&gt;
                        screen_mirror&lt;br /&gt;
                        ;;&lt;br /&gt;
                mirror)&lt;br /&gt;
                        screen_external&lt;br /&gt;
                        ;;&lt;br /&gt;
                external)&lt;br /&gt;
                        screen_both&lt;br /&gt;
                        ;;&lt;br /&gt;
                both)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
                *)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
        esac&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # What should we do?&lt;br /&gt;
 DO=&amp;quot;$1&amp;quot;&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        if [ $(basename $0) = &amp;quot;thinkpad-fn-f7&amp;quot; ]; then&lt;br /&gt;
                DO=&amp;quot;toggle&amp;quot;&lt;br /&gt;
        fi&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        toggle)&lt;br /&gt;
                screen_toggle&lt;br /&gt;
                ;;&lt;br /&gt;
        internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        mirror)&lt;br /&gt;
                screen_mirror&lt;br /&gt;
                ;;&lt;br /&gt;
        both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        status)&lt;br /&gt;
                echo &amp;quot;Current Fn-F7 state is: $STATE&amp;quot;&lt;br /&gt;
                echo&lt;br /&gt;
                echo &amp;quot;Attached monitors:&amp;quot;&lt;br /&gt;
                xrandr | grep connected | sed &amp;quot;s/^/ /&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: $0 &amp;lt;command&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  commands:&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          status&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          external&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          mirror&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As root, run the following commands,&lt;br /&gt;
&lt;br /&gt;
 {{cmdroot|chmod 755 /usr/local/sbin/thinkpad-fn-f7}}&lt;br /&gt;
 {{cmdroot|service acpid restart}}&lt;br /&gt;
&lt;br /&gt;
You should be ready to go, just press Fn-F7 to try.&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34478</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34478"/>
		<updated>2007-11-13T04:29:14Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide will help you configure Fn-F7 key combination to toggle between internal, mirror, external, or both screens.  This was tested on ThinkPad X60s running Fedora 8, please comment if it works or does not work for you.&lt;br /&gt;
&lt;br /&gt;
Add a &amp;quot;Virtual&amp;quot; statement to your /etc/X11/xorg.conf, the total resolution should be large enough to fit all your screens in the configuration you want, for example if you have 1600x1200 monitor to the left of your internal 1024x768 monitor, your total max resolution is 2624x1200 (See [[Xorg RandR 1.2]] for more details):&lt;br /&gt;
&lt;br /&gt;
 Section &amp;quot;Screen&amp;quot;&lt;br /&gt;
        Identifier &amp;quot;Screen0&amp;quot;&lt;br /&gt;
        Device     &amp;quot;Videocard0&amp;quot;&lt;br /&gt;
        DefaultDepth     24&lt;br /&gt;
        SubSection &amp;quot;Display&amp;quot;&lt;br /&gt;
                Viewport   0 0&lt;br /&gt;
                Depth     24&lt;br /&gt;
                &amp;lt;b&amp;gt;Virtual   2624 1200&amp;lt;/b&amp;gt;&lt;br /&gt;
        EndSubSection&lt;br /&gt;
 EndSection&lt;br /&gt;
&lt;br /&gt;
Restart X server at this point (i.e. logout and login).&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
 # fn-F7&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7:&lt;br /&gt;
&lt;br /&gt;
Note: you will have change EXTERNAL_OUTPUT and INTERNAL_OUTPUT to what xrandr shows, for example VGA and LVDS in this case:&lt;br /&gt;
&lt;br /&gt;
 $ xrandr | grep connected&lt;br /&gt;
 '''VGA''' connected 1600x1200+0+0 (normal left inverted right x axis y axis) 432mm x 324mm&lt;br /&gt;
 '''LVDS''' connected (normal left inverted right x axis y axis)&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #@ seva sevatech.com&lt;br /&gt;
 &lt;br /&gt;
 EXTERNAL_OUTPUT=&amp;quot;'''VGA'''&amp;quot;&lt;br /&gt;
 INTERNAL_OUTPUT=&amp;quot;'''LVDS'''&amp;quot;&lt;br /&gt;
 EXTERNAL_LOCATION=&amp;quot;'''left'''&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # This is to figure out which user and X11 display to work on&lt;br /&gt;
 # TODO there has to be a better way to do this?&lt;br /&gt;
 SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
 export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$EXTERNAL_LOCATION&amp;quot; in&lt;br /&gt;
        left|LEFT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        right|RIGHT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--right-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        top|TOP|above|ABOVE)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--above $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        bottom|BOTTOM|below|BELOW)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--below $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
 &lt;br /&gt;
 # Save the state to the file until we can figure it out by running xrandr&lt;br /&gt;
 # TODO figure out the state from xrandr and xwininfo -root or something?&lt;br /&gt;
 STATE_FILE=/var/lib/thinkpad/screen.state;&lt;br /&gt;
 if [ ! -e $STATE_FILE ]; then&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 STATE=$(cat $STATE_FILE)&lt;br /&gt;
 &lt;br /&gt;
 function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;external&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_mirror(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
        echo &amp;quot;mirror&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION&amp;quot;&lt;br /&gt;
        echo &amp;quot;both&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_toggle(){&lt;br /&gt;
        case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                internal)&lt;br /&gt;
                        screen_mirror&lt;br /&gt;
                        ;;&lt;br /&gt;
                mirror)&lt;br /&gt;
                        screen_external&lt;br /&gt;
                        ;;&lt;br /&gt;
                external)&lt;br /&gt;
                        screen_both&lt;br /&gt;
                        ;;&lt;br /&gt;
                both)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
                *)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
        esac&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # What should we do?&lt;br /&gt;
 DO=&amp;quot;$1&amp;quot;&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=$(basename $0)&lt;br /&gt;
 fi&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=&amp;quot;internal&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        toggle|thinkpad-fn-f7)&lt;br /&gt;
                screen_toggle&lt;br /&gt;
                ;;&lt;br /&gt;
        internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        mirror)&lt;br /&gt;
                screen_mirror&lt;br /&gt;
                ;;&lt;br /&gt;
        both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        status)&lt;br /&gt;
                echo &amp;quot;Current Fn-F7 state is: $STATE&amp;quot;&lt;br /&gt;
                echo&lt;br /&gt;
                echo &amp;quot;Attached monitors:&amp;quot;&lt;br /&gt;
                xrandr | grep connected | sed &amp;quot;s/^/ /&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: $0 &amp;lt;command&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  commands:&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          status&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          external&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          mirror&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  If no command is given default is internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
&lt;br /&gt;
As root, run the following commands,&lt;br /&gt;
&lt;br /&gt;
 {{cmdroot|mkdir -p /var/lib/thinkpad}}&lt;br /&gt;
 {{cmdroot|echo &amp;quot;internal&amp;quot; &amp;gt; /var/lib/thinkpad/screen.state}}&lt;br /&gt;
 {{cmdroot|chmod 755 /usr/local/sbin/thinkpad-fn-f7}}&lt;br /&gt;
 {{cmdroot|service acpid restart}}&lt;br /&gt;
&lt;br /&gt;
You should be ready to go, just press Fn-F7 to try.&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Talk:Sample_Fn-F7_script&amp;diff=34477</id>
		<title>Talk:Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Talk:Sample_Fn-F7_script&amp;diff=34477"/>
		<updated>2007-11-13T04:23:03Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Note: you will need to change the internal and external resolution until someone fixes this script to figure it out from xrandr, you may also need to change output names from &amp;quot;VGA&amp;quot; and &amp;quot;LVDS&amp;quot; to what your xrandr tells you.&lt;br /&gt;
&lt;br /&gt;
why not just use --auto ?&lt;br /&gt;
&lt;br /&gt;
xrandr --output VGA --auto&lt;br /&gt;
&lt;br /&gt;
xrandr --output VGA --off&lt;br /&gt;
&lt;br /&gt;
xrandr --output LVDS --auto&lt;br /&gt;
 &lt;br /&gt;
xrandr --output LVDS --off&lt;br /&gt;
 &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Good point, made the changes --seva&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
# This is to figure out which user and X11 display to work on&lt;br /&gt;
# TODO there has to be a better way to do this?&lt;br /&gt;
SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}'&lt;br /&gt;
&lt;br /&gt;
As the xrandr command can be run by the user is this necessary? if the script called by Fn7 can be run by an ordinary user then is it not equivalent to running the commands in an xterm?&lt;br /&gt;
 djc@Twingo:~$ xrandr --output LVDS --auto --output VGA --off&lt;br /&gt;
 djc@Twingo:~$ xrandr --output LVDS --off --output VGA --auto&lt;br /&gt;
 djc@Twingo:~$ xrandr --output LVDS --auto --output VGA --auto&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
concerning detecting what is currently active from xrandr. with VGA off xrandrq shows&lt;br /&gt;
&lt;br /&gt;
 Screen 0: minimum 320 x 200, current 1024 x 768, maximum 2048 x 2048&lt;br /&gt;
 VGA connected (normal left inverted right)&lt;br /&gt;
   1600x1200      60.0 +   59.9  &lt;br /&gt;
   1280x1024      75.0     59.9  &lt;br /&gt;
   1152x864       74.8  &lt;br /&gt;
   1024x768       75.1     60.0  &lt;br /&gt;
   800x600        75.0     60.3  &lt;br /&gt;
   640x480        75.0     60.0  &lt;br /&gt;
   720x400        70.1  &lt;br /&gt;
 LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&lt;br /&gt;
   1024x768       60.0*+   50.0  &lt;br /&gt;
   800x600        60.3  &lt;br /&gt;
   640x480        60.0     59.9 &lt;br /&gt;
&lt;br /&gt;
with VGA on &lt;br /&gt;
 VGA connected 1600x1200+0+0 (normal left inverted right) 367mm x 275mm&lt;br /&gt;
   1600x1200      60.0*+   59.9  &lt;br /&gt;
   1280x1024      75.0     59.9  &lt;br /&gt;
   1152x864       74.8  &lt;br /&gt;
   1024x768       75.1     60.0  &lt;br /&gt;
   800x600        75.0     60.3  &lt;br /&gt;
   640x480        75.0     60.0  &lt;br /&gt;
   720x400        70.1  &lt;br /&gt;
 LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&lt;br /&gt;
   1024x768       60.0*+   50.0  &lt;br /&gt;
   800x600        60.3  &lt;br /&gt;
   640x480        60.0     59.9  &lt;br /&gt;
&lt;br /&gt;
with LVDS off:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 djc@Twingo:~$ xrandr --output LVDS --off --output VGA --auto&lt;br /&gt;
 djc@Twingo:~$ xrandr -q&lt;br /&gt;
 Screen 0: minimum 320 x 200, current 1600 x 1200, maximum 2048 x 2048&lt;br /&gt;
 VGA connected 1600x1200+0+0 (normal left inverted right) 367mm x 275mm&lt;br /&gt;
   1600x1200      60.0*+   59.9  &lt;br /&gt;
   1280x1024      75.0     59.9  &lt;br /&gt;
   1152x864       74.8  &lt;br /&gt;
   1024x768       75.1     60.0  &lt;br /&gt;
   800x600        75.0     60.3  &lt;br /&gt;
   640x480        75.0     60.0  &lt;br /&gt;
   720x400        70.1  &lt;br /&gt;
 LVDS connected (normal left inverted right)&lt;br /&gt;
   1024x768       60.0 +   50.0  &lt;br /&gt;
   800x600        60.3  &lt;br /&gt;
   640x480        60.0     59.9  &lt;br /&gt;
&lt;br /&gt;
so detection should be possible on the differences between&lt;br /&gt;
 VGA connected 1600x1200+0+0 (normal left inverted right) 367mm x 275mm&lt;br /&gt;
 VGA connected (normal left inverted right)&lt;br /&gt;
 LVDS connected (normal left inverted right)&lt;br /&gt;
 LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm&lt;br /&gt;
&lt;br /&gt;
eg between '''xxxx connected nnnnxnn+0+0 (''' and '''xxxx connected ('''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Regarding 1. acpid runs as root, so I switch to a user account before runinng xrandr, however I need to figure out which user to switch to -- hence the hack.&lt;br /&gt;
&lt;br /&gt;
Regarding 2. that doesn't tell us if screens are being mirrored or exended, just active, i think that in combination with some other tools (xwininfo -root perhaps?) could work.&lt;br /&gt;
&lt;br /&gt;
--seva&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34468</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34468"/>
		<updated>2007-11-12T21:56:09Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide will help you configure Fn-F7 key combination to toggle between internal, mirror, external, or both screens.  This was tested on ThinkPad X60s running Fedora 8, please comment if it works or does not work for you.&lt;br /&gt;
&lt;br /&gt;
Add a &amp;quot;Virtual&amp;quot; statement to your /etc/X11/xorg.conf, the total resolution should be large enough to fit all your screens in the configuration you want, for example I have 1600x1200 monitor to the left of my internal 1024x768 monitor for a total max resolution of 2624x1200 (See [[Xorg RandR 1.2]] for more details):&lt;br /&gt;
&lt;br /&gt;
 Section &amp;quot;Screen&amp;quot;&lt;br /&gt;
        Identifier &amp;quot;Screen0&amp;quot;&lt;br /&gt;
        Device     &amp;quot;Videocard0&amp;quot;&lt;br /&gt;
        DefaultDepth     24&lt;br /&gt;
        SubSection &amp;quot;Display&amp;quot;&lt;br /&gt;
                Viewport   0 0&lt;br /&gt;
                Depth     24&lt;br /&gt;
                &amp;lt;b&amp;gt;Virtual   2624 1200&amp;lt;/b&amp;gt;&lt;br /&gt;
        EndSubSection&lt;br /&gt;
 EndSection&lt;br /&gt;
&lt;br /&gt;
Restart X server at this point (i.e. logout and login).&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
 # fn-F7&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7:&lt;br /&gt;
&lt;br /&gt;
Note: you will have change EXTERNAL_OUTPUT and INTERNAL_OUTPUT to what xrandr shows, for example VGA and LVDS in this case:&lt;br /&gt;
&lt;br /&gt;
 $ xrandr | grep connected&lt;br /&gt;
 '''VGA''' connected 1600x1200+0+0 (normal left inverted right x axis y axis) 432mm x 324mm&lt;br /&gt;
 '''LVDS''' connected (normal left inverted right x axis y axis)&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 #@ seva sevatech.com&lt;br /&gt;
 &lt;br /&gt;
 EXTERNAL_OUTPUT=&amp;quot;'''VGA'''&amp;quot;&lt;br /&gt;
 INTERNAL_OUTPUT=&amp;quot;'''LVDS'''&amp;quot;&lt;br /&gt;
 EXTERNAL_LOCATION=&amp;quot;'''left'''&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # This is to figure out which user and X11 display to work on&lt;br /&gt;
 # TODO there has to be a better way to do this?&lt;br /&gt;
 SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
 export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$EXTERNAL_LOCATION&amp;quot; in&lt;br /&gt;
        left|LEFT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        right|RIGHT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--right-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        top|TOP|above|ABOVE)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--above $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        bottom|BOTTOM|below|BELOW)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--below $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
 &lt;br /&gt;
 # Save the state to the file until we can figure it out by running xrandr&lt;br /&gt;
 STATE_FILE=/var/lib/thinkpad/screen.state;&lt;br /&gt;
 if [ ! -e $STATE_FILE ]; then&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 STATE=$(cat $STATE_FILE)&lt;br /&gt;
 &lt;br /&gt;
 function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;external&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_mirror(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
        echo &amp;quot;mirror&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION&amp;quot;&lt;br /&gt;
        echo &amp;quot;both&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_toggle(){&lt;br /&gt;
        case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                internal)&lt;br /&gt;
                        screen_mirror&lt;br /&gt;
                        ;;&lt;br /&gt;
                mirror)&lt;br /&gt;
                        screen_external&lt;br /&gt;
                        ;;&lt;br /&gt;
                external)&lt;br /&gt;
                        screen_both&lt;br /&gt;
                        ;;&lt;br /&gt;
                both)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
                *)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
        esac&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # What should we do?&lt;br /&gt;
 DO=&amp;quot;$1&amp;quot;&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=$(basename $0)&lt;br /&gt;
 fi&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=&amp;quot;internal&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        toggle|thinkpad-fn-f7)&lt;br /&gt;
                screen_toggle&lt;br /&gt;
                ;;&lt;br /&gt;
        internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        mirror)&lt;br /&gt;
                screen_mirror&lt;br /&gt;
                ;;&lt;br /&gt;
        both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        status)&lt;br /&gt;
                echo &amp;quot;Current Fn-F7 state is: $STATE&amp;quot;&lt;br /&gt;
                echo&lt;br /&gt;
                echo &amp;quot;Attached monitors:&amp;quot;&lt;br /&gt;
                xrandr | grep connected | sed &amp;quot;s/^/ /&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: $0 &amp;lt;command&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  commands:&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          status&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          external&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          mirror&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  If no command is given default is internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
&lt;br /&gt;
As root, run the following commands,&lt;br /&gt;
&lt;br /&gt;
 {{cmdroot|mkdir -p /var/lib/thinkpad}}&lt;br /&gt;
 {{cmdroot|echo &amp;quot;internal&amp;quot; &amp;gt; /var/lib/thinkpad/screen.state}}&lt;br /&gt;
 {{cmdroot|chmod 755 /usr/local/sbin/thinkpad-fn-f7}}&lt;br /&gt;
 {{cmdroot|service acpid restart}}&lt;br /&gt;
&lt;br /&gt;
You should be ready to go, just press Fn-F7 to try.&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34467</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34467"/>
		<updated>2007-11-12T21:46:51Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide will help you configure Fn-F7 key combination to toggle between internal, mirror, external, or both screens.  This was tested on ThinkPad X60s running Fedora 8, please comment if it works or does not work for you.&lt;br /&gt;
&lt;br /&gt;
Add a &amp;quot;Virtual&amp;quot; statement to your /etc/X11/xorg.conf, the total resolution should be large enough to fit all your screens in the configuration you want, for example I have 1600x1200 monitor to the left of my internal 1024x768 monitor for a total max resolution of 2624x1200 (See [[Xorg RandR 1.2]] for more details):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 Section &amp;quot;Screen&amp;quot;&lt;br /&gt;
        Identifier &amp;quot;Screen0&amp;quot;&lt;br /&gt;
        Device     &amp;quot;Videocard0&amp;quot;&lt;br /&gt;
        DefaultDepth     24&lt;br /&gt;
        SubSection &amp;quot;Display&amp;quot;&lt;br /&gt;
                Viewport   0 0&lt;br /&gt;
                Depth     24&lt;br /&gt;
                &amp;lt;b&amp;gt;Virtual   2624 1200&amp;lt;/b&amp;gt;&lt;br /&gt;
        EndSubSection&lt;br /&gt;
 EndSection&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Restart X server at this point (i.e. logout and login).&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 # fn-F7&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7:&lt;br /&gt;
&lt;br /&gt;
Note: you will have change EXTERNAL_OUTPUT and INTERNAL_OUTPUT to what xrandr shows, for example VGA and LVDS in this case:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 xrandr | grep connected&lt;br /&gt;
 &amp;lt;b&amp;gt;VGA&amp;lt;/b&amp;gt; connected 1600x1200+0+0 (normal left inverted right x axis y axis) 432mm x 324mm&lt;br /&gt;
 &amp;lt;b&amp;gt;LVDS&amp;lt;/b&amp;gt; connected (normal left inverted right x axis y axis)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 #@ seva sevatech.com&lt;br /&gt;
 &lt;br /&gt;
 EXTERNAL_OUTPUT=&amp;quot;VGA&amp;quot;&lt;br /&gt;
 INTERNAL_OUTPUT=&amp;quot;LVDS&amp;quot;&lt;br /&gt;
 EXTERNAL_LOCATION=&amp;quot;left&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # This is to figure out which user and X11 display to work on&lt;br /&gt;
 # TODO there has to be a better way to do this?&lt;br /&gt;
 SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
 export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$EXTERNAL_LOCATION&amp;quot; in&lt;br /&gt;
        left|LEFT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        right|RIGHT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--right-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        top|TOP|above|ABOVE)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--above $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        bottom|BOTTOM|below|BELOW)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--below $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
 &lt;br /&gt;
 # Save the state to the file until we can figure it out by running xrandr&lt;br /&gt;
 STATE_FILE=/var/lib/thinkpad/screen.state;&lt;br /&gt;
 if [ ! -e $STATE_FILE ]; then&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 STATE=$(cat $STATE_FILE)&lt;br /&gt;
 &lt;br /&gt;
 function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;external&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_mirror(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
        echo &amp;quot;mirror&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION&amp;quot;&lt;br /&gt;
        echo &amp;quot;both&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_toggle(){&lt;br /&gt;
        case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                internal)&lt;br /&gt;
                        screen_mirror&lt;br /&gt;
                        ;;&lt;br /&gt;
                mirror)&lt;br /&gt;
                        screen_external&lt;br /&gt;
                        ;;&lt;br /&gt;
                external)&lt;br /&gt;
                        screen_both&lt;br /&gt;
                        ;;&lt;br /&gt;
                both)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
                *)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
        esac&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # What should we do?&lt;br /&gt;
 DO=&amp;quot;$1&amp;quot;&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=$(basename $0)&lt;br /&gt;
 fi&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=&amp;quot;internal&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        toggle|thinkpad-fn-f7)&lt;br /&gt;
                screen_toggle&lt;br /&gt;
                ;;&lt;br /&gt;
        internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        mirror)&lt;br /&gt;
                screen_mirror&lt;br /&gt;
                ;;&lt;br /&gt;
        both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        status)&lt;br /&gt;
                echo &amp;quot;Current Fn-F7 state is: $STATE&amp;quot;&lt;br /&gt;
                echo&lt;br /&gt;
                echo &amp;quot;Attached monitors:&amp;quot;&lt;br /&gt;
                xrandr | grep connected | sed &amp;quot;s/^/ /&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: $0 &amp;lt;command&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  commands:&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          status&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          external&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          mirror&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  If no command is given default is internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As root, run the following commands,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 mkdir -p /var/lib/thinkpad&lt;br /&gt;
 echo &amp;quot;internal&amp;quot; &amp;gt; /var/lib/thinkpad/screen.state&lt;br /&gt;
 chmod 755 /usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
 service acpid restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should be ready to go, just press Fn-F7 to try.&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34466</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34466"/>
		<updated>2007-11-12T21:38:53Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide will let you use Fn-F7 key combination to toggle between internal, mirror, external, or both screens.  This was tested on ThinkPad X60s running Fedora 8, please comment if it works or does not work for you.&lt;br /&gt;
&lt;br /&gt;
Add a &amp;quot;Virtual&amp;quot; statement to your /etc/X11/xorg.conf, the total resolution should be large enough to fit all your screens in the configuration you want, for example I have 1600x1200 monitor to the left of my internal 1024x768 monitor for a total max resolution of 2624x1200:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 Section &amp;quot;Screen&amp;quot;&lt;br /&gt;
        Identifier &amp;quot;Screen0&amp;quot;&lt;br /&gt;
        Device     &amp;quot;Videocard0&amp;quot;&lt;br /&gt;
        DefaultDepth     24&lt;br /&gt;
        SubSection &amp;quot;Display&amp;quot;&lt;br /&gt;
                Viewport   0 0&lt;br /&gt;
                Depth     24&lt;br /&gt;
                &amp;lt;b&amp;gt;Virtual   2624 1200&amp;lt;/b&amp;gt;&lt;br /&gt;
        EndSubSection&lt;br /&gt;
 EndSection&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that for some drivers, including intel 945, the maximum is 2048x2048, see [[Xorg RandR 1.2]] for more details.&lt;br /&gt;
&lt;br /&gt;
Restart X server at this point (i.e. logout and login).&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 # fn-F7&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7:&lt;br /&gt;
&lt;br /&gt;
Note: you will have change EXTERNAL_OUTPUT and INTERNAL_OUTPUT to what xrandr shows, for example VGA and LVDS in this case:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 xrandr | grep connected&lt;br /&gt;
 &amp;lt;b&amp;gt;VGA&amp;lt;/b&amp;gt; connected 1600x1200+0+0 (normal left inverted right x axis y axis) 432mm x 324mm&lt;br /&gt;
 &amp;lt;b&amp;gt;LVDS&amp;lt;/b&amp;gt; connected (normal left inverted right x axis y axis)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 #@ seva sevatech.com&lt;br /&gt;
 &lt;br /&gt;
 EXTERNAL_OUTPUT=&amp;quot;VGA&amp;quot;&lt;br /&gt;
 INTERNAL_OUTPUT=&amp;quot;LVDS&amp;quot;&lt;br /&gt;
 EXTERNAL_LOCATION=&amp;quot;left&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # This is to figure out which user and X11 display to work on&lt;br /&gt;
 # TODO there has to be a better way to do this?&lt;br /&gt;
 SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
 export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$EXTERNAL_LOCATION&amp;quot; in&lt;br /&gt;
        left|LEFT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        right|RIGHT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--right-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        top|TOP|above|ABOVE)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--above $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        bottom|BOTTOM|below|BELOW)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--below $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
 &lt;br /&gt;
 # Save the state to the file until we can figure it out by running xrandr&lt;br /&gt;
 STATE_FILE=/var/lib/thinkpad/screen.state;&lt;br /&gt;
 if [ ! -e $STATE_FILE ]; then&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 STATE=$(cat $STATE_FILE)&lt;br /&gt;
 &lt;br /&gt;
 function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;external&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_mirror(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
        echo &amp;quot;mirror&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION&amp;quot;&lt;br /&gt;
        echo &amp;quot;both&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_toggle(){&lt;br /&gt;
        case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                internal)&lt;br /&gt;
                        screen_mirror&lt;br /&gt;
                        ;;&lt;br /&gt;
                mirror)&lt;br /&gt;
                        screen_external&lt;br /&gt;
                        ;;&lt;br /&gt;
                external)&lt;br /&gt;
                        screen_both&lt;br /&gt;
                        ;;&lt;br /&gt;
                both)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
                *)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
        esac&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # What should we do?&lt;br /&gt;
 DO=&amp;quot;$1&amp;quot;&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=$(basename $0)&lt;br /&gt;
 fi&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=&amp;quot;internal&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        toggle|thinkpad-fn-f7)&lt;br /&gt;
                screen_toggle&lt;br /&gt;
                ;;&lt;br /&gt;
        internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        mirror)&lt;br /&gt;
                screen_mirror&lt;br /&gt;
                ;;&lt;br /&gt;
        both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        status)&lt;br /&gt;
                echo &amp;quot;Current Fn-F7 state is: $STATE&amp;quot;&lt;br /&gt;
                echo&lt;br /&gt;
                echo &amp;quot;Attached monitors:&amp;quot;&lt;br /&gt;
                xrandr | grep connected | sed &amp;quot;s/^/ /&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: $0 &amp;lt;command&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  commands:&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          status&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          external&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          mirror&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  If no command is given default is internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As root, run the following commands,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 mkdir -p /var/lib/thinkpad&lt;br /&gt;
 echo &amp;quot;internal&amp;quot; &amp;gt; /var/lib/thinkpad/screen.state&lt;br /&gt;
 chmod 755 /usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
 service acpid restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should be ready to go, just press Fn-F7 to try.&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34465</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34465"/>
		<updated>2007-11-12T21:32:18Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide will let you use Fn-F7 key combination to toggle between internal, mirror, external, or both screens.  This was tested on ThinkPad X60s running Fedora 8, please comment if it works or does not work for you.&lt;br /&gt;
&lt;br /&gt;
Add a &amp;quot;Virtual&amp;quot; statement to your /etc/X11/xorg.conf, the total resolution should be large enough to fit all your screens in the configuration you want, for example I have 1600x1200 monitor to the left of my internal 1024x768 monitor for a total max resolution of 2624x1200:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 Section &amp;quot;Screen&amp;quot;&lt;br /&gt;
        Identifier &amp;quot;Screen0&amp;quot;&lt;br /&gt;
        Device     &amp;quot;Videocard0&amp;quot;&lt;br /&gt;
        DefaultDepth     24&lt;br /&gt;
        SubSection &amp;quot;Display&amp;quot;&lt;br /&gt;
                Viewport   0 0&lt;br /&gt;
                Depth     24&lt;br /&gt;
                &amp;lt;b&amp;gt;Virtual   2624 1200&amp;lt;/b&amp;gt;&lt;br /&gt;
        EndSubSection&lt;br /&gt;
 EndSection&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart X server at this point (i.e. logout and login).&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 # fn-F7&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7:&lt;br /&gt;
&lt;br /&gt;
Note: you will have change EXTERNAL_OUTPUT and INTERNAL_OUTPUT to what xrandr shows, for example VGA and LVDS in this case:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 xrandr | grep connected&lt;br /&gt;
 &amp;lt;b&amp;gt;VGA&amp;lt;/b&amp;gt; connected 1600x1200+0+0 (normal left inverted right x axis y axis) 432mm x 324mm&lt;br /&gt;
 &amp;lt;b&amp;gt;LVDS&amp;lt;/b&amp;gt; connected (normal left inverted right x axis y axis)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 #@ seva sevatech.com&lt;br /&gt;
 &lt;br /&gt;
 EXTERNAL_OUTPUT=&amp;quot;VGA&amp;quot;&lt;br /&gt;
 INTERNAL_OUTPUT=&amp;quot;LVDS&amp;quot;&lt;br /&gt;
 EXTERNAL_LOCATION=&amp;quot;left&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # This is to figure out which user and X11 display to work on&lt;br /&gt;
 # TODO there has to be a better way to do this?&lt;br /&gt;
 SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
 export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$EXTERNAL_LOCATION&amp;quot; in&lt;br /&gt;
        left|LEFT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        right|RIGHT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--right-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        top|TOP|above|ABOVE)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--above $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        bottom|BOTTOM|below|BELOW)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--below $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
 &lt;br /&gt;
 # Save the state to the file until we can figure it out by running xrandr&lt;br /&gt;
 STATE_FILE=/var/lib/thinkpad/screen.state;&lt;br /&gt;
 if [ ! -e $STATE_FILE ]; then&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 STATE=$(cat $STATE_FILE)&lt;br /&gt;
 &lt;br /&gt;
 function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;external&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_mirror(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
        echo &amp;quot;mirror&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION&amp;quot;&lt;br /&gt;
        echo &amp;quot;both&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_toggle(){&lt;br /&gt;
        case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                internal)&lt;br /&gt;
                        screen_mirror&lt;br /&gt;
                        ;;&lt;br /&gt;
                mirror)&lt;br /&gt;
                        screen_external&lt;br /&gt;
                        ;;&lt;br /&gt;
                external)&lt;br /&gt;
                        screen_both&lt;br /&gt;
                        ;;&lt;br /&gt;
                both)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
                *)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
        esac&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # What should we do?&lt;br /&gt;
 DO=&amp;quot;$1&amp;quot;&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=$(basename $0)&lt;br /&gt;
 fi&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=&amp;quot;internal&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        toggle|thinkpad-fn-f7)&lt;br /&gt;
                screen_toggle&lt;br /&gt;
                ;;&lt;br /&gt;
        internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        mirror)&lt;br /&gt;
                screen_mirror&lt;br /&gt;
                ;;&lt;br /&gt;
        both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        status)&lt;br /&gt;
                echo &amp;quot;Current Fn-F7 state is: $STATE&amp;quot;&lt;br /&gt;
                echo&lt;br /&gt;
                echo &amp;quot;Attached monitors:&amp;quot;&lt;br /&gt;
                xrandr | grep connected | sed &amp;quot;s/^/ /&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: $0 &amp;lt;command&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  commands:&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          status&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          external&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          mirror&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  If no command is given default is internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As root, run the following commands,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 mkdir -p /var/lib/thinkpad&lt;br /&gt;
 echo &amp;quot;internal&amp;quot; &amp;gt; /var/lib/thinkpad/screen.state&lt;br /&gt;
 chmod 755 /usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
 service acpid restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should be ready to go, just press Fn-F7 to try.&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34464</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34464"/>
		<updated>2007-11-12T21:31:45Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide will let you use Fn-F7 key combination to toggle between internal, mirror, external, or both screens.  This was tested on ThinkPad X60s running Fedora 8, please comment if it works or does not work for you.&lt;br /&gt;
&lt;br /&gt;
Add a &amp;quot;Virtual&amp;quot; statement to your /etc/X11/xorg.conf, the total resolution should be large enough to fit all your screens in the configuration you want, for example I have 1600x1200 monitor to the left of my internal 1024x768 monitor for a total max resolution of 2624x1200:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 Section &amp;quot;Screen&amp;quot;&lt;br /&gt;
        Identifier &amp;quot;Screen0&amp;quot;&lt;br /&gt;
        Device     &amp;quot;Videocard0&amp;quot;&lt;br /&gt;
        DefaultDepth     24&lt;br /&gt;
        SubSection &amp;quot;Display&amp;quot;&lt;br /&gt;
                Viewport   0 0&lt;br /&gt;
                Depth     24&lt;br /&gt;
                &amp;lt;b&amp;gt;Virtual   2624 1200&amp;lt;/b&amp;gt;&lt;br /&gt;
        EndSubSection&lt;br /&gt;
 EndSection&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart X server at this point (i.e. logout and login).&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 # fn-F7&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7:&lt;br /&gt;
&lt;br /&gt;
Note: you will have change EXTERNAL_OUTPUT and INTERNAL_OUTPUT to what xrandr shows, for example VGA and LVDS in this case:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 xrandr | grep connected&lt;br /&gt;
 &amp;lt;b&amp;gt;VGA&amp;lt;/b&amp;gt; connected 1600x1200+0+0 (normal left inverted right x axis y axis) 432mm x 324mm&lt;br /&gt;
 &amp;lt;b&amp;gt;LVDS&amp;lt;/b&amp;gt; connected (normal left inverted right x axis y axis)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 #@ seva sevatech.com&lt;br /&gt;
 &lt;br /&gt;
 EXTERNAL_OUTPUT=&amp;quot;VGA&amp;quot;&lt;br /&gt;
 INTERNAL_OUTPUT=&amp;quot;LVDS&amp;quot;&lt;br /&gt;
 EXTERNAL_LOCATION=&amp;quot;left&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # This is to figure out which user and X11 display to work on&lt;br /&gt;
 # TODO there has to be a better way to do this?&lt;br /&gt;
 SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
 export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$EXTERNAL_LOCATION&amp;quot; in&lt;br /&gt;
        left|LEFT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        right|RIGHT)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--right-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        top|TOP|above|ABOVE)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--above $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        bottom|BOTTOM|below|BELOW)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--below $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
 &lt;br /&gt;
 # Save the state to the file until we can figure it out by running xrandr&lt;br /&gt;
 STATE_FILE=/var/lib/thinkpad/screen.state;&lt;br /&gt;
 if [ ! -e $STATE_FILE ]; then&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 STATE=$(cat $STATE_FILE)&lt;br /&gt;
 &lt;br /&gt;
 function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;external&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_mirror(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
        echo &amp;quot;mirror&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION&amp;quot;&lt;br /&gt;
        echo &amp;quot;both&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_toggle(){&lt;br /&gt;
        case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                internal)&lt;br /&gt;
                        screen_mirror&lt;br /&gt;
                        ;;&lt;br /&gt;
                mirror)&lt;br /&gt;
                        screen_external&lt;br /&gt;
                        ;;&lt;br /&gt;
                external)&lt;br /&gt;
                        screen_both&lt;br /&gt;
                        ;;&lt;br /&gt;
                both)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
                *)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
        esac&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # What should we do?&lt;br /&gt;
 DO=&amp;quot;$1&amp;quot;&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=$(basename $0)&lt;br /&gt;
 fi&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=&amp;quot;internal&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        toggle|thinkpad-fn-f7)&lt;br /&gt;
                echo wtf&lt;br /&gt;
                screen_toggle&lt;br /&gt;
                ;;&lt;br /&gt;
        internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        mirror)&lt;br /&gt;
                screen_mirror&lt;br /&gt;
                ;;&lt;br /&gt;
        both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        status)&lt;br /&gt;
                echo &amp;quot;Current Fn-F7 state is: $STATE&amp;quot;&lt;br /&gt;
                echo&lt;br /&gt;
                echo &amp;quot;Attached monitors:&amp;quot;&lt;br /&gt;
                xrandr | grep connected | sed &amp;quot;s/^/ /&amp;quot;&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: $0 &amp;lt;command&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  commands:&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          status&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          external&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          mirror&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  If no command is given default is internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As root, run the following commands,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 mkdir -p /var/lib/thinkpad&lt;br /&gt;
 echo &amp;quot;internal&amp;quot; &amp;gt; /var/lib/thinkpad/screen.state&lt;br /&gt;
 chmod 755 /usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
 service acpid restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should be ready to go, just press Fn-F7 to try.&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=User:Seva&amp;diff=34463</id>
		<title>User:Seva</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=User:Seva&amp;diff=34463"/>
		<updated>2007-11-12T19:00:35Z</updated>

		<summary type="html">&lt;p&gt;Seva: Removing all content from page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=User:Seva&amp;diff=34462</id>
		<title>User:Seva</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=User:Seva&amp;diff=34462"/>
		<updated>2007-11-12T19:00:27Z</updated>

		<summary type="html">&lt;p&gt;Seva: â†Created page with '@ seva sevatech.com'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;@ seva sevatech.com&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Talk:Installing_Fedora_7_on_a_ThinkPad_T60p&amp;diff=34461</id>
		<title>Talk:Installing Fedora 7 on a ThinkPad T60p</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Talk:Installing_Fedora_7_on_a_ThinkPad_T60p&amp;diff=34461"/>
		<updated>2007-11-12T19:00:04Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Have you tried TPB for the Thinkvantage button?  I don't know if it works with the T60p, but I know it does with the T40.  --The preceding unsigned comment was added by SiriusStarr on 24 September 2007.&lt;br /&gt;
:What does the button do when pressed?  'xev' doesn't register an event, and I've wiped off the factory-supplied 'ThinkVantage' partition.  Thanks, [[User:GChriss|GChriss]]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Could you try [[Sample Fn-F7 Script]] --[[User:seva]]&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34458</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34458"/>
		<updated>2007-11-12T16:08:02Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide will let you use Fn-F7 key combination to toggle between internal, mirror, external, or both screens.  This was tested on ThinkPad X60s running Fedora 8, please comment if it works or does not work for you.&lt;br /&gt;
&lt;br /&gt;
Add a &amp;quot;Virtual&amp;quot; statement to your /etc/X11/xorg.conf, the total resolution should be large enough to fit all your screens in the configuration you want, for example I have 1600x1200 monitor to the left of my internal 1024x768 monitor for a total max resolution of 2624x1200:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 Section &amp;quot;Screen&amp;quot;&lt;br /&gt;
        Identifier &amp;quot;Screen0&amp;quot;&lt;br /&gt;
        Device     &amp;quot;Videocard0&amp;quot;&lt;br /&gt;
        DefaultDepth     24&lt;br /&gt;
        SubSection &amp;quot;Display&amp;quot;&lt;br /&gt;
                Viewport   0 0&lt;br /&gt;
                Depth     24&lt;br /&gt;
                &amp;lt;b&amp;gt;Virtual   2624 1200&amp;lt;/b&amp;gt;&lt;br /&gt;
        EndSubSection&lt;br /&gt;
 EndSection&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart X server at this point (i.e. logout and login).&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 # fn-F7&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7:&lt;br /&gt;
&lt;br /&gt;
Note: you will have change EXTERNAL_OUTPUT and INTERNAL_OUTPUT to what xrandr shows, for example VGA and LVDS in this case:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 xrandr | grep connected&lt;br /&gt;
 &amp;lt;b&amp;gt;VGA&amp;lt;/b&amp;gt; connected 1600x1200+0+0 (normal left inverted right x axis y axis) 432mm x 324mm&lt;br /&gt;
 &amp;lt;b&amp;gt;LVDS&amp;lt;/b&amp;gt; connected (normal left inverted right x axis y axis)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 #@ seva sevatech.com&lt;br /&gt;
 &lt;br /&gt;
 EXTERNAL_OUTPUT=&amp;lt;b&amp;gt;VGA&amp;lt;/b&amp;gt;&lt;br /&gt;
 INTERNAL_OUTPUT=&amp;lt;b&amp;gt;LVDS&amp;lt;/b&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
 EXTERNAL_LOCATION=&amp;quot;&amp;lt;b&amp;gt;--left-of&amp;lt;/b&amp;gt; $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # This is to figure out which X11 display to work on&lt;br /&gt;
 SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
 export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
 &lt;br /&gt;
 # Save the state to the file until we can figure it out by running xrandr&lt;br /&gt;
 STATE_FILE=/var/lib/thinkpad/screen.state;&lt;br /&gt;
 if [ ! -e $STATE_FILE ]; then&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 STATE=$(cat $STATE_FILE)&lt;br /&gt;
 &lt;br /&gt;
 function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;external&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_mirror(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
        echo &amp;quot;mirror&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION&amp;quot;&lt;br /&gt;
        echo &amp;quot;both&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_toggle(){&lt;br /&gt;
        case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                internal)&lt;br /&gt;
                        screen_mirror&lt;br /&gt;
                        ;;&lt;br /&gt;
                mirror)&lt;br /&gt;
                        screen_external&lt;br /&gt;
                        ;;&lt;br /&gt;
                external)&lt;br /&gt;
                        screen_both&lt;br /&gt;
                        ;;&lt;br /&gt;
                both)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
                *)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
        esac&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # What should we do?&lt;br /&gt;
 DO=&amp;quot;$1&amp;quot;&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=$(basename $0)&lt;br /&gt;
 fi&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=&amp;quot;internal&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        toggle|thinkpad-fn-f7)&lt;br /&gt;
                screen_toggle&lt;br /&gt;
                ;;&lt;br /&gt;
        internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        mirror)&lt;br /&gt;
                screen_mirror&lt;br /&gt;
                ;;&lt;br /&gt;
        both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        status)&lt;br /&gt;
                echo $STATE&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: $0 &amp;lt;command&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  commands:&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          status&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          external&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          mirror&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  If no command is given default is internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As root, run the following commands,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 mkdir -p /var/lib/thinkpad&lt;br /&gt;
 echo &amp;quot;internal&amp;quot; &amp;gt; /var/lib/thinkpad/screen.state&lt;br /&gt;
 chmod 755 /usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
 service acpid restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should be ready to go, just press Fn-F7 to try.&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Problem_with_video_output_switching&amp;diff=34457</id>
		<title>Problem with video output switching</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Problem_with_video_output_switching&amp;diff=34457"/>
		<updated>2007-11-12T16:06:29Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Affected Models==&lt;br /&gt;
*ThinkPad {{T40}}, {{T40p}}, {{T41}}, {{T41p}}, {{T42}}, {{T42p}}, {{T43}}, {{T43p}}, {{T60}}, {{T61}}&lt;br /&gt;
*ThinkPad {{X22}}, {{X23}}, {{X31}}, {{X41}}, {{X60}}, {{X60s}}&lt;br /&gt;
&lt;br /&gt;
==Problem Description==&lt;br /&gt;
External video output is not working, or it is not possible, using the  FN-F7 key, to switch between the LCD and the external monitor in the following way:&lt;br /&gt;
 LCD --&amp;gt; external Monitor--&amp;gt; both --&amp;gt;LCD&lt;br /&gt;
However ''cloning'' is possible for the Intel chipsets, see below.&lt;br /&gt;
&lt;br /&gt;
=== At least as of Fedora 8 with intel chipset the following works: [[Sample Fn-F7 script]] ===&lt;br /&gt;
&lt;br /&gt;
===Problems with Intel chipsets===&lt;br /&gt;
Disabling the internal LCD (e.g. when using an external Monitor) doesn't seem to work reliably.&lt;br /&gt;
&lt;br /&gt;
* For Xorg 7.022 one can clone the LCD display to an external monitor, adding the following lines to the Device section in the xorg.conf file:&lt;br /&gt;
 Section &amp;quot;Device&amp;quot;&lt;br /&gt;
  Identifier	&amp;quot;Generic Video Card&amp;quot;&lt;br /&gt;
  Driver		&amp;quot;i810&amp;quot;&lt;br /&gt;
  Option          &amp;quot;Clone&amp;quot; &amp;quot;true&amp;quot;&lt;br /&gt;
  Option          &amp;quot;MonitorLayout&amp;quot; &amp;quot;CRT,LFP&amp;quot;&lt;br /&gt;
however you can not switch between these screens as described above, once you use FN-F7 the cloned display is lost.&lt;br /&gt;
&lt;br /&gt;
* i810switch doesn't have any effect. After disabling the LCD it is still on (but the status display of i810switch claims that is is switched off). &lt;br /&gt;
&lt;br /&gt;
* The following works with Fedora Core 6 on an {{X60s}} and CentOS 5 on {{X60}}: i810switch 0.6.5 with the patch found on http://thpinfo.com/2006/patches/i810switch_macbook_support.patch  can switch between LCD and CRT (and initially CRT is off) (NOTE: The first hunk of this patch does not apply to the source, just remove it, it is unnecessary). This patch makes i810switch recognize the i915 chipset. It should thus be doable to use this with an ACPI event/action to do {{key|Fn}}{{key|F7}} switching. After installing i810switch and its i810rotate script and the missing [[ibm-acpi]] kernel module I did the following to achieve just that:&lt;br /&gt;
&lt;br /&gt;
In /etc/rc.local:&lt;br /&gt;
 modprobe ibm_acpi&lt;br /&gt;
 echo enable,0x084c &amp;gt; /proc/acpi/ibm/hotkey&lt;br /&gt;
&lt;br /&gt;
in /etc/acpi/events/videoswitch.conf:&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/etc/acpi/actions/video-rotate.sh&lt;br /&gt;
&lt;br /&gt;
Make sure the event code is correct. If acpid doesn't seem to recognise the event, try to recopy it from acpi log.&lt;br /&gt;
&lt;br /&gt;
in /etc/acpi/actions/video-rotate.sh&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 exec /usr/sbin/i810rotate&lt;br /&gt;
&lt;br /&gt;
* i855crt works see: http://stefan.desire.ch/howto/x41debian/#graphics for details.&lt;br /&gt;
&lt;br /&gt;
* With [[ibm-acpi]], {{cmdroot|echo lcd_disable &amp;gt;/proc/acpi/ibm/video}} works, but {{cmdroot|echo lcd_enable &amp;gt;/proc/acpi/ibm/video}} doesn't work - so one can't enable it anymore after disabling it. (the strange thing is that when switching to a console with {{key|ctrl}}{{key|alt}}{{key|F1}} the LCD display is used for it, so there must be some way to enable it but I can't find out how to control this in X). I've tried this with version 0.8 and version 0.11 of [[ibm-acpi]].&lt;br /&gt;
** {{key|Fn}}{{key|F7}} lets me enable the internal LCD after I disabled it with {{cmdroot|echo lcd_disable &amp;gt;/proc/acpi/ibm/video}} on my X41 but it corrupts the crt out&lt;br /&gt;
&lt;br /&gt;
===Problems with ATI chipsets===&lt;br /&gt;
*It is a [http://bugs.freedesktop.org/show_bug.cgi?id=2000 known issue] of xorgs radeon driver that {{key|Fn}}{{key|F7}} doesn't work.&lt;br /&gt;
&lt;br /&gt;
The {{cmdroot|radeontool light off}} and {{cmdroot|radeontool dac off}} commands will disable the LCD and CRT if they're been enabled before in the X server, but the corresponding {{cmdroot|radeontool light on}} and {{cmdroot|radeontool dac on}} will not work if the displays have were not enabled when the X server started. Also note that turing off the CRT using this command will not reduce power consumption, nor allow [[fglrx]] to enable power saving modes.&lt;br /&gt;
&lt;br /&gt;
You might try the following: Hit Ctrl+Alt+F1 to switch to a console, hit Fn+F7 to switch video, hit Alt+F7 to switch back to X.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Similar problems exist with XFree86 4.3 and its radeon driver&lt;br /&gt;
&lt;br /&gt;
You '''can''' switch the display off after switching to tty1 (STRG+ALT+F1) by &lt;br /&gt;
  * pressing FN+F7 or&lt;br /&gt;
  * executing ''echo crt_disable &amp;gt; /proc/acpi/ibm/video'' as root&lt;br /&gt;
&lt;br /&gt;
You '''cannot''' do this under X11. The display is always on under X11. I tried &lt;br /&gt;
  * ''echo auto_disable &amp;gt; /proc/acpi/ibm/video''&lt;br /&gt;
  * ''echo crt_disable &amp;gt; /proc/acpi/ibm/video''&lt;br /&gt;
  * ''echo lcd_disable &amp;gt; /proc/acpi/ibm/video''&lt;br /&gt;
  * pressing FN+F7&lt;br /&gt;
&lt;br /&gt;
but none of the above had any effect. If you switch the display off, then start X or switch to it, the display&lt;br /&gt;
will be activated automatically.&lt;br /&gt;
&lt;br /&gt;
====With the radeon driver====&lt;br /&gt;
You can force the &amp;lt;tt&amp;gt;radeon&amp;lt;/tt&amp;gt; driver to enable both CRT and LCD using &amp;lt;tt&amp;gt;Option &amp;quot;MonitorLayout&amp;quot; &amp;quot;LVDS,CRT&amp;quot;&amp;lt;/tt&amp;gt; in the &amp;lt;tt&amp;gt;&amp;quot;Device&amp;quot;&amp;lt;/tt&amp;gt; section of {{path|/etc/X11/xorg.conf}}. &lt;br /&gt;
&lt;br /&gt;
With new versions of the [[radeon]] drivers that include [[Xorg RandR 1.2]] support, you can fully control all outputs using the &amp;lt;tt&amp;gt;xrandr&amp;lt;/tt&amp;gt; utility.&lt;br /&gt;
&lt;br /&gt;
====With the fglrx driver====&lt;br /&gt;
Output switching with the Closed-Source ati-driver works: Just use {{cmdroot|aticonfig --query-monitor}} and e.g. {{cmdroot |aticonfig  --enable-monitor...&amp;quot;}}. You can use those two commands in a script, and bind them to {{key|Fn}}{{key|F7}}. Or use  &amp;lt;tt&amp;gt;Option &amp;quot;ForceMonitors&amp;quot; &amp;quot;lvds,crt1&amp;quot;&amp;lt;/tt&amp;gt; in {{path|/etc/X11/xorg.conf}}. &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Alternative solution: {{path|fglrx}} 8.28.8 will recognize {{key|Fn}}{{key|F7}} directly, if the key is enabled. This obviates the need for scripts which call aticonfig. To enable the hotkey, issue the command {{cmdroot|echo enable,0xffff &amp;gt;/proc/acpi/ibm/hotkey}}. You'll want to have this run both at boot time, and after resume (on my T43, the hotkey mask is reset on resume). For Ubuntu, I've put a script with the command in both the {{path|/etc/acpi/resume.d}}, and {{path|/etc/acpi/start.d}} directories.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Using kubuntu 7.04 with xorg-driver-fglrx 7.1.0-8.34.8+2.6.20.5-16.29, fglrx failed to recognise {{key|Fn}}{{key|F7}}.  However the following scripts can be used with acpi.  Tested on a T42p.&lt;br /&gt;
&lt;br /&gt;
* /etc/acpi/events/ibmvideobtn&lt;br /&gt;
  # /etc/acpi/events/ibmvideobtn&lt;br /&gt;
  # This is called when the user presses the video button.&lt;br /&gt;
  event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
  action=/etc/acpi/ibm-video.sh&lt;br /&gt;
&lt;br /&gt;
* /etc/acpi/ibm-video.sh&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
 &lt;br /&gt;
  # ACPI Scripts run as root, but the display will not allow access&lt;br /&gt;
  # from other users.&lt;br /&gt;
  # Lookup the X process for :0, find the -auth command line option,&lt;br /&gt;
  # extract the name of the authority file and use this file&lt;br /&gt;
  # to gain access to the DISPLAY&lt;br /&gt;
  export XAUTHORITY=`ps -ef | grep /usr/bin/X | grep :0 | grep -v grep | \&lt;br /&gt;
    awk -F' -' '{for (i=1; i&amp;lt;=NF; i++) if (substr($i, 0, 4)==&amp;quot;auth&amp;quot;) print $i}' \&lt;br /&gt;
    | awk '{print $2}'`&lt;br /&gt;
 &lt;br /&gt;
  export DISPLAY=:0&lt;br /&gt;
 &lt;br /&gt;
  # Query current monitor setup&lt;br /&gt;
  # Expect output from aticonfig such as:&lt;br /&gt;
  #   Connected monitors: crt1, lvds&lt;br /&gt;
  #   Enabled monitors: crt1&lt;br /&gt;
  #&lt;br /&gt;
  current=`aticonfig --query-monitor | tail -1 | awk -F: '{print $2}' | cut -c2-`&lt;br /&gt;
 &lt;br /&gt;
  # Cycle round to next monitor setup.&lt;br /&gt;
  # We loop through these settings&lt;br /&gt;
  # 1. CRT&lt;br /&gt;
  # 2. LCD&lt;br /&gt;
  # 3. CRT and LCD&lt;br /&gt;
  echo Current video: $current&lt;br /&gt;
  &lt;br /&gt;
  case $current in&lt;br /&gt;
    crt1)&lt;br /&gt;
      echo Switching to LCD&lt;br /&gt;
      aticonfig --enable-monitor=lvds&lt;br /&gt;
      ;;&lt;br /&gt;
    lvds)&lt;br /&gt;
      echo Switching to both LCD and CRT&lt;br /&gt;
      aticonfig --enable-monitor=crt1,lvds&lt;br /&gt;
      ;;&lt;br /&gt;
    &amp;quot;crt1, lvds&amp;quot;)&lt;br /&gt;
      echo Switching to CRT&lt;br /&gt;
      aticonfig --enable-monitor=crt1&lt;br /&gt;
      ;;&lt;br /&gt;
    *)&lt;br /&gt;
      # Unexpected current monitor, change to internal LCD&lt;br /&gt;
      echo Unknown current mode, switching to LCD&lt;br /&gt;
      aticonfig --enable-monitor=lvds&lt;br /&gt;
  esac&lt;br /&gt;
&lt;br /&gt;
====With the VESA driver====&lt;br /&gt;
&lt;br /&gt;
I have fixed the problem on my T42 by switching to the generic VESA driver in xorg.conf, and rebooting, as mentioned on the xorg bug page above. None of the other solutions worked.&lt;br /&gt;
&lt;br /&gt;
==Related Links==&lt;br /&gt;
*https://bugs.freedesktop.org/show_bug.cgi?id=2000&lt;br /&gt;
&lt;br /&gt;
==Solutions==&lt;br /&gt;
&lt;br /&gt;
====BIOSHotKeys====&lt;br /&gt;
&lt;br /&gt;
Try adding&lt;br /&gt;
 Option &amp;quot;BiosHotKeys&amp;quot; &amp;quot;on&amp;quot;&lt;br /&gt;
to &amp;quot;Device&amp;quot; selection in /etc/xorg.conf. For some reason, this is not the default, and will cause xorg to ignore the BIOS's request to switch modes!&lt;br /&gt;
This fixes the problem for an X22, with xorg 6.9.0.&lt;br /&gt;
&lt;br /&gt;
It fixed this problem for a X31 with xorg 7.1.1 too, but as the CRT is the primary display in some Thinkpads (like in the X31), you can not switch back to the LCD (or both) if xorg has started with the CRT only or both mode, because it sets the resolution and or refresrate to high for the LCD.&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Problem_with_video_output_switching&amp;diff=34456</id>
		<title>Problem with video output switching</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Problem_with_video_output_switching&amp;diff=34456"/>
		<updated>2007-11-12T16:05:47Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Affected Models==&lt;br /&gt;
*ThinkPad {{T40}}, {{T40p}}, {{T41}}, {{T41p}}, {{T42}}, {{T42p}}, {{T43}}, {{T43p}}, {{T60}}, {{T61}}&lt;br /&gt;
*ThinkPad {{X22}}, {{X23}}, {{X31}}, {{X41}}, {{X60}}, {{X60s}}&lt;br /&gt;
&lt;br /&gt;
==Problem Description==&lt;br /&gt;
External video output is not working, or it is not possible, using the  FN-F7 key, to switch between the LCD and the external monitor in the following way:&lt;br /&gt;
 LCD --&amp;gt; external Monitor--&amp;gt; both --&amp;gt;LCD&lt;br /&gt;
However ''cloning'' is possible for the Intel chipsets, see below.&lt;br /&gt;
&lt;br /&gt;
At least as of Fedora 8, with intel chipset the following works: [[Sample Fn-F7 script]]&lt;br /&gt;
&lt;br /&gt;
===Problems with Intel chipsets===&lt;br /&gt;
Disabling the internal LCD (e.g. when using an external Monitor) doesn't seem to work reliably.&lt;br /&gt;
&lt;br /&gt;
* For Xorg 7.022 one can clone the LCD display to an external monitor, adding the following lines to the Device section in the xorg.conf file:&lt;br /&gt;
 Section &amp;quot;Device&amp;quot;&lt;br /&gt;
  Identifier	&amp;quot;Generic Video Card&amp;quot;&lt;br /&gt;
  Driver		&amp;quot;i810&amp;quot;&lt;br /&gt;
  Option          &amp;quot;Clone&amp;quot; &amp;quot;true&amp;quot;&lt;br /&gt;
  Option          &amp;quot;MonitorLayout&amp;quot; &amp;quot;CRT,LFP&amp;quot;&lt;br /&gt;
however you can not switch between these screens as described above, once you use FN-F7 the cloned display is lost.&lt;br /&gt;
&lt;br /&gt;
* i810switch doesn't have any effect. After disabling the LCD it is still on (but the status display of i810switch claims that is is switched off). &lt;br /&gt;
&lt;br /&gt;
* The following works with Fedora Core 6 on an {{X60s}} and CentOS 5 on {{X60}}: i810switch 0.6.5 with the patch found on http://thpinfo.com/2006/patches/i810switch_macbook_support.patch  can switch between LCD and CRT (and initially CRT is off) (NOTE: The first hunk of this patch does not apply to the source, just remove it, it is unnecessary). This patch makes i810switch recognize the i915 chipset. It should thus be doable to use this with an ACPI event/action to do {{key|Fn}}{{key|F7}} switching. After installing i810switch and its i810rotate script and the missing [[ibm-acpi]] kernel module I did the following to achieve just that:&lt;br /&gt;
&lt;br /&gt;
In /etc/rc.local:&lt;br /&gt;
 modprobe ibm_acpi&lt;br /&gt;
 echo enable,0x084c &amp;gt; /proc/acpi/ibm/hotkey&lt;br /&gt;
&lt;br /&gt;
in /etc/acpi/events/videoswitch.conf:&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/etc/acpi/actions/video-rotate.sh&lt;br /&gt;
&lt;br /&gt;
Make sure the event code is correct. If acpid doesn't seem to recognise the event, try to recopy it from acpi log.&lt;br /&gt;
&lt;br /&gt;
in /etc/acpi/actions/video-rotate.sh&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 exec /usr/sbin/i810rotate&lt;br /&gt;
&lt;br /&gt;
* i855crt works see: http://stefan.desire.ch/howto/x41debian/#graphics for details.&lt;br /&gt;
&lt;br /&gt;
* With [[ibm-acpi]], {{cmdroot|echo lcd_disable &amp;gt;/proc/acpi/ibm/video}} works, but {{cmdroot|echo lcd_enable &amp;gt;/proc/acpi/ibm/video}} doesn't work - so one can't enable it anymore after disabling it. (the strange thing is that when switching to a console with {{key|ctrl}}{{key|alt}}{{key|F1}} the LCD display is used for it, so there must be some way to enable it but I can't find out how to control this in X). I've tried this with version 0.8 and version 0.11 of [[ibm-acpi]].&lt;br /&gt;
** {{key|Fn}}{{key|F7}} lets me enable the internal LCD after I disabled it with {{cmdroot|echo lcd_disable &amp;gt;/proc/acpi/ibm/video}} on my X41 but it corrupts the crt out&lt;br /&gt;
&lt;br /&gt;
===Problems with ATI chipsets===&lt;br /&gt;
*It is a [http://bugs.freedesktop.org/show_bug.cgi?id=2000 known issue] of xorgs radeon driver that {{key|Fn}}{{key|F7}} doesn't work.&lt;br /&gt;
&lt;br /&gt;
The {{cmdroot|radeontool light off}} and {{cmdroot|radeontool dac off}} commands will disable the LCD and CRT if they're been enabled before in the X server, but the corresponding {{cmdroot|radeontool light on}} and {{cmdroot|radeontool dac on}} will not work if the displays have were not enabled when the X server started. Also note that turing off the CRT using this command will not reduce power consumption, nor allow [[fglrx]] to enable power saving modes.&lt;br /&gt;
&lt;br /&gt;
You might try the following: Hit Ctrl+Alt+F1 to switch to a console, hit Fn+F7 to switch video, hit Alt+F7 to switch back to X.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Similar problems exist with XFree86 4.3 and its radeon driver&lt;br /&gt;
&lt;br /&gt;
You '''can''' switch the display off after switching to tty1 (STRG+ALT+F1) by &lt;br /&gt;
  * pressing FN+F7 or&lt;br /&gt;
  * executing ''echo crt_disable &amp;gt; /proc/acpi/ibm/video'' as root&lt;br /&gt;
&lt;br /&gt;
You '''cannot''' do this under X11. The display is always on under X11. I tried &lt;br /&gt;
  * ''echo auto_disable &amp;gt; /proc/acpi/ibm/video''&lt;br /&gt;
  * ''echo crt_disable &amp;gt; /proc/acpi/ibm/video''&lt;br /&gt;
  * ''echo lcd_disable &amp;gt; /proc/acpi/ibm/video''&lt;br /&gt;
  * pressing FN+F7&lt;br /&gt;
&lt;br /&gt;
but none of the above had any effect. If you switch the display off, then start X or switch to it, the display&lt;br /&gt;
will be activated automatically.&lt;br /&gt;
&lt;br /&gt;
====With the radeon driver====&lt;br /&gt;
You can force the &amp;lt;tt&amp;gt;radeon&amp;lt;/tt&amp;gt; driver to enable both CRT and LCD using &amp;lt;tt&amp;gt;Option &amp;quot;MonitorLayout&amp;quot; &amp;quot;LVDS,CRT&amp;quot;&amp;lt;/tt&amp;gt; in the &amp;lt;tt&amp;gt;&amp;quot;Device&amp;quot;&amp;lt;/tt&amp;gt; section of {{path|/etc/X11/xorg.conf}}. &lt;br /&gt;
&lt;br /&gt;
With new versions of the [[radeon]] drivers that include [[Xorg RandR 1.2]] support, you can fully control all outputs using the &amp;lt;tt&amp;gt;xrandr&amp;lt;/tt&amp;gt; utility.&lt;br /&gt;
&lt;br /&gt;
====With the fglrx driver====&lt;br /&gt;
Output switching with the Closed-Source ati-driver works: Just use {{cmdroot|aticonfig --query-monitor}} and e.g. {{cmdroot |aticonfig  --enable-monitor...&amp;quot;}}. You can use those two commands in a script, and bind them to {{key|Fn}}{{key|F7}}. Or use  &amp;lt;tt&amp;gt;Option &amp;quot;ForceMonitors&amp;quot; &amp;quot;lvds,crt1&amp;quot;&amp;lt;/tt&amp;gt; in {{path|/etc/X11/xorg.conf}}. &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Alternative solution: {{path|fglrx}} 8.28.8 will recognize {{key|Fn}}{{key|F7}} directly, if the key is enabled. This obviates the need for scripts which call aticonfig. To enable the hotkey, issue the command {{cmdroot|echo enable,0xffff &amp;gt;/proc/acpi/ibm/hotkey}}. You'll want to have this run both at boot time, and after resume (on my T43, the hotkey mask is reset on resume). For Ubuntu, I've put a script with the command in both the {{path|/etc/acpi/resume.d}}, and {{path|/etc/acpi/start.d}} directories.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Using kubuntu 7.04 with xorg-driver-fglrx 7.1.0-8.34.8+2.6.20.5-16.29, fglrx failed to recognise {{key|Fn}}{{key|F7}}.  However the following scripts can be used with acpi.  Tested on a T42p.&lt;br /&gt;
&lt;br /&gt;
* /etc/acpi/events/ibmvideobtn&lt;br /&gt;
  # /etc/acpi/events/ibmvideobtn&lt;br /&gt;
  # This is called when the user presses the video button.&lt;br /&gt;
  event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
  action=/etc/acpi/ibm-video.sh&lt;br /&gt;
&lt;br /&gt;
* /etc/acpi/ibm-video.sh&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
 &lt;br /&gt;
  # ACPI Scripts run as root, but the display will not allow access&lt;br /&gt;
  # from other users.&lt;br /&gt;
  # Lookup the X process for :0, find the -auth command line option,&lt;br /&gt;
  # extract the name of the authority file and use this file&lt;br /&gt;
  # to gain access to the DISPLAY&lt;br /&gt;
  export XAUTHORITY=`ps -ef | grep /usr/bin/X | grep :0 | grep -v grep | \&lt;br /&gt;
    awk -F' -' '{for (i=1; i&amp;lt;=NF; i++) if (substr($i, 0, 4)==&amp;quot;auth&amp;quot;) print $i}' \&lt;br /&gt;
    | awk '{print $2}'`&lt;br /&gt;
 &lt;br /&gt;
  export DISPLAY=:0&lt;br /&gt;
 &lt;br /&gt;
  # Query current monitor setup&lt;br /&gt;
  # Expect output from aticonfig such as:&lt;br /&gt;
  #   Connected monitors: crt1, lvds&lt;br /&gt;
  #   Enabled monitors: crt1&lt;br /&gt;
  #&lt;br /&gt;
  current=`aticonfig --query-monitor | tail -1 | awk -F: '{print $2}' | cut -c2-`&lt;br /&gt;
 &lt;br /&gt;
  # Cycle round to next monitor setup.&lt;br /&gt;
  # We loop through these settings&lt;br /&gt;
  # 1. CRT&lt;br /&gt;
  # 2. LCD&lt;br /&gt;
  # 3. CRT and LCD&lt;br /&gt;
  echo Current video: $current&lt;br /&gt;
  &lt;br /&gt;
  case $current in&lt;br /&gt;
    crt1)&lt;br /&gt;
      echo Switching to LCD&lt;br /&gt;
      aticonfig --enable-monitor=lvds&lt;br /&gt;
      ;;&lt;br /&gt;
    lvds)&lt;br /&gt;
      echo Switching to both LCD and CRT&lt;br /&gt;
      aticonfig --enable-monitor=crt1,lvds&lt;br /&gt;
      ;;&lt;br /&gt;
    &amp;quot;crt1, lvds&amp;quot;)&lt;br /&gt;
      echo Switching to CRT&lt;br /&gt;
      aticonfig --enable-monitor=crt1&lt;br /&gt;
      ;;&lt;br /&gt;
    *)&lt;br /&gt;
      # Unexpected current monitor, change to internal LCD&lt;br /&gt;
      echo Unknown current mode, switching to LCD&lt;br /&gt;
      aticonfig --enable-monitor=lvds&lt;br /&gt;
  esac&lt;br /&gt;
&lt;br /&gt;
====With the VESA driver====&lt;br /&gt;
&lt;br /&gt;
I have fixed the problem on my T42 by switching to the generic VESA driver in xorg.conf, and rebooting, as mentioned on the xorg bug page above. None of the other solutions worked.&lt;br /&gt;
&lt;br /&gt;
==Related Links==&lt;br /&gt;
*https://bugs.freedesktop.org/show_bug.cgi?id=2000&lt;br /&gt;
&lt;br /&gt;
==Solutions==&lt;br /&gt;
&lt;br /&gt;
====BIOSHotKeys====&lt;br /&gt;
&lt;br /&gt;
Try adding&lt;br /&gt;
 Option &amp;quot;BiosHotKeys&amp;quot; &amp;quot;on&amp;quot;&lt;br /&gt;
to &amp;quot;Device&amp;quot; selection in /etc/xorg.conf. For some reason, this is not the default, and will cause xorg to ignore the BIOS's request to switch modes!&lt;br /&gt;
This fixes the problem for an X22, with xorg 6.9.0.&lt;br /&gt;
&lt;br /&gt;
It fixed this problem for a X31 with xorg 7.1.1 too, but as the CRT is the primary display in some Thinkpads (like in the X31), you can not switch back to the LCD (or both) if xorg has started with the CRT only or both mode, because it sets the resolution and or refresrate to high for the LCD.&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=How_to_get_special_keys_to_work&amp;diff=34453</id>
		<title>How to get special keys to work</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=How_to_get_special_keys_to_work&amp;diff=34453"/>
		<updated>2007-11-12T15:55:41Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
The following table gives an overview over the special keys found on ThinkPads and what is needed to make them work.&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
! key !! standard function{{footnote|1}} !! tools supporting key{{footnote|2}} !! configurability{{footnote|3}} !! remarks&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}} || - || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || on release without completed key combination&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F1}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F2}} || lock screen || [[#ibm-acpi events|ibm-acpi]] || full || in models from T/X/Z 60 onwards&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F3}} || blank screen || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F4}} || suspend to ram || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]] || full || may generate ACPI event when not enabled in the ibm-acpi hotkey mask&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F5}} || switch bluetooth || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]] || full || in models starting from 2002&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F6}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F7}} || toggle display || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]], [[#tpb configuration|tpb]] || additional actions || [[Sample Fn-F7 script]]&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F8}} || toggle trackpoint/touchpad || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]], [[#tpb configuration|tpb]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F9}} || eject from dock || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F10}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F11}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F12}} || hibernate || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]] || full || may generate ACPI event when not enabled in the ibm-acpi hotkey mask&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Home}} / {{key|Fn}}{{key|Pos1}} || brightness up || [[#ibm-acpi events|ibm-acpi]], [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|End}} || brightness down || [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|PageUp}} || toggle thinklight || [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Space}} || toggle zoom || [[#tpb configuration|tpb]], [[KMilo]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Ins}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Del}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Backspace}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|NumLock}} || - || [[#xmodmap configuration|xmodmap]] || make working ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Windows}} || - || [[#xmodmap configuration|xmodmap]] || remapping ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Access IBM|#495988}} or {{ibmkey|ThinkPad|#494949}} or {{ibmkey|ThinkVantage|#495988}} || help application || [[#tpb configuration|tpb]], [[KMilo]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Home|#494949}} || open web browser || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]], [[KMilo]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Search|#494949}} || open search application || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]], [[KMilo]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Mail|#494949}} || open mail application || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]], [[KMilo]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Favorites|#494949}} || open favorites || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Reload|#494949}} || reload web page || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Abort|#494949}} || abort loading page || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Backward|#494949}} || previous page || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full ||  ext. keyboards and ThinkPads starting from 2002&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Forward|#494949}} || next page || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || ext. keyboards and ThinkPads starting from 2002&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume up|#494949}} || volume up || [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume down|#494949}} || volume down || [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume mute|#494949}} || mute volume || [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Play/Pause|#494949}} || start/pause playback  || [[#xmodmap configuration|xmodmap]] || full || {{X60s}} (Fn+Arrow Down)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Stop|#494949}} || stop playback || [[#xmodmap configuration|xmodmap]] || full || {{X60s}} (Fn+Arrow Up)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Next|#494949}} || play next || [[#xmodmap configuration|xmodmap]] || full || {{X60s}} (Fn+Arrow Right)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Previous|#494949}} || play previous || [[#xmodmap configuration|xmodmap]] || full || {{X60s}} (Fn+Arrow Left)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Power|#494949}} || shutdown || [[#ibm-acpi events|ibm-acpi]] || full || triggered on pressing 3secs, but notebook goes off on 5sec press&lt;br /&gt;
|-&lt;br /&gt;
| Display lid || blank screen || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| Ultrabay lid || announce ultrabay change || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| Dock eject || eject from dock || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet power|#494949}} || shutdown || [[#ibm-acpi events|ibm-acpi]] || full || triggered on pressing 3secs, but notebook goes off on 5sec press&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet orientation|#494949}} || rotates screen || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet shortcut|#494949}} || shortcut menu || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Esc|#494949}} || esc key || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Enter|#494949}} || enter key || [[#mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Up|#494949}} || up key || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Down|#494949}} || down key || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet (unlabeled)|#494949}} || down key || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Triggering key events==&lt;br /&gt;
===ibm-acpi events===&lt;br /&gt;
Some of the following events require a {{cmdroot|echo enable,0xffff &amp;gt;/proc/acpi/ibm/hotkey}} in order to make acpi able to get information on them. These events can be used to [[How to configure acpid|configure acpid]].&lt;br /&gt;
&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
|+ events triggered by [[ibm-acpi]] for {{path|/etc/acpi/events}} files. &lt;br /&gt;
! key !! event&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F1}} || ibm/hotkey HKEY 00000080 00001001&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F2}} || ibm/hotkey HKEY 00000080 00001002&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F3}} || ibm/hotkey HKEY 00000080 00001003&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F4}} || ibm/hotkey HKEY 00000080 00001004&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F5}} || ibm/hotkey HKEY 00000080 00001005&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F6}} || ibm/hotkey HKEY 00000080 00001006&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F7}} || ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F8}} || ibm/hotkey HKEY 00000080 00001008&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F9}} || ibm/hotkey HKEY 00000080 00001009&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F10}} || ibm/hotkey HKEY 00000080 0000100a&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F11}} || ibm/hotkey HKEY 00000080 0000100b&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F12}} || ibm/hotkey HKEY 00000080 0000100c&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Backspace}} || ibm/hotkey HKEY 00000080 0000100d&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Ins}} || ibm/hotkey HKEY 00000080 0000100e&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Del}} || ibm/hotkey HKEY 00000080 0000100f&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Home}}/{{key|Fn}}{{key|Pos1}} || ibm/hotkey HKEY 00000080 00001010&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|ThinkVantage|#495988}} ||ibm/hotkey HKEY 00000080 00001018&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Power|#494949}} || button/power PWRF 00000080 xxxxxxxx&lt;br /&gt;
|-&lt;br /&gt;
| Display lid || button/lid LID 00000080 xxxxxxxx&lt;br /&gt;
|-&lt;br /&gt;
| Ultrabay eject || ibm/bay MSTR 00000003 00000000&lt;br /&gt;
|-&lt;br /&gt;
| Ultrabay inserted || ibm/bay MSTR 00000001 00000000&lt;br /&gt;
|-&lt;br /&gt;
| Dock eject || ibm/dock GDCK 00000003 00000001&lt;br /&gt;
|-&lt;br /&gt;
| Wireless switch || ibm/hotkey HKEY 00000080 00007000&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
By disassembling and editing the DSDT, more events can be added.  HKEY events are triggered by calls to the MKHQ function, e.g. &amp;lt;tt&amp;gt;\_SB.PCI0.LPC.EC.HKEY.MHKQ(0Ã—1007)&amp;lt;/tt&amp;gt; will trigger &amp;quot;ibm/hotkey HKEY 00000080 00001007&amp;quot;.  Most of these can be found in &amp;lt;tt&amp;gt;_Qxx&amp;lt;/tt&amp;gt; methods within the DSDT, which are executed on embedded controller events, e.g. _Q10 is triggered by pressing Fn-F7.  You can add a call to MKHQ into an existing &amp;lt;tt&amp;gt;_Qxx&amp;lt;/tt&amp;gt; method to get it recognized by ibm-acpi as well as creating new &amp;lt;tt&amp;gt;_Qxx&amp;lt;/tt&amp;gt; methods, which if you're lucky will correspond to an EC event that IBM never used (e.g. A 770 will send Fn-Home/End/PgUp/PgDn to ibm-acpi if hacked in this fashion). For example, [http://www.wormnet.eu/ibm-g40/morebuttons.dsl this is a modified block of DSDT for a G40].&lt;br /&gt;
&lt;br /&gt;
=== Pure ACPI events ===&lt;br /&gt;
&lt;br /&gt;
A few keys can generate ACPI events of their own on certain ThinkPads, as long as they are masked off in the ibm-acpi hotkey's mask (or the hotkey feature is disabled in ibm-acpi).&lt;br /&gt;
&lt;br /&gt;
If you want the ThinkPad's BIOS and ACPI methods to know about these keys being pressed, you probably want to leave them masked out from ibm-acpi, and use their non-HKEY events listed below, instead.&lt;br /&gt;
&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
|+ events triggered by ACPI when hotkey is masked out or disabled. &lt;br /&gt;
! key !! event&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F4}} || button/sleep SLPB 00000080 00000001&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F12}} || ibm/hotkey HKEY 00000080 0000100c&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===tpb configuration===&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
|+ configuration keywords for [[tpb]] (to put in {{path|/etc/tpbrc}})&lt;br /&gt;
! key !! config keyword&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Access IBM|#495988}} or {{ibmkey|ThinkPad|#494949}} || THINKPAD&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Home|#494949}} || HOME&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Search|#494949}} || SEARCH&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Mail|#494949}} || MAIL&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Favorites|#494949}} || FAVORITES&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Reload|#494949}} || RELOAD&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Abort|#494949}} || ABORT&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Backward|#494949}} || BACKWARD&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Forward|#494949}} || FORWARD&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}} || FN&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Space}} || CALLBACK (zoom on/off)&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|PageUp}} || CALLBACK (thinklight on/off)&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F7}} || CALLBACK (display lcd/crt/both)&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F8}} || CALLBACK (expand on/off)&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Home}} / {{key|Fn}}{{key|Pos1}} || CALLBACK (brightness &amp;lt;percent&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|End}} || CALLBACK (brightness &amp;lt;percent&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume up|#494949}} || CALLBACK (volume &amp;lt;percent&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume down|#494949}} || CALLBACK (volume &amp;lt;percent&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume mute|#494949}} || CALLBACK (mute on/off)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To all parameter keywords should be assigned the full path to the executables supposed to be started on key press.&lt;br /&gt;
The exectable provided for the CALLBACK keyword should take the parameters given in parentheses and act according to them.&lt;br /&gt;
If you want to use xmodmap for the HOME, SEARCH, MAIL, FAVORITES, RELOAD, ABORT, BACKWARD, FORWARD and FN keys you should&lt;br /&gt;
provide a &amp;lt;tt&amp;gt;XEVENTS OFF&amp;lt;/tt&amp;gt; in your {{path|/etc/tpbrc}}. &lt;br /&gt;
You can use an appropriate executable to [[How to inject fake keystrokes|inject fake keystrokes]].&lt;br /&gt;
&lt;br /&gt;
For Debian users, tpb is started from {{path|/etc/X11/Xsession.d/90tpb}}.&lt;br /&gt;
&lt;br /&gt;
'''Sound Button configuration'''&lt;br /&gt;
&lt;br /&gt;
''Note: Tested on T60p with Ubuntu 6.06 LTS''&lt;br /&gt;
&lt;br /&gt;
Most Thinkpads have a hardware sound mixer, thus the volumes buttons should work without configuration. However, this change is not reflected in the software mixer. tpb has a switch to enable software mixer support via OSS. The manual recommends this only for devices without a hardware mixer, but it also works for other hadware mixer enabled devices, even with the ALSA system. Just put MIXER ON in your {{path|/etc/tpbrc}} file and you can see the effect immediately in any ALSA mixer (e.g. kmix). For this to work you need write permissions to {{path|/dev/nvram}}.&lt;br /&gt;
&lt;br /&gt;
''Note: Tested on X21 with Ubuntu 6.06 LTS''&lt;br /&gt;
&lt;br /&gt;
On the ThinkPad X21 (and maybe some other older models) ACPI causes problems with tpb.  On an X21 using acpi the volume buttons would work occasionally, and the OSD for tpb functions would rarely work.  If a volume buttons was pressed too often, sometimes the computer would enter a low power (unplugged state) and would require a reboot.  The solution is to use APM instead of ACPI.  Instructions can be found in [[How_to_make_APM_work]].&lt;br /&gt;
&lt;br /&gt;
===KMilo configuration===&lt;br /&gt;
The programs to be executed by [[KMilo]] are configured via the KDE Control Center (&amp;lt;tt&amp;gt;kcontrol&amp;lt;/tt&amp;gt;), under &amp;lt;tt&amp;gt;System Administration --&amp;gt; IBM Thinkpad Laptop&amp;lt;/tt&amp;gt;. Note that you can use appropriate commands to [[How to inject fake keystrokes|inject fake keystrokes]].&lt;br /&gt;
&lt;br /&gt;
===xmodmap configuration===&lt;br /&gt;
xmodmap enables you to edit the modifier map and keymap tables that are used to translate keycodes into keysyms.&lt;br /&gt;
Understood? Well, basically it allows you to give the X server a dictionary for the translation of keycodes like &amp;quot;97&amp;quot; into more human readable synonyms like &amp;quot;Home&amp;quot;. This way xmodmap allows you to make the special keys of your keyboard known to X applications.&lt;br /&gt;
&lt;br /&gt;
To discover the keycode that a certain keypress produces, use the tool {{cmduser|xev}} &lt;br /&gt;
&lt;br /&gt;
Usually you should write your keycode-keysym associations into the file {{path|~/.Xmodmap}}. This file is usually read by the X session startup scripts of your system, so that the mappings automatically get included everytime you run the X server.&lt;br /&gt;
&lt;br /&gt;
The {{path|~/.Xmodmap}} lines for our purpose are in the form of&lt;br /&gt;
 keycode &amp;lt;keycode&amp;gt; = &amp;lt;keysym&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load the assocation using the command&lt;br /&gt;
&lt;br /&gt;
{{cmduser|xmodmap ~/.Xmodmap}} &lt;br /&gt;
&lt;br /&gt;
(some configurations do this automatically upon X startup). &lt;br /&gt;
&lt;br /&gt;
The following table shows the keycodes generated by the ThinkPad special keys and sensible keysyms to assign them to.&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
|+ keycodes and recommended keysyms&lt;br /&gt;
! key !! keycode !! keysym&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Access IBM|#495988}} or {{ibmkey|ThinkPad|#494949}} || 159 || XF86LaunchA&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Backward|#494949}} || 234 || XF86Back or F19&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Forward|#494949}} || 233 || XF86Forward or F20&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Play/Pause|#494949}} || 162 || XF86AudioPlay&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Stop|#494949}} || 164 || XF86AudioStop&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Next|#494949}} || 153 || XF86AudioNext&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Previous|#494949}} || 144 || XF86AudioPrev&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| {{ibmkey|Home|#494949}} || 178 || XF86HomePage&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Search|#494949}} || 229 || XF86Search&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Mail|#494949}} || 236 || XF86Mail&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Favorites|#494949}} || 230 || XF86AddFavorite or XF86Favorites&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Reload|#494949}} || 231 || XF86Reload&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Abort|#494949}} || 232 || XF86Stop&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}} || 227 || F35&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: You can also use xkeycaps (an X tool to display and edit the X keyboard mapping) to generate proper .Xmodmap.&lt;br /&gt;
&lt;br /&gt;
Note: if you are running [[tpb]] you might need to add the line &amp;lt;tt&amp;gt;XEVENTS=off&amp;lt;/tt&amp;gt; into your tpbrc to stop it from grabbing the key events and allow them to get through to X instead. See [[http://www.thinkwiki.org/wiki/Tpb]] for more detailed instruction on how to use tpb and xmodmap.&lt;br /&gt;
&lt;br /&gt;
Note: XF86Forward and XF86Back do not work correctly in Firefox. You may want to map them to F19 and F20 instead if you use Firefox.&lt;br /&gt;
&lt;br /&gt;
Note: The &amp;quot;XF86AudioPlay&amp;quot; etc. just works with a few programs. To make it work with more multimedia programs you have map the key to use something like [http://www.kde-apps.org/content/show.php/ReMoot?content=63140 ReMoot]. ReMoot is a command line wrapper that control 18 of the most common multimedia applications. &lt;br /&gt;
&lt;br /&gt;
=====Enabling the Windows and Menu Keys=====&lt;br /&gt;
On some systems the Windows and Menu keys may not be recognized.  You can enable then by&lt;br /&gt;
making the following changes:&lt;br /&gt;
&lt;br /&gt;
        keycode 115 = F13&lt;br /&gt;
        keycode 227 = F35&lt;br /&gt;
&lt;br /&gt;
F13 and F35 are used for the Windows and and Menu keys respectively.  Labelling keycpode 227 as &amp;quot;Menu&amp;quot; may conflict with the right-mouse-click event.&lt;br /&gt;
&lt;br /&gt;
=====Using Caps Lock as Super L (Windows key)=====&lt;br /&gt;
You can easily use Caps Lock as Win key by adding the following in your ~/.Xmodmap:&lt;br /&gt;
        ! No Caps Lock&lt;br /&gt;
        clear lock&lt;br /&gt;
        ! Caps Lock as Win key&lt;br /&gt;
        add mod4 = Caps_Lock&lt;br /&gt;
=====NumLock=====&lt;br /&gt;
On the ThinkPad {{600}}, {{T20}}, {{T21}}, {{T22}}, {{T30}}, {{X20}}, {{X21}},  {{X31}}, {{X40}}, {{T42p}}, {{T43}}, {{R51}}, {{R52}} and possibly other models, X does not recognize the keycode for {{key|NumLk}} = {{key|Shift}}+{{key|ScrLk}}. To fix this, add the following to {{path|~/.Xmodmap}} in your home directory or {{path|/etc/X11/Xmodmap}} and run &amp;lt;tt&amp;gt;xmodmap&amp;lt;/tt&amp;gt;, ex: &amp;lt;tt&amp;gt;xmodmap ~/.Xmodmap&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 keycode 77 = Num_Lock&lt;br /&gt;
&lt;br /&gt;
This configuration also enables the respective LED.&lt;br /&gt;
&lt;br /&gt;
Please note, pressing the {{key|Shift}}+{{key|ScrLk}} key combination, without first following the above configuration, will start an accessibility feature, which will allow the numeric keypad to maneuver the mouse pointer.  Starting this accessibility feature and subsequently running xmodmap, as described above, results in the accessibility feature and the numeric lock LED functioning simultaneously.  As such, the above configuration should be completed before the accessibility feature is started in order to produce numbers.&lt;br /&gt;
&lt;br /&gt;
===Mapping keys with setkeycodes===&lt;br /&gt;
You can use the setkeycodes command to remap certain keys. I.e. you can use {{cmdroot|setkeycodes 6e 109 6d 104 69 28 6b 1}} to map the Tablets Up and Down keys to the standard PageUp and PageDown keys and Tablet Escape and Enter to their respective keys.&lt;br /&gt;
&lt;br /&gt;
The following table shows the keycodes generated by the ThinkPad keys.&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
|+ keycodes&lt;br /&gt;
! key !! keycode&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet orientation|#494949}} || 0x6d&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Shortcut|#494949}} || 0x6e&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Esc|#494949}} || 0x6b&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Enter|#494949}} || 0x69&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Up|#494949}} || 0x68&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Down|#494949}} || 0x6c&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet (unlabeled)|#494949}} || 0x67&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Example Applications==&lt;br /&gt;
===Web Browsers===&lt;br /&gt;
====Firefox====&lt;br /&gt;
&lt;br /&gt;
There are various ways to assign actions to the browser keys. The easiest way is to install [http://mozilla.dorando.at/keyconfig.xpi keyconfig.xpi] from http://mozilla.dorando.at, which adds a menu entry Tools-&amp;gt;Keyconfig. Then you can assign any action you want to the F19/F20 keys (you still need to create {{path|~/.Xmodmap}} as explained above).&lt;br /&gt;
&lt;br /&gt;
The remaining discussion gives you various more complicated ways to achieve the same thing. &lt;br /&gt;
To have firefox make use of the browser keys you need to modify one of its files{{footnote|4}}.&lt;br /&gt;
To do this you will first need to extract it from the {{path|browser.jar}} archive. Do...&lt;br /&gt;
&lt;br /&gt;
:{{cmdroot|cd &amp;lt;firefox-directory&amp;gt;/chrome}}&amp;lt;br /&amp;gt;&lt;br /&gt;
:{{cmdroot|unzip browser.jar}}&lt;br /&gt;
&lt;br /&gt;
The file of interest is {{path|content/browser/browser.xul}}. Edit it {and don't forget to make a backup copy first}...&lt;br /&gt;
:{{cmdroot|vi content/browser/browser.xul}}&lt;br /&gt;
&lt;br /&gt;
Look for the '''&amp;lt;keyset id=&amp;quot;mainKeyset&amp;quot;&amp;gt;''' section and add the following lines within...&lt;br /&gt;
 &amp;lt;key id=&amp;quot;goBackKb&amp;quot; keycode=&amp;quot;VK_F19&amp;quot; command=&amp;quot;Browser:Back&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;key id=&amp;quot;goForwardKb&amp;quot; keycode=&amp;quot;VK_F20&amp;quot; command=&amp;quot;Browser:Forward&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Command you need for Next Tab &lt;br /&gt;
 &amp;lt;key id=&amp;quot;goBackTabKb&amp;quot; keycode=&amp;quot;VK_F19&amp;quot; oncommand=&amp;quot;gBrowser.mTabContainer.advanceSelectedTab(-1)&amp;quot; /&amp;gt;&lt;br /&gt;
For the Previous Tab &lt;br /&gt;
 &amp;lt;key id=&amp;quot;goForwardTabKb&amp;quot; keycode=&amp;quot;VK_F20&amp;quot; oncommand=&amp;quot;gBrowser.mTabContainer.advanceSelectedTab(1)&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now save the file and repackage the {{path|browser.jar}} archive...&lt;br /&gt;
:{{cmdroot|zip -rD0 browser.jar content/browser/}}&lt;br /&gt;
&lt;br /&gt;
That's it.&lt;br /&gt;
&lt;br /&gt;
{{HINT|For Firefox 2.0, just edit &amp;lt;firefox-directory&amp;gt;/chrome/browser/content/browser/browser.xul}}&lt;br /&gt;
&lt;br /&gt;
{{HINT|Outdated: Another interesting Page on Firefox is http://dqd.com/~mayoff/notes/thinkpad/dqdnavkeys/ It uses different key mappings (F19 resp. F20) but a ready [http://dqd.com/~mayoff/notes/thinkpad/dqdnavkeys/dqdnavkeys-1.2.xpi .xpi] is provided which is pretty comfortable. However, this xpi file does not install on Firefox 1.5. or later.}}&lt;br /&gt;
&lt;br /&gt;
{{HINT|Outdated: You can also use the [http://extensionroom.mozdev.org/more-info/keyconfig keyconfig] extension to configure custom keys.  This extension works with Firefox 1.5 but not with Firefox 2.0. The Command you need for Next Tab is gBrowser.mTabContainer.advanceSelectedTab(1,true); For Previous Tab its gBrowser.mTabContainer.advanceSelectedTab(-1,true); }}.&lt;br /&gt;
&lt;br /&gt;
====Konqueror====&lt;br /&gt;
KDE allows you set key mappings for KDE applications (Go to KMenu &amp;gt; System &amp;gt; Control Center &amp;gt; Regional &amp;amp; Accessibility &amp;gt; Keyboard Shortcuts). By default (at least in KDE 3.5), XF86Back and XF86Forward are set as alternatives to Alt-Left and Alt-Right, and are mapped to KDE Back and Forward navigation actions.  &lt;br /&gt;
&lt;br /&gt;
If you use Konqueror as your only browser, you only need to set up {{path|~/.Xmodmap}} as described [[#xmodmap configuration|above]] to assign ThinkPad back/forward keys to the symbols XF86Back/XF86Forward. This also make these keys work for other KDE applications such as Quanta Plus, KPackage and so on (not all KDE applications honor this setting, e.g. KDE help system doesn't).&lt;br /&gt;
&lt;br /&gt;
If you want to use Firefox, however, the above settings do not work. You will have to map ThinkPad back/forward keys to F19/F20 as described [[#Firefox|above]], and change KDE navigation key settings to use F19/F20 instead of the default.&lt;br /&gt;
&lt;br /&gt;
====Opera====&lt;br /&gt;
However this isn't a simple configration file, you can set your browser manually.&amp;lt;br /&amp;gt;&lt;br /&gt;
Go to &amp;lt;i&amp;gt;Tool &amp;gt; Settings &amp;gt; Mouse and keyboard &amp;gt; Keyboard settings &amp;gt; Edit &amp;gt; Browser Window&amp;lt;/i&amp;gt;. There add F19 - Back and F20 - Forward. Now you can surf using your TP keys ;-)&lt;br /&gt;
&lt;br /&gt;
===Window Managers===&lt;br /&gt;
====fvwm====&lt;br /&gt;
To get the {{ibmkey|Forward|#494949}} and {{ibmkey|Backward|#494949}} keys to cycle through pages in the virtual desktop, add this to your {{path|~/.fvwmrc}}:&lt;br /&gt;
 Key    XF86Back     A      A   Scroll     -100000   0&lt;br /&gt;
 Key    XF86Forward  A      A   Scroll     +100000   0&lt;br /&gt;
If you use multiple virtual desktops, you could instead use the keys to flip between them by using GotoDesk.&lt;br /&gt;
&lt;br /&gt;
====fluxbox====&lt;br /&gt;
To get the keys to cycle through pages in the virtual desktop, add this to your {{path|~/.fluxbox/keys}}:&lt;br /&gt;
 None F19 :PrevWorkspace&lt;br /&gt;
 None F20 :NextWorkspace&lt;br /&gt;
&lt;br /&gt;
====pekwm configuration====&lt;br /&gt;
You can make the two browser keys switch workspaces in pekwm, by adding the following two lines to the {{path|~/.pekwm/keys}} file:&lt;br /&gt;
 KeyPress = &amp;quot;Mod1 XF86Back&amp;quot; { Actions = &amp;quot;GoToWorkspace prev&amp;quot; }&lt;br /&gt;
 KeyPress = &amp;quot;Mod1 XF86Forward&amp;quot; { Actions = &amp;quot;GoToWorkspace next&amp;quot; }&lt;br /&gt;
&lt;br /&gt;
====pwm====&lt;br /&gt;
Another example how to use these two keys to switch between pwm tabs. These two lines should be added to {{path|~/.pwm/keys-default.conf}} or {{path|/etc/pwm/keys-default.conf}}:&lt;br /&gt;
 kbind &amp;quot;Back&amp;quot;, &amp;quot;switch_rot&amp;quot;, -1&lt;br /&gt;
 kbind &amp;quot;Forward&amp;quot;, &amp;quot;switch_rot&amp;quot;, 1&lt;br /&gt;
&lt;br /&gt;
====IceWM====&lt;br /&gt;
To make IceWM cycle workspaces using the {{ibmkey|Forward|#494949}} and {{ibmkey|Backward|#494949}} keys, change these two options in {{path|~/.icewm/preferences}} (Provided you assigned keysyms F19 and F20 with xmodmap):&lt;br /&gt;
 # &amp;quot;Previous workspace&amp;quot; shortcut&lt;br /&gt;
 KeySysWorkspacePrev=&amp;quot;F19&amp;quot;&lt;br /&gt;
 # &amp;quot;Next workspace&amp;quot; shortcut&lt;br /&gt;
 KeySysWorkspaceNext=&amp;quot;F20&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Gnome/metacity ====&lt;br /&gt;
&lt;br /&gt;
Follow the [https://wiki.ubuntu.com/Keybindings Ubuntu guide].&lt;br /&gt;
&lt;br /&gt;
===Other Uses===&lt;br /&gt;
====Console tools configuraton====&lt;br /&gt;
To make the {{ibmkey|Forward|#494949}} and {{ibmkey|Backward|#494949}} keys useful in console, add this to your keymap ({{path|/etc/console/boottime.kmap.gz}} in {{Debian}}):&lt;br /&gt;
 keycode 158 = Decr_Console&lt;br /&gt;
 keycode 159 = Incr_Console&lt;br /&gt;
&lt;br /&gt;
Alternatively you can load this script (perhaps on system startup) to enable Backward/Forward button console (VT) switch:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 echo keycode 158 = Decr_Console | loadkeys&lt;br /&gt;
 echo keycode 159 = Incr_Console | loadkeys&lt;br /&gt;
&lt;br /&gt;
It should work with any distro.&lt;br /&gt;
&lt;br /&gt;
==External Sources==&lt;br /&gt;
*[http://www-307.ibm.com/pc/support/site.wss/document.do?lndocid=MIGR-51537 IBMs page on configuring the ThinkPad buttons (ThinkPad, Access IBM, Mail, Search, and Home buttons) under Linux]&lt;br /&gt;
*[http://dqd.com/~mayoff/notes/thinkpad/dqdnavkeys/ Rob Mayoffs page on using IBM Keyboard Navigation Keys in Linux Mozilla and Firefox]&lt;br /&gt;
*[http://snarfed.org/space/thinkpad+keys+in+firefox Ryan Barretts blog article about using the browser keys in Firefox]&lt;br /&gt;
*[http://chaotika.org/~bluesceada/?page=soft&amp;amp;sub=thinkpad#acpibutn DennisG's help to get the ibm-acpi buttons do useful things] on a {{Z61e}} and possibly {{Z61m}}, {{Z61t}} and {{Z61p}}&lt;br /&gt;
&lt;br /&gt;
{{footnotes|&lt;br /&gt;
#Note that the associated functionality for Fn-F* key combinations is not consistent amongst all ThinkPads. We are maintaining [[Default meanings of special keys|a table of associated meanings]].&lt;br /&gt;
#if there are more than one tool listed, one is sufficient&lt;br /&gt;
#'full' means you can completely reassign any action to be triggered by the key, 'additional actions' means you can trigger actions in addition to the standard function of the key, which can not be changed.&lt;br /&gt;
#Thanks go to Ryan Barrett for writing the [http://snarfed.org/space/thinkpad+keys+in+firefox little howto] on [http://snarfed.org/space/start his blog].&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34449</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34449"/>
		<updated>2007-11-12T15:55:05Z</updated>

		<summary type="html">&lt;p&gt;Seva: Sample fn-F7 script moved to Sample Fn-F7 script: capital F in Fn&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide will let you use Fn-F7 key combination to toggle between internal, mirror, external, or both screens.  This was tested on ThinkPad X60s running Fedora 8, please comment if it works or does not work for you.&lt;br /&gt;
&lt;br /&gt;
Add a &amp;quot;Virtual&amp;quot; statement to your /etc/X11/xorg.conf, the total resolution should be large enough to fit all your screens in the configuration you want, for example I have 1600x1200 monitor to the left of my internal 1024x768 monitor for a total max resolution of 2624x1200:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 Section &amp;quot;Screen&amp;quot;&lt;br /&gt;
        Identifier &amp;quot;Screen0&amp;quot;&lt;br /&gt;
        Device     &amp;quot;Videocard0&amp;quot;&lt;br /&gt;
        DefaultDepth     24&lt;br /&gt;
        SubSection &amp;quot;Display&amp;quot;&lt;br /&gt;
                Viewport   0 0&lt;br /&gt;
                Depth     24&lt;br /&gt;
                &amp;lt;b&amp;gt;Virtual   2624 1200&amp;lt;/b&amp;gt;&lt;br /&gt;
        EndSubSection&lt;br /&gt;
 EndSection&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart X server at this point (i.e. logout and login).&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 # fn-F7&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7:&lt;br /&gt;
&lt;br /&gt;
Note: you will have change EXTERNAL_OUTPUT and INTERNAL_OUTPUT to what xrandr shows, for example VGA and LVDS in this case:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 xrandr | grep connected&lt;br /&gt;
 &amp;lt;b&amp;gt;VGA&amp;lt;/b&amp;gt; connected 1600x1200+0+0 (normal left inverted right x axis y axis) 432mm x 324mm&lt;br /&gt;
 &amp;lt;b&amp;gt;LVDS&amp;lt;/b&amp;gt; connected (normal left inverted right x axis y axis)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 #@ seva sevatech.com&lt;br /&gt;
 &lt;br /&gt;
 EXTERNAL_OUTPUT=&amp;lt;b&amp;gt;VGA&amp;lt;/b&amp;gt;&lt;br /&gt;
 INTERNAL_OUTPUT=&amp;lt;b&amp;gt;LVDS&amp;lt;/b&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
 EXTERNAL_LOCATION=&amp;quot;&amp;lt;b&amp;gt;--left-of&amp;lt;/b&amp;gt; $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # This is to figure out which X11 display to work on&lt;br /&gt;
 SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
 export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
 &lt;br /&gt;
 # Save the state to the file until we can figure it out by running xrandr&lt;br /&gt;
 STATE_FILE=/var/lib/thinkpad/screen.state;&lt;br /&gt;
 if [ ! -e $STATE_FILE ]; then&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 STATE=$(cat $STATE_FILE)&lt;br /&gt;
 &lt;br /&gt;
 function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;external&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_mirror(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
        echo &amp;quot;mirror&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION&amp;quot;&lt;br /&gt;
        echo &amp;quot;both&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_toggle(){&lt;br /&gt;
        case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                internal)&lt;br /&gt;
                        screen_mirror&lt;br /&gt;
                        ;;&lt;br /&gt;
                mirror)&lt;br /&gt;
                        screen_external&lt;br /&gt;
                        ;;&lt;br /&gt;
                external)&lt;br /&gt;
                        screen_both&lt;br /&gt;
                        ;;&lt;br /&gt;
                both)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
                *)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
        esac&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # What should we do?&lt;br /&gt;
 DO=&amp;quot;$1&amp;quot;&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=$(basename $0)&lt;br /&gt;
 fi&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=&amp;quot;internal&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        toggle|thinkpad-fn-f7)&lt;br /&gt;
                echo wtf&lt;br /&gt;
                screen_toggle&lt;br /&gt;
                ;;&lt;br /&gt;
        internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        mirror)&lt;br /&gt;
                screen_mirror&lt;br /&gt;
                ;;&lt;br /&gt;
        both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        status)&lt;br /&gt;
                echo $STATE&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: $0 &amp;lt;command&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  commands:&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          status&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          external&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          mirror&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  If no command is given default is internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As root, run the following commands,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 mkdir -p /var/lib/thinkpad&lt;br /&gt;
 echo &amp;quot;internal&amp;quot; &amp;gt; /var/lib/thinkpad/screen.state&lt;br /&gt;
 chmod 755 /usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
 service acpid restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should be ready to go, just press Fn-F7 to try.&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_fn-F7_script&amp;diff=34450</id>
		<title>Sample fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_fn-F7_script&amp;diff=34450"/>
		<updated>2007-11-12T15:55:05Z</updated>

		<summary type="html">&lt;p&gt;Seva: Sample fn-F7 script moved to Sample Fn-F7 script: capital F in Fn&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Sample Fn-F7 script]]&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Talk:Sample_Fn-F7_script&amp;diff=34451</id>
		<title>Talk:Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Talk:Sample_Fn-F7_script&amp;diff=34451"/>
		<updated>2007-11-12T15:55:05Z</updated>

		<summary type="html">&lt;p&gt;Seva: Talk:Sample fn-F7 script moved to Talk:Sample Fn-F7 script: capital F in Fn&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Note: you will need to change the internal and external resolution until someone fixes this script to figure it out from xrandr, you may also need to change output names from &amp;quot;VGA&amp;quot; and &amp;quot;LVDS&amp;quot; to what your xrandr tells you.&lt;br /&gt;
&lt;br /&gt;
why not just use --auto ?&lt;br /&gt;
&lt;br /&gt;
xrandr --output VGA --auto&lt;br /&gt;
&lt;br /&gt;
xrandr --output VGA --off&lt;br /&gt;
&lt;br /&gt;
xrandr --output LVDS --auto&lt;br /&gt;
&lt;br /&gt;
xrandr --output LVDS --off&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Good point, made the changes --seva&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Talk:Sample_fn-F7_script&amp;diff=34452</id>
		<title>Talk:Sample fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Talk:Sample_fn-F7_script&amp;diff=34452"/>
		<updated>2007-11-12T15:55:05Z</updated>

		<summary type="html">&lt;p&gt;Seva: Talk:Sample fn-F7 script moved to Talk:Sample Fn-F7 script: capital F in Fn&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Talk:Sample Fn-F7 script]]&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34448</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34448"/>
		<updated>2007-11-12T15:54:51Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide will let you use Fn-F7 key combination to toggle between internal, mirror, external, or both screens.  This was tested on ThinkPad X60s running Fedora 8, please comment if it works or does not work for you.&lt;br /&gt;
&lt;br /&gt;
Add a &amp;quot;Virtual&amp;quot; statement to your /etc/X11/xorg.conf, the total resolution should be large enough to fit all your screens in the configuration you want, for example I have 1600x1200 monitor to the left of my internal 1024x768 monitor for a total max resolution of 2624x1200:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 Section &amp;quot;Screen&amp;quot;&lt;br /&gt;
        Identifier &amp;quot;Screen0&amp;quot;&lt;br /&gt;
        Device     &amp;quot;Videocard0&amp;quot;&lt;br /&gt;
        DefaultDepth     24&lt;br /&gt;
        SubSection &amp;quot;Display&amp;quot;&lt;br /&gt;
                Viewport   0 0&lt;br /&gt;
                Depth     24&lt;br /&gt;
                &amp;lt;b&amp;gt;Virtual   2624 1200&amp;lt;/b&amp;gt;&lt;br /&gt;
        EndSubSection&lt;br /&gt;
 EndSection&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart X server at this point (i.e. logout and login).&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 # fn-F7&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7:&lt;br /&gt;
&lt;br /&gt;
Note: you will have change EXTERNAL_OUTPUT and INTERNAL_OUTPUT to what xrandr shows, for example VGA and LVDS in this case:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 xrandr | grep connected&lt;br /&gt;
 &amp;lt;b&amp;gt;VGA&amp;lt;/b&amp;gt; connected 1600x1200+0+0 (normal left inverted right x axis y axis) 432mm x 324mm&lt;br /&gt;
 &amp;lt;b&amp;gt;LVDS&amp;lt;/b&amp;gt; connected (normal left inverted right x axis y axis)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 #@ seva sevatech.com&lt;br /&gt;
 &lt;br /&gt;
 EXTERNAL_OUTPUT=&amp;lt;b&amp;gt;VGA&amp;lt;/b&amp;gt;&lt;br /&gt;
 INTERNAL_OUTPUT=&amp;lt;b&amp;gt;LVDS&amp;lt;/b&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
 EXTERNAL_LOCATION=&amp;quot;&amp;lt;b&amp;gt;--left-of&amp;lt;/b&amp;gt; $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # This is to figure out which X11 display to work on&lt;br /&gt;
 SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
 export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
 &lt;br /&gt;
 # Save the state to the file until we can figure it out by running xrandr&lt;br /&gt;
 STATE_FILE=/var/lib/thinkpad/screen.state;&lt;br /&gt;
 if [ ! -e $STATE_FILE ]; then&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 STATE=$(cat $STATE_FILE)&lt;br /&gt;
 &lt;br /&gt;
 function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;external&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_mirror(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
        echo &amp;quot;mirror&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION&amp;quot;&lt;br /&gt;
        echo &amp;quot;both&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_toggle(){&lt;br /&gt;
        case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                internal)&lt;br /&gt;
                        screen_mirror&lt;br /&gt;
                        ;;&lt;br /&gt;
                mirror)&lt;br /&gt;
                        screen_external&lt;br /&gt;
                        ;;&lt;br /&gt;
                external)&lt;br /&gt;
                        screen_both&lt;br /&gt;
                        ;;&lt;br /&gt;
                both)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
                *)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
        esac&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # What should we do?&lt;br /&gt;
 DO=&amp;quot;$1&amp;quot;&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=$(basename $0)&lt;br /&gt;
 fi&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=&amp;quot;internal&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        toggle|thinkpad-fn-f7)&lt;br /&gt;
                echo wtf&lt;br /&gt;
                screen_toggle&lt;br /&gt;
                ;;&lt;br /&gt;
        internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        mirror)&lt;br /&gt;
                screen_mirror&lt;br /&gt;
                ;;&lt;br /&gt;
        both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        status)&lt;br /&gt;
                echo $STATE&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: $0 &amp;lt;command&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  commands:&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          status&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          external&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          mirror&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  If no command is given default is internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As root, run the following commands,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 mkdir -p /var/lib/thinkpad&lt;br /&gt;
 echo &amp;quot;internal&amp;quot; &amp;gt; /var/lib/thinkpad/screen.state&lt;br /&gt;
 chmod 755 /usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
 service acpid restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should be ready to go, just press Fn-F7 to try.&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34447</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34447"/>
		<updated>2007-11-12T15:54:10Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide will let you use Fn-F7 key combination to toggle between internal, mirror, external, or both screens.  This was tested on ThinkPad X60s running Fedora 8, please comment if it works or does not work for you.&lt;br /&gt;
&lt;br /&gt;
Add a &amp;quot;Virtual&amp;quot; statement to your /etc/X11/xorg.conf, the total resolution should be large enough to fit all your screens in the configuration you want, for example I have 1600x1200 monitor to the left of my internal 1024x768 monitor for a total max resolution of 2624x1200:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 Section &amp;quot;Screen&amp;quot;&lt;br /&gt;
        Identifier &amp;quot;Screen0&amp;quot;&lt;br /&gt;
        Device     &amp;quot;Videocard0&amp;quot;&lt;br /&gt;
        DefaultDepth     24&lt;br /&gt;
        SubSection &amp;quot;Display&amp;quot;&lt;br /&gt;
                Viewport   0 0&lt;br /&gt;
                Depth     24&lt;br /&gt;
                &amp;lt;b&amp;gt;Virtual   2624 1200&amp;lt;/b&amp;gt;&lt;br /&gt;
        EndSubSection&lt;br /&gt;
 EndSection&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart X server at this point (i.e. logout and login).&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 # fn-F7&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create &amp;lt;b&amp;gt;/usr/local/sbin/thinkpad-fn-f7&amp;lt;/b&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
Note: you will have change EXTERNAL_OUTPUT and INTERNAL_OUTPUT to what xrandr shows, for example VGA and LVDS in this case:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 xrandr | grep connected&lt;br /&gt;
 &amp;lt;b&amp;gt;VGA&amp;lt;/b&amp;gt; connected 1600x1200+0+0 (normal left inverted right x axis y axis) 432mm x 324mm&lt;br /&gt;
 &amp;lt;b&amp;gt;LVDS&amp;lt;/b&amp;gt; connected (normal left inverted right x axis y axis)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 #@ seva sevatech.com&lt;br /&gt;
 &lt;br /&gt;
 EXTERNAL_OUTPUT=&amp;lt;b&amp;gt;VGA&amp;lt;/b&amp;gt;&lt;br /&gt;
 INTERNAL_OUTPUT=&amp;lt;b&amp;gt;LVDS&amp;lt;/b&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
 EXTERNAL_LOCATION=&amp;quot;&amp;lt;b&amp;gt;--left-of&amp;lt;/b&amp;gt; $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # This is to figure out which X11 display to work on&lt;br /&gt;
 SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
 export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
 &lt;br /&gt;
 # Save the state to the file until we can figure it out by running xrandr&lt;br /&gt;
 STATE_FILE=/var/lib/thinkpad/screen.state;&lt;br /&gt;
 if [ ! -e $STATE_FILE ]; then&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 STATE=$(cat $STATE_FILE)&lt;br /&gt;
 &lt;br /&gt;
 function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;external&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_mirror(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
        echo &amp;quot;mirror&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION&amp;quot;&lt;br /&gt;
        echo &amp;quot;both&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_toggle(){&lt;br /&gt;
        case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                internal)&lt;br /&gt;
                        screen_mirror&lt;br /&gt;
                        ;;&lt;br /&gt;
                mirror)&lt;br /&gt;
                        screen_external&lt;br /&gt;
                        ;;&lt;br /&gt;
                external)&lt;br /&gt;
                        screen_both&lt;br /&gt;
                        ;;&lt;br /&gt;
                both)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
                *)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
        esac&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # What should we do?&lt;br /&gt;
 DO=&amp;quot;$1&amp;quot;&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=$(basename $0)&lt;br /&gt;
 fi&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=&amp;quot;internal&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        toggle|thinkpad-fn-f7)&lt;br /&gt;
                echo wtf&lt;br /&gt;
                screen_toggle&lt;br /&gt;
                ;;&lt;br /&gt;
        internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        mirror)&lt;br /&gt;
                screen_mirror&lt;br /&gt;
                ;;&lt;br /&gt;
        both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        status)&lt;br /&gt;
                echo $STATE&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: $0 &amp;lt;command&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  commands:&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          status&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          external&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          mirror&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  If no command is given default is internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As root, run the following commands,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 mkdir -p /var/lib/thinkpad&lt;br /&gt;
 echo &amp;quot;internal&amp;quot; &amp;gt; /var/lib/thinkpad/screen.state&lt;br /&gt;
 chmod 755 /usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
 service acpid restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should be ready to go, just press Fn-F7 to try.&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34446</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34446"/>
		<updated>2007-11-12T15:50:35Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This setup will let you use fn-F7 key combination to toggle between internal, mirror, external, or both screens.  Tested on ThinkPad X60s running Fedora 8.&lt;br /&gt;
&lt;br /&gt;
Add a &amp;quot;Virtual&amp;quot; statement to your /etc/X11/xorg.conf, the total resolution should be large enough to fit all your screens in the configuration you want, for example I have 1600x1200 monitor to the left of my internal 1024x768 monitor for a total max resolution of 2624x1200:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
Section &amp;quot;Screen&amp;quot;&lt;br /&gt;
        Identifier &amp;quot;Screen0&amp;quot;&lt;br /&gt;
        Device     &amp;quot;Videocard0&amp;quot;&lt;br /&gt;
        DefaultDepth     24&lt;br /&gt;
        SubSection &amp;quot;Display&amp;quot;&lt;br /&gt;
                Viewport   0 0&lt;br /&gt;
                Depth     24&lt;br /&gt;
                Virtual   2624 1200&lt;br /&gt;
        EndSubSection&lt;br /&gt;
EndSection&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 # fn-F7&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7:&lt;br /&gt;
&lt;br /&gt;
Note: you will have change EXTERNAL_OUTPUT and INTERNAL_OUTPUT to what xrandr shows, for example VGA and LVDS in this case:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 xrandr | grep connected&lt;br /&gt;
 VGA connected 1600x1200+0+0 (normal left inverted right x axis y axis) 432mm x 324mm&lt;br /&gt;
 LVDS connected (normal left inverted right x axis y axis)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 #@ seva sevatech.com&lt;br /&gt;
 &lt;br /&gt;
 EXTERNAL_OUTPUT=VGA&lt;br /&gt;
 INTERNAL_OUTPUT=LVDS&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # This is to figure out which X11 display to work on&lt;br /&gt;
 SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
 export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
 &lt;br /&gt;
 # Save the state to the file until we can figure it out by running xrandr&lt;br /&gt;
 STATE_FILE=/var/lib/thinkpad/screen.state;&lt;br /&gt;
 if [ ! -e $STATE_FILE ]; then&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 STATE=$(cat $STATE_FILE)&lt;br /&gt;
 &lt;br /&gt;
 function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;external&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_mirror(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
        echo &amp;quot;mirror&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION&amp;quot;&lt;br /&gt;
        echo &amp;quot;both&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_toggle(){&lt;br /&gt;
        case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                internal)&lt;br /&gt;
                        screen_mirror&lt;br /&gt;
                        ;;&lt;br /&gt;
                mirror)&lt;br /&gt;
                        screen_external&lt;br /&gt;
                        ;;&lt;br /&gt;
                external)&lt;br /&gt;
                        screen_both&lt;br /&gt;
                        ;;&lt;br /&gt;
                both)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
                *)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
        esac&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # What should we do?&lt;br /&gt;
 DO=&amp;quot;$1&amp;quot;&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=$(basename $0)&lt;br /&gt;
 fi&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=&amp;quot;internal&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        toggle|thinkpad-fn-f7)&lt;br /&gt;
                echo wtf&lt;br /&gt;
                screen_toggle&lt;br /&gt;
                ;;&lt;br /&gt;
        internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        mirror)&lt;br /&gt;
                screen_mirror&lt;br /&gt;
                ;;&lt;br /&gt;
        both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        status)&lt;br /&gt;
                echo $STATE&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: $0 &amp;lt;command&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  commands:&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          status&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          external&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          mirror&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  If no command is given default is internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As root,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 mkdir -p /var/lib/thinkpad&lt;br /&gt;
 echo &amp;quot;internal&amp;quot; &amp;gt; /var/lib/thinkpad/screen.state&lt;br /&gt;
 chmod 755 /usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
 service acpid restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34445</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34445"/>
		<updated>2007-11-12T15:48:24Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This setup will let you use fn-F7 key combination to toggle between internal, mirror, external, or both screens.  Tested on ThinkPad X60s running Fedora 8.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 # fn-F7&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7:&lt;br /&gt;
&lt;br /&gt;
Note: you will have change EXTERNAL_OUTPUT and INTERNAL_OUTPUT to what xrandr shows, for example VGA and LVDS in this case:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 xrandr | grep connected&lt;br /&gt;
 VGA connected 1600x1200+0+0 (normal left inverted right x axis y axis) 432mm x 324mm&lt;br /&gt;
 LVDS connected (normal left inverted right x axis y axis)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 #@ seva sevatech.com&lt;br /&gt;
 &lt;br /&gt;
 EXTERNAL_OUTPUT=VGA&lt;br /&gt;
 INTERNAL_OUTPUT=LVDS&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # This is to figure out which X11 display to work on&lt;br /&gt;
 SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
 export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
 &lt;br /&gt;
 # Save the state to the file until we can figure it out by running xrandr&lt;br /&gt;
 STATE_FILE=/var/lib/thinkpad/screen.state;&lt;br /&gt;
 if [ ! -e $STATE_FILE ]; then&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 STATE=$(cat $STATE_FILE)&lt;br /&gt;
 &lt;br /&gt;
 function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;external&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_mirror(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
        echo &amp;quot;mirror&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION&amp;quot;&lt;br /&gt;
        echo &amp;quot;both&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_toggle(){&lt;br /&gt;
        case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                internal)&lt;br /&gt;
                        screen_mirror&lt;br /&gt;
                        ;;&lt;br /&gt;
                mirror)&lt;br /&gt;
                        screen_external&lt;br /&gt;
                        ;;&lt;br /&gt;
                external)&lt;br /&gt;
                        screen_both&lt;br /&gt;
                        ;;&lt;br /&gt;
                both)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
                *)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
        esac&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # What should we do?&lt;br /&gt;
 DO=&amp;quot;$1&amp;quot;&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=$(basename $0)&lt;br /&gt;
 fi&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=&amp;quot;internal&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        toggle|thinkpad-fn-f7)&lt;br /&gt;
                echo wtf&lt;br /&gt;
                screen_toggle&lt;br /&gt;
                ;;&lt;br /&gt;
        internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        mirror)&lt;br /&gt;
                screen_mirror&lt;br /&gt;
                ;;&lt;br /&gt;
        both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        status)&lt;br /&gt;
                echo $STATE&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: $0 &amp;lt;command&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  commands:&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          status&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          external&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          mirror&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  If no command is given default is internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As root,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 mkdir -p /var/lib/thinkpad&lt;br /&gt;
 echo &amp;quot;internal&amp;quot; &amp;gt; /var/lib/thinkpad/screen.state&lt;br /&gt;
 chmod 755 /usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
 service acpid restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Talk:Sample_Fn-F7_script&amp;diff=34444</id>
		<title>Talk:Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Talk:Sample_Fn-F7_script&amp;diff=34444"/>
		<updated>2007-11-12T15:42:21Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Note: you will need to change the internal and external resolution until someone fixes this script to figure it out from xrandr, you may also need to change output names from &amp;quot;VGA&amp;quot; and &amp;quot;LVDS&amp;quot; to what your xrandr tells you.&lt;br /&gt;
&lt;br /&gt;
why not just use --auto ?&lt;br /&gt;
&lt;br /&gt;
xrandr --output VGA --auto&lt;br /&gt;
&lt;br /&gt;
xrandr --output VGA --off&lt;br /&gt;
&lt;br /&gt;
xrandr --output LVDS --auto&lt;br /&gt;
&lt;br /&gt;
xrandr --output LVDS --off&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Good point, made the changes --seva&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34443</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34443"/>
		<updated>2007-11-12T15:41:57Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This setup will let you use fn-F7 key combination to toggle between internal, external, or both screens.  Tested on ThinkPad X60s running Fedora 8.&lt;br /&gt;
&lt;br /&gt;
Note: you will need to change the internal and external resolution until someone fixes this script to figure it out from xrandr, you may also need to change output names from &amp;quot;VGA&amp;quot; and &amp;quot;LVDS&amp;quot; to what your xrandr tells you.&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 # fn-F7&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 #@ seva sevatech.com&lt;br /&gt;
 &lt;br /&gt;
 EXTERNAL_OUTPUT=VGA&lt;br /&gt;
 INTERNAL_OUTPUT=LVDS&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # This is to figure out which X11 display to work on&lt;br /&gt;
 SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
 export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
 &lt;br /&gt;
 # Save the state to the file until we can figure it out by running xrandr&lt;br /&gt;
 STATE_FILE=/var/lib/thinkpad/screen.state;&lt;br /&gt;
 if [ ! -e $STATE_FILE ]; then&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 STATE=$(cat $STATE_FILE)&lt;br /&gt;
 &lt;br /&gt;
 function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;external&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_mirror(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
        echo &amp;quot;mirror&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION&amp;quot;&lt;br /&gt;
        echo &amp;quot;both&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_toggle(){&lt;br /&gt;
        case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                internal)&lt;br /&gt;
                        screen_mirror&lt;br /&gt;
                        ;;&lt;br /&gt;
                mirror)&lt;br /&gt;
                        screen_external&lt;br /&gt;
                        ;;&lt;br /&gt;
                external)&lt;br /&gt;
                        screen_both&lt;br /&gt;
                        ;;&lt;br /&gt;
                both)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
                *)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
        esac&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # What should we do?&lt;br /&gt;
 DO=&amp;quot;$1&amp;quot;&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=$(basename $0)&lt;br /&gt;
 fi&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=&amp;quot;internal&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        toggle|thinkpad-fn-f7)&lt;br /&gt;
                echo wtf&lt;br /&gt;
                screen_toggle&lt;br /&gt;
                ;;&lt;br /&gt;
        internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        mirror)&lt;br /&gt;
                screen_mirror&lt;br /&gt;
                ;;&lt;br /&gt;
        both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        status)&lt;br /&gt;
                echo $STATE&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: $0 &amp;lt;command&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  commands:&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          status&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          external&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          mirror&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  If no command is given default is internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As root,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 mkdir -p /var/lib/thinkpad&lt;br /&gt;
 echo &amp;quot;internal&amp;quot; &amp;gt; /var/lib/thinkpad/screen.state&lt;br /&gt;
 chmod 755 /usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
 service acpid restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34442</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34442"/>
		<updated>2007-11-12T15:41:37Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This setup will let you use fn-F7 key combination to toggle between internal, external, or both screens.  Tested on ThinkPad X60s running Fedora 8.&lt;br /&gt;
&lt;br /&gt;
Note: you will need to change the internal and external resolution until someone fixes this script to figure it out from xrandr, you may also need to change output names from &amp;quot;VGA&amp;quot; and &amp;quot;LVDS&amp;quot; to what your xrandr tells you.&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 # fn-F7&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 #@ seva sevatech.com&lt;br /&gt;
 &lt;br /&gt;
 EXTERNAL_OUTPUT=VGA&lt;br /&gt;
 INTERNAL_OUTPUT=LVDS&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # This is to figure out which X11 display to work on&lt;br /&gt;
 SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
 export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
 &lt;br /&gt;
 # Save the state to the file until we can figure it out by running xrandr&lt;br /&gt;
 STATE_FILE=/var/lib/thinkpad/screen.state;&lt;br /&gt;
 if [ ! -e $STATE_FILE ]; then&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 STATE=$(cat $STATE_FILE)&lt;br /&gt;
 &lt;br /&gt;
 function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;external&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_mirror(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
        echo &amp;quot;mirror&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION&amp;quot;&lt;br /&gt;
        echo &amp;quot;both&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 function screen_toggle(){&lt;br /&gt;
        case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                internal)&lt;br /&gt;
                        screen_mirror&lt;br /&gt;
                        ;;&lt;br /&gt;
                mirror)&lt;br /&gt;
                        screen_external&lt;br /&gt;
                        ;;&lt;br /&gt;
                external)&lt;br /&gt;
                        screen_both&lt;br /&gt;
                        ;;&lt;br /&gt;
                both)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
                *)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
        esac&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # What should we do?&lt;br /&gt;
 DO=&amp;quot;$1&amp;quot;&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=$(basename $0)&lt;br /&gt;
 fi&lt;br /&gt;
 if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=&amp;quot;internal&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        toggle|thinkpad-fn-f7)&lt;br /&gt;
                echo wtf&lt;br /&gt;
                screen_toggle&lt;br /&gt;
                ;;&lt;br /&gt;
        internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        mirror)&lt;br /&gt;
                screen_mirror&lt;br /&gt;
                ;;&lt;br /&gt;
        both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        status)&lt;br /&gt;
                echo $STATE&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: $0 &amp;lt;command&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  commands:&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          status&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          external&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          mirror&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  If no command is given default is internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
 esac&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As root,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 mkdir -p /var/lib/thinkpad&lt;br /&gt;
 echo &amp;quot;internal&amp;quot; &amp;gt; /var/lib/thinkpad/screen.state&lt;br /&gt;
 chmod 755 /usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
 service acpid restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34441</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34441"/>
		<updated>2007-11-12T15:40:10Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This setup will let you use fn-F7 key combination to toggle between internal, external, or both screens.  Tested on ThinkPad X60s running Fedora 8.&lt;br /&gt;
&lt;br /&gt;
Note: you will need to change the internal and external resolution until someone fixes this script to figure it out from xrandr, you may also need to change output names from &amp;quot;VGA&amp;quot; and &amp;quot;LVDS&amp;quot; to what your xrandr tells you.&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 # fn-F7&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7:&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
As root,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 mkdir -p /var/lib/thinkpad&lt;br /&gt;
 echo &amp;quot;internal&amp;quot; &amp;gt; /var/lib/thinkpad/screen.state&lt;br /&gt;
 chmod 755 /usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
 service acpid restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34440</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34440"/>
		<updated>2007-11-12T15:39:46Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This setup will let you use fn-F7 key combination to toggle between internal, external, or both screens.  Tested on ThinkPad X60s running Fedora 8.&lt;br /&gt;
&lt;br /&gt;
Note: you will need to change the internal and external resolution until someone fixes this script to figure it out from xrandr, you may also need to change output names from &amp;quot;VGA&amp;quot; and &amp;quot;LVDS&amp;quot; to what your xrandr tells you.&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
# fn-F7&lt;br /&gt;
event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7:&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
As root,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mkdir -p /var/lib/thinkpad&lt;br /&gt;
echo &amp;quot;internal&amp;quot; &amp;gt; /var/lib/thinkpad/screen.state&lt;br /&gt;
chmod 755 /usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
service acpid restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34439</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34439"/>
		<updated>2007-11-12T15:38:26Z</updated>

		<summary type="html">&lt;p&gt;Seva: Cleanups to the script, added mirror mode, and use --auto as noted in the Talk page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This setup will let you use fn-F7 key combination to toggle between internal, external, or both screens.  Tested on ThinkPad X60s running Fedora 8.&lt;br /&gt;
&lt;br /&gt;
Note: you will need to change the internal and external resolution until someone fixes this script to figure it out from xrandr, you may also need to change output names from &amp;quot;VGA&amp;quot; and &amp;quot;LVDS&amp;quot; to what your xrandr tells you.&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
# fn-F7&lt;br /&gt;
event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#@ seva sevatech.com&lt;br /&gt;
&lt;br /&gt;
EXTERNAL_OUTPUT=VGA&lt;br /&gt;
INTERNAL_OUTPUT=LVDS&lt;br /&gt;
&lt;br /&gt;
EXTERNAL_LOCATION=&amp;quot;--left-of $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This is to figure out which X11 display to work on&lt;br /&gt;
SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
&lt;br /&gt;
# Save the state to the file until we can figure it out by running xrandr&lt;br /&gt;
STATE_FILE=/var/lib/thinkpad/screen.state;&lt;br /&gt;
if [ ! -e $STATE_FILE ]; then&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
STATE=$(cat $STATE_FILE)&lt;br /&gt;
&lt;br /&gt;
function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;external&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function screen_mirror(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
        echo &amp;quot;mirror&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --auto&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION&amp;quot;&lt;br /&gt;
        echo &amp;quot;both&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function screen_toggle(){&lt;br /&gt;
        case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                internal)&lt;br /&gt;
                        screen_mirror&lt;br /&gt;
                        ;;&lt;br /&gt;
                mirror)&lt;br /&gt;
                        screen_external&lt;br /&gt;
                        ;;&lt;br /&gt;
                external)&lt;br /&gt;
                        screen_both&lt;br /&gt;
                        ;;&lt;br /&gt;
                both)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
                *)&lt;br /&gt;
                        screen_internal&lt;br /&gt;
                        ;;&lt;br /&gt;
        esac&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# What should we do?&lt;br /&gt;
DO=&amp;quot;$1&amp;quot;&lt;br /&gt;
if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=$(basename $0)&lt;br /&gt;
fi&lt;br /&gt;
if [ -z &amp;quot;$DO&amp;quot; ]; then&lt;br /&gt;
        DO=&amp;quot;internal&amp;quot;&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        toggle|thinkpad-fn-f7)&lt;br /&gt;
                echo wtf&lt;br /&gt;
                screen_toggle&lt;br /&gt;
                ;;&lt;br /&gt;
        internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        mirror)&lt;br /&gt;
                screen_mirror&lt;br /&gt;
                ;;&lt;br /&gt;
        both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        status)&lt;br /&gt;
                echo $STATE&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: $0 &amp;lt;command&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  commands:&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          status&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          external&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          mirror&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;          toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;gt;&amp;amp;2&lt;br /&gt;
                echo &amp;quot;  If no command is given default is internal&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As root,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mkdir -p /var/lib/thinkpad&lt;br /&gt;
echo &amp;quot;internal&amp;quot; &amp;gt; /var/lib/thinkpad/screen.state&lt;br /&gt;
chmod 755 /usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
service acpid restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=How_to_reduce_power_consumption&amp;diff=34435</id>
		<title>How to reduce power consumption</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=How_to_reduce_power_consumption&amp;diff=34435"/>
		<updated>2007-11-12T04:16:43Z</updated>

		<summary type="html">&lt;p&gt;Seva: Turning off auto-negotiation on a network card is not really a good idea unless the other side has it off as well&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Reducing system power consumption will extend battery life, reduce system&lt;br /&gt;
temperature and (on some models) reduce system fan noise.&lt;br /&gt;
Power consumption can be greatly improved from a stock distribution configuration&lt;br /&gt;
to a fine tuned system. The general rules are :&lt;br /&gt;
* Unload drivers for unused devices (ie. USB 1.1, Yenta/PCMCIA, Wireless, IRDA, Bluetooth, ...)&lt;br /&gt;
* Reduce polling on devices (drives, USB subsystem, nvram, use SATA AN, ...)&lt;br /&gt;
* Reduce hard drive activity&lt;br /&gt;
* Reduce LCD brightness to the minimum you can stand&lt;br /&gt;
* Reduce CPU wakeups, so it can stay longer in deep power saving c-states&lt;br /&gt;
* Make use of every hardware devices availables power saving features (AHCI ALPM, USB autosuspend, Alsa and Wireless powersaving modes, HPET timers, ...)&lt;br /&gt;
&lt;br /&gt;
==Tools==&lt;br /&gt;
Arjan van de Ven's [[PowerTOP]] utility&lt;br /&gt;
is a gold mine to improve energy efficiency, but is almost only CPU-oriented. This tool helps to easily detect&lt;br /&gt;
the top power offenders, both userland and kernel modules, which prevent the use of CPU power saving mechanisms and sometime suggest &lt;br /&gt;
fixes accordingly.&lt;br /&gt;
PowerTOP users collected some [http://www.linuxpowertop.org/known.php tips &amp;amp; tricks]&lt;br /&gt;
and an informative [http://www.linuxpowertop.org/faq.php faq].&lt;br /&gt;
&lt;br /&gt;
Alternatively (or complementary) to PowerTOP, running &amp;lt;code&amp;gt;strace -p $(pidof yourapp)&amp;lt;/code&amp;gt; &lt;br /&gt;
for all your favorite or background running applications while they are expected to be &lt;br /&gt;
idle, will show the misbehaviors.&lt;br /&gt;
&lt;br /&gt;
Beside CPU wakeups, disks spins are also power angry. To detect what make your disk spinning,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 sysctl vm.block_dump=1&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will list all applications causing disks wakeups on the kernel's dmesg.&lt;br /&gt;
Other useful tools for this purpose are blktrace, iostat and lm-profiler&lt;br /&gt;
(from laptop-mode-tools suite).&lt;br /&gt;
&lt;br /&gt;
See also [[#Misbehaving Userland]].&lt;br /&gt;
&lt;br /&gt;
==BIOS settings==&lt;br /&gt;
Some Thinkpad BIOS (like 2.08 BIOS on {{X40}}) offer two very lame options,&lt;br /&gt;
with a very misleading online help (saying &amp;quot;Usually not needed&amp;quot;). That's&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 CPU power management: (default disabled)&lt;br /&gt;
 PCI bus power management: (default disabled)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should indeed enable them, else the deepest C3 and C4 ACPI C-states&lt;br /&gt;
are disabled.&lt;br /&gt;
&lt;br /&gt;
==CPU==&lt;br /&gt;
Look at:&lt;br /&gt;
* [[How to make use of Dynamic Frequency Scaling]]&lt;br /&gt;
* [[Pentium M undervolting and underclocking]]&lt;br /&gt;
&lt;br /&gt;
A good thing to keep in mind is that every CPU wakeup, even if it's for&lt;br /&gt;
a trivial light job, reduce the time the CPU stays on a deep power&lt;br /&gt;
saving C-state (like C3 or C4). Therefore you should ensure your applications&lt;br /&gt;
stay really idle when they meant to be idle (track shorts select timeouts&lt;br /&gt;
in loop, etc. with [[PowerTOP]]).&lt;br /&gt;
&lt;br /&gt;
Also note that manually locking the CPU in the lowest P-state (frequency) &lt;br /&gt;
available is '''not''' an efficient way to improve battery lifetime. This will&lt;br /&gt;
cause the CPU to stay longer in C0 (power angry C-state) doing hard work when &lt;br /&gt;
there is something to do, while it could have done this work faster by augmenting&lt;br /&gt;
the CPU freq, and returned back faster to a deeper, economic, C-state and to a&lt;br /&gt;
lower frequency (P-state).&lt;br /&gt;
The best is to let the kernel select the appropriates CPU frequencies by itself&lt;br /&gt;
with the help of in kernel CPU governors.&lt;br /&gt;
Have a look at [http://www.bughost.org/pipermail/power/2007-May/000166.html this explanation]&lt;br /&gt;
from Intel's kernel developer Arjan van de Ven.&lt;br /&gt;
&lt;br /&gt;
==Kernel settings and patches==&lt;br /&gt;
&lt;br /&gt;
===General settings===&lt;br /&gt;
The 2.6.21 kernel brought some very effective changes (like dynticks). If&lt;br /&gt;
it's not already on your distribution and you value power efficiency, you&lt;br /&gt;
may think about compiling it (or a more recent one) yourself.&lt;br /&gt;
&lt;br /&gt;
Here are a few options (beside the ACPI and APM related one) that matter to &lt;br /&gt;
reduce power consumption or to help diagnosing consumers:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 # From PowerTOP's FAQ:&lt;br /&gt;
 CONFIG_NO_HZ&lt;br /&gt;
 CONFIG_HIGH_RES_TIMERS&lt;br /&gt;
 CONFIG_HPET&lt;br /&gt;
 CONFIG_HPET_TIMER&lt;br /&gt;
 CONFIG_CPU_FREQ_GOV_ONDEMAND&lt;br /&gt;
 CONFIG_USB_SUSPEND&lt;br /&gt;
 CONFIG_SND_AC97_POWER_SAVE&lt;br /&gt;
 CONFIG_TIMER_STATS&lt;br /&gt;
 CONFIG_ACPI_BATTERY&lt;br /&gt;
 CONFIG_CPU_FREQ_STAT&lt;br /&gt;
 CONFIG_INOTIFY&lt;br /&gt;
&lt;br /&gt;
 # Not from the PowerTOP FAQ:&lt;br /&gt;
 CONFIG_BLK_DEV_IO_TRACE&lt;br /&gt;
 CONFIG_X86_ACPI_CPUFREQ&lt;br /&gt;
 CONFIG_X86_SPEEDSTEP_CENTRINO&lt;br /&gt;
 CONFIG_X86_SPEEDSTEP_ICH&lt;br /&gt;
 CONFIG_X86_SPEEDSTEP_SMI&lt;br /&gt;
 CONFIG_CPU_IDLE&lt;br /&gt;
 CONFIG_CPU_IDLE_GOV_LADDER&lt;br /&gt;
 CONFIG_CPU_IDLE_GOV_MENU&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Those options are already in Fedora Core 7 and Ubuntu Gutsy (not Feisty) default i686 kernels.&lt;br /&gt;
PowerTOP FAQ also suggest to '''disable'''&lt;br /&gt;
CONFIG_IRQBALANCE and CONFIG_ACPI_DEBUG.&lt;br /&gt;
&lt;br /&gt;
Also, you need to properly set APM and ACPI. Look at:&lt;br /&gt;
* [[Power Management]]&lt;br /&gt;
* [[How to make use of Power Management features]]&lt;br /&gt;
&lt;br /&gt;
===Useful Patches===&lt;br /&gt;
&lt;br /&gt;
Thomas Gleixner High Resolution Timers (hrt) patchset brings many improvements,&lt;br /&gt;
like the cpuidle work and Udo A. Steinberg and Venki Pallipadi &amp;quot;force&lt;br /&gt;
enable HPET&amp;quot; patches (non HPET timers causes about 20-40 CPU wakeups/second, but&lt;br /&gt;
HPET is often hidden by the BIOS due to Windows XP deficiencies). Those are &lt;br /&gt;
fully merged in 2.6.24-rc1 vanilla kernel.&lt;br /&gt;
See http://www.tglx.de/projects/hrtimers/&lt;br /&gt;
&lt;br /&gt;
Kristen Carlson Accardi from Intel has a patchset to turn on &amp;quot;Aggressive&lt;br /&gt;
Link Power Management&amp;quot; (ALPM) for the AHCI driver (for SATA bus). See:&lt;br /&gt;
http://www.kernel.org/pub/linux/kernel/people/kristen/patches/SATA/alpm/&lt;br /&gt;
&lt;br /&gt;
The [[HDAPS]] disk protection systems can reduce battery life. &lt;br /&gt;
Matthew Garrett provides [http://www.linuxpowertop.org/patches/hdaps.patch a patch]&lt;br /&gt;
that prevents hdaps kernel module to generate interrupts when&lt;br /&gt;
this feature isn't used.&lt;br /&gt;
&lt;br /&gt;
===Useful sysctls===&lt;br /&gt;
The meaning of those settings is explained case by case on the relevant &lt;br /&gt;
sections of this document. But for convenience sake, we group them here too.&lt;br /&gt;
&lt;br /&gt;
Note that the &amp;quot;ondemand&amp;quot; scaling governor is recommended by Intel developers&lt;br /&gt;
for energy efficiency: it's expected to be more efficient than the &amp;quot;powersave&amp;quot;&lt;br /&gt;
governor, or than userspace daemons (like cpufreq-utils, cpufreqd, powernowd...).&lt;br /&gt;
Look [http://www.bughost.org/pipermail/power/2007-May/000071.html here],&lt;br /&gt;
[http://www.bughost.org/pipermail/power/2007-May/000073.html here], or&lt;br /&gt;
[http://www.bughost.org/pipermail/power/2007-May/000166.html here] for a&lt;br /&gt;
kernel developer explanation about &amp;quot;ondemand&amp;quot; being better on modern Intel CPUs.&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;link_power_management_policy&amp;quot; tunable won't be available unless you&lt;br /&gt;
run a 2.6.24-rc2 or more kernel, or applied Kirsten patchset, have an Intel &lt;br /&gt;
AHCI compatible chipset, and use SATA drives.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 echo 5 &amp;gt; /proc/sys/vm/laptop_mode&lt;br /&gt;
 echo 0 &amp;gt; /proc/sys/kernel/nmi_watchdog&lt;br /&gt;
 echo Y &amp;gt; /sys/module/snd_ac97_codec/parameters/power_save&lt;br /&gt;
 echo 1 &amp;gt; /sys/devices/system/cpu/sched_mc_power_savings&lt;br /&gt;
 echo ondemand &amp;gt; /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor&lt;br /&gt;
 echo 1500 &amp;gt; /proc/sys/vm/dirty_writeback_centisecs&lt;br /&gt;
 # those sysctl's are only available if you have an AHCI compatible SATA &lt;br /&gt;
 # controler and use kernel &amp;gt; 2.6.24-rc2 (or use Kristen ALPM patchset) : &lt;br /&gt;
 echo min_power &amp;gt; /sys/class/scsi_host/host0/link_power_management_policy&lt;br /&gt;
 echo min_power &amp;gt; /sys/class/scsi_host/host1/link_power_management_policy&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're running a kernel older than 2.6.22 do this. Not needed for kernels 2.6.22 onward:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 cd /sys/devices/system/cpu/cpu0/cpufreq&lt;br /&gt;
 cat ondemand/sampling_rate_max &amp;gt; ondemand/sampling_rate&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==ATA drives==&lt;br /&gt;
Hard drives and CDRom drives spinning is very costly. To improve battery&lt;br /&gt;
lifetime, you should reduce disks access (or devices polling) the more you&lt;br /&gt;
can.  &lt;br /&gt;
&lt;br /&gt;
===Hard Drives===&lt;br /&gt;
The files access time update, while mandated by POSIX, is causing lots of&lt;br /&gt;
disks access; even accessing files on disk cache may wake the ATA or USB&lt;br /&gt;
bus. If you don't use this feature, disable it via:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 mount -o remount,noatime /  # and so on for all mounted fs&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The laptop_mode reduce disk usage by regrouping writes. You should enable&lt;br /&gt;
it, at least while on battery. See [[Laptop-mode]] for more details:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 echo 5 &amp;gt; /proc/sys/vm/laptop_mode&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default kernel dirty page writeback frequency is very conservative. On&lt;br /&gt;
a laptop running on battery, one might find more appropriate to reduce it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 echo 1500 &amp;gt; /proc/sys/vm/dirty_writeback_centisecs&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some power saving hard drives features can be activated with hdparm (beware&lt;br /&gt;
that &amp;quot;-B 1&amp;quot; may reduce your drive lifetime, if you have lot of intermittent&lt;br /&gt;
disk activity causing lots of heads load/unloads: so reduce I/O activity first,&lt;br /&gt;
as explained above, in order to get longer disks idling periods).&lt;br /&gt;
For more details look at [[How to make use of Power Management features]] :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
 hdparm -B 1 -S 12 /dev/sda # and/or any other disk device&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Optical drive===&lt;br /&gt;
The optical drive is reported to consume power even when not accessed. See &lt;br /&gt;
&lt;br /&gt;
* [[How to hotswap UltraBay devices|Eject the UltraBay optical drive]], or just turn off its power supply (i.e., run the appropriate eject script but leave the drive inserted).&lt;br /&gt;
* [[How to set optical drive speed|Reduce the spinning speed of the optical drive]].&lt;br /&gt;
&lt;br /&gt;
The hald daemon polling tends to maintain the ATA buses out of power saving&lt;br /&gt;
modes, and to wakeup CDROM drive (except if you have a kernel &amp;gt;= 2.6.24, hal &amp;gt;= 0.5.10,&lt;br /&gt;
and SATA AN compatible devices). If you have a recent hald version, you&lt;br /&gt;
can stop this polling when on battery:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 hal-disable-polling /dev/scd0 # or whatever your CD drive is&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your hald is not recent enough, consider suspending it when running on battery. Some moderns SATA buses and drivers supports a notification mechanism (SATA AN - Asynchronous Events Notifications) that obsolete the need for polling on modern hardware; support for this feature had been merged in Linux 2.6.24-rc1 and HAL 0.5.10.&lt;br /&gt;
&lt;br /&gt;
==LCD Backlight/Brightness==&lt;br /&gt;
The LCD backlight is one of the very major power drain. &lt;br /&gt;
Reducing brightness to the lowest readable&lt;br /&gt;
level will save a lot of battery lifetime. Also, don't forget to configure&lt;br /&gt;
your screen saver to shutdown the screen backlight (rather than displaying some&lt;br /&gt;
eye candy), when no activity for a few minutes.&lt;br /&gt;
&lt;br /&gt;
You can also let the system [[automatically reduce brightness]] after a &lt;br /&gt;
period of inactivity.&lt;br /&gt;
&lt;br /&gt;
If you're choosing your Thinkpad laptop model, keep in mind that the screen&lt;br /&gt;
size affect the battery time greatly: more power needed for larger screens.&lt;br /&gt;
&lt;br /&gt;
The very recent, but xorg standard way to control backlight from CLI is&lt;br /&gt;
using xbacklight. ie. to set backlight at half the brightness:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 xbacklight -set 50&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should configure the DPMS to shutdown the screen when idle (rather than&lt;br /&gt;
displaying a fancy but power consuming screensaver). ie. to turn off the&lt;br /&gt;
display after 5mn of idling:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 xset +dpms&lt;br /&gt;
 xset dpms 0 0 300&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Graphic controllers==&lt;br /&gt;
All xorg Thinkpad graphics chipsets drivers (ati, radeon, fglrx, i810) have&lt;br /&gt;
the same bug causing very frequent CPU wakeups when DRI is activated, even&lt;br /&gt;
when you don't use any 3D application.&lt;br /&gt;
This problem is partly fixed on xorg git tree but not released as of xorg&lt;br /&gt;
7.2. If you value more battery than 3D, you should disable DRI: put this on&lt;br /&gt;
the /etc/X11/xorg.conf &amp;quot;Device&amp;quot; of you graphic controller:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 Option          &amp;quot;NoDRI&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also be sure that DPMS is working: &amp;lt;code&amp;gt;grep DPMS /var/log/Xorg.0.log&amp;lt;/code&amp;gt;&lt;br /&gt;
should output &amp;quot;DPMS enabled&amp;quot;. If not, put &amp;lt;code&amp;gt;Option &amp;quot;DPMS&amp;quot;&amp;lt;/code&amp;gt; in your config.&lt;br /&gt;
See the section above about how to enable dpms driven display power saving.&lt;br /&gt;
&lt;br /&gt;
On recent xrandr/xorg versions, you can disable the TV output (or any other detected&lt;br /&gt;
as connected but not used outputs) when you're not using it: it's known to consume power. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
 xrandr # see all displays listed here, but that you don't actually use and disable them. &lt;br /&gt;
 xrandr --output TV -off # for instance (if &amp;quot;xrandr&amp;quot; above listed a connected output named &amp;quot;TV&amp;quot; that you don't use)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you don't have an external monitor plugged, disable CRT and DVI output &lt;br /&gt;
(for some, this can make a difference in power usage) : &lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
 echo crt_disable &amp;gt; /proc/acpi/ibm/video&lt;br /&gt;
 echo dvi_disable &amp;gt; /proc/acpi/ibm/video&lt;br /&gt;
&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Some drivers have specials power saving mode, and/or allows underclocking the GPU. See also:&lt;br /&gt;
* [[How to make use of Graphics Chips Power Management features]], or with [[Rovclock]] on ATI.&lt;br /&gt;
* [[Problem with high power drain in ACPI sleep]]&lt;br /&gt;
&lt;br /&gt;
==USB Subsystem==&lt;br /&gt;
The kernel support an efficient USB 2.0 power saving feature if you enabled&lt;br /&gt;
CONFIG_USB_SUSPEND. This may not trigger in when you have an USB device&lt;br /&gt;
plugged (and beside, USB devices tends to suck power on their own), so avoid&lt;br /&gt;
using such devices when on battery. And you must enable it, either a boot time &lt;br /&gt;
by adding this in the kernel boot options (ie. in grub's menu.lst):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 usbcore.autosuspend=1&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or at runtime, per device, with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 for i in /sys/bus/usb/devices/%s/power/autosuspend; do echo 1 &amp;gt; $i; done&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
USB 1.1 is worst. It needs polling the bus frequently, hence can't really go&lt;br /&gt;
in a low power mode when you enabled it, even if you don't have any device&lt;br /&gt;
plugged. You'd better remove it when you don't use a 1.1 device:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 rmmod uhci_hcd&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don't intend to use any device needing USB 1.1 (unfortunately, the built-in bluetooth and fingerprint-reader are USB 1.1 devices), the USB 1.1 support can also be totaly avoided. On Debian and derivatives, just do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 echo &amp;quot;blacklist uhci_hcd&amp;quot; &amp;gt;&amp;gt; /etc/modprobe.d/blacklist&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Sound==&lt;br /&gt;
ALSA has a power saving feature that should be enabled on your kernel&lt;br /&gt;
(CONFIG_SND_AC97_POWER_SAVE). Note that this low power mode won't trigger in&lt;br /&gt;
unless you muted all sound inputs (micro, line in etc.). This feature has&lt;br /&gt;
to be activated with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 amixer set Line mute nocap&lt;br /&gt;
 amixer set Mic mute nocap&lt;br /&gt;
 echo Y &amp;gt; /sys/module/snd_ac97_codec/parameters/power_save&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More radical: you can unload all sound related modules when you are on &lt;br /&gt;
battery, or mute the sound system (echo mute &amp;gt; /proc/acpi/ibm/volume).&lt;br /&gt;
&lt;br /&gt;
Seel also [[How to enable AC97 power saving]].&lt;br /&gt;
&lt;br /&gt;
==Wireless Interface==&lt;br /&gt;
Wireless network consume a lot of power.&lt;br /&gt;
To save power, you can kill the Wi-Fi radio when it's not in use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 echo 1 &amp;gt; /sys/bus/pci/devices/*/rf_kill&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you need Wi-Fi, you can also reduce power consumption (at the price of&lt;br /&gt;
performances) by activating the power saving modes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 iwpriv eth1 set_power 5&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For drivers using the new Wi-Fi kernel framework (mac80211/cfg80211), &lt;br /&gt;
the canonical way to do this is now:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 for i in /sys/bus/pci/devices/*/power_level ; do echo 5 &amp;gt; $i ; done&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Most drivers, like ipw2200, that don't use the new mac80211 framework place the&lt;br /&gt;
interfaces in aggressive scanning mode when they are not associated with any &lt;br /&gt;
Access Point, even when the interface is down (more info about this on Intel's&lt;br /&gt;
[http://www.lesswatts.org/tips/wireless.php LessWatts] website).&lt;br /&gt;
This behavior consumes a lot of power, even more than when the interface&lt;br /&gt;
is plain active and in use. But this can disabled at module's load time :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 rmmod ipw2200&lt;br /&gt;
 modprobe ipw2200 associate=0&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can fix this setting by placing the following in /etc/modprobe.d/options &lt;br /&gt;
(Debian/Ubuntu) or in /etc/modprobe.conf (Red Hat/Fedora):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 options ipw2200 associate=0&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reducing beacon intervals on your Access Point to 1 per second will also&lt;br /&gt;
reduce network card interrupts, therefore power savings. This shouldn't have&lt;br /&gt;
negatives side effects.&lt;br /&gt;
&lt;br /&gt;
See also, to activate power saving on the wireless network card:&lt;br /&gt;
* For [[Intel PRO/Wireless 2200BG Mini-PCI Adapter]] and [[Intel PRO/Wireless 2915ABG Mini-PCI Adapter]], see instructions for the [[ipw2200]] driver.&lt;br /&gt;
* For [[Intel PRO/Wireless 3945ABG Mini-PCI Express Adapter]], see the [http://ipw3945.sourceforge.net/README.ipw3945 ipw3945 driver README]&lt;br /&gt;
&lt;br /&gt;
==Ethernet Controler==&lt;br /&gt;
If you don't use Wake-on-LAN, you should disable it for your network card,&lt;br /&gt;
because it sucks a lot of power:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ethtool -s eth0 wol d&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you can, try to reduce useless network activity on your ethernet&lt;br /&gt;
segment, coming to your NIC (ie. uneeded broadcasts), those cause &lt;br /&gt;
interrupts and CPU wakeups.&lt;br /&gt;
&lt;br /&gt;
Forcing 100Mbps full-duplex speed on a gigabit ethernet NIC can also save a lot of power (~1W) on most network workloads. This also reduces components temperature (e.g., [[Thermal Sensors|thermal sensor]] 0xC0 on the {{T43}} cools down by 5 degree between 1000Mbps and 100Mbps, and another 1 degree for 10Mbps).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  ethtool -s eth0 autoneg off speed 100&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note, however, that if the network device on the other side has auto-negotiation enabled (which is very common) and you turn auto-negotiation off, the other side will assume half-duplex mode and you will experience a significant loss of performance.&lt;br /&gt;
&lt;br /&gt;
==Bluetooth==&lt;br /&gt;
When you don't need bluetooth, disable it. Because of its radio, &lt;br /&gt;
bluetooth is not power friendly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 hciconfig hci0 down ; rmmod hci_usb&lt;br /&gt;
 echo disable &amp;gt; /proc/acpi/ibm/bluetooth&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Modem==&lt;br /&gt;
When was the last time you used your analog modem? If you can't remember, you probably just don't need it. If it is on a separate module in your laptop, simply remove it. Store it in a ESD safe place (like the bag in which your last addon card or hard drive was packed), in case you should need it again. This won't save you a lot of power and weight, but why carry something around you never use.&lt;br /&gt;
&lt;br /&gt;
==System Fans==&lt;br /&gt;
Fans consumes power when running, so you may look at the [[ACPI fan control script]].&lt;br /&gt;
&lt;br /&gt;
==Misbehaving Userland==&lt;br /&gt;
You should avoid using Beagle, Compiz, Beryl, XMMS, gnome-power-manager&lt;br /&gt;
and Evolution while on battery.&lt;br /&gt;
Look at the PowerTOP's [http://www.linuxpowertop.org/known.php known problems]&lt;br /&gt;
list.&lt;br /&gt;
&lt;br /&gt;
Deactivate desktop animations (blinking cursor on the terms, animated wallpapers, ...): they cause regular X (therefore kernel and CPU) wakeups.&lt;br /&gt;
&lt;br /&gt;
In short, while on battery, you should stop all applications that don't really stay idle when you're not using them. This means applications that:&lt;br /&gt;
* Wakes up the CPU too often (by polling something, because of too short select() timeouts, ...)&lt;br /&gt;
* Access the disks at regular intervals&lt;br /&gt;
* Access an hardware bus (USB, ATA, ...) at regular intervals&lt;br /&gt;
To find those offenders run:&lt;br /&gt;
* &amp;lt;code&amp;gt;strace -p $(pidof yourapp)&amp;lt;/code&amp;gt; # for all your running applications&lt;br /&gt;
* &amp;lt;code&amp;gt;powertop&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;sysctl vm.block_dump=1&amp;lt;/code&amp;gt; # and look at dmesg&lt;br /&gt;
* &amp;lt;code&amp;gt;ps aux | awk '{print$10,$11}' | sort -n&amp;lt;/code&amp;gt; # will list all running softs sorted by used cpu time&lt;br /&gt;
Please, don't forget to fill a bug when you find such a misbehaving software.&lt;br /&gt;
{{NOTE|Not all software is evil, buggy or badly written. Some produce regular activity because they have to, in order to provide their intented functionality.  Think twice before filling bugs about this.}}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[How to measure power consumption]]&lt;br /&gt;
* [[Script for monitoring power consumption]]&lt;br /&gt;
* Battery [[maintenance]]&lt;br /&gt;
&lt;br /&gt;
==External resources==&lt;br /&gt;
* [http://www.free-it.de/archiv/talks_2005/paper-11017/paper-11017.html ''Current trends in Linux Kernel Power Management''], Dominik Brodowski, 2005&lt;br /&gt;
* [http://www.linuxpowertop.org PowerTOP] website&lt;br /&gt;
* [http://www.gentoo.org/doc/en/power-management-guide.xml Power Management Guide] from the Gentoo Linux documentation&lt;br /&gt;
* [http://mailman.linux-thinkpad.org/pipermail/linux-thinkpad/2005-November/030478.html When/where/what for low power consumption?] (thread on Linux-Thinkpad)&lt;br /&gt;
* ''8 hours of battery life on your lap(top)'' ([http://atrey.karlin.mff.cuni.cz/~pavel/swsusp/8hours.odp ODP]/[http://atrey.karlin.mff.cuni.cz/~pavel/swsusp/8hours.pdf PDF]), a presentation by Pavel Machek&lt;br /&gt;
* [http://www.lesswatts.org Website dedicated to save energy on Intel systems using Linux]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:600X]] [[Category:A20m]] [[Category:A20p]] [[Category:A21e]] [[Category:A21m]] [[Category:A21p]] [[Category:A22e]] [[Category:A22m]] [[Category:A22p]] [[Category:A30]] [[Category:A30p]] [[Category:A31]] [[Category:A31p]] [[Category:i1200]] [[Category:i1300]] [[Category:i1620]] [[Category:G40]] [[Category:G41]] [[Category:R30]] [[Category:R31]] [[Category:R32]] [[Category:R40]] [[Category:R40e]] [[Category:R50]] [[Category:R50e]] [[Category:R50p]] [[Category:R51]] [[Category:R52]] [[Category:R60]] [[Category:R60e]] [[Category:T20]] [[Category:T21]] [[Category:T22]] [[Category:T23]] [[Category:T30]] [[Category:T40]] [[Category:T40p]] [[Category:T41]] [[Category:T41p]] [[Category:T42]] [[Category:T42p]] [[Category:T43]] [[Category:T43p]] [[Category:T60]] [[Category:T60p]] [[Category:T61]] [[Category:X20]] [[Category:X21]] [[Category:X22]] [[Category:X23]] [[Category:X24]] [[Category:X30]] [[Category:X31]] [[Category:X32]] [[Category:X40]] [[Category:X41]] [[Category:X41 Tablet]] [[Category:X60]] [[Category:X60s]] [[Category:Z60m]] [[Category:Z60t]] [[Category:Z61t]] [[Category:Z61e]] [[Category:TransNote]]&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34381</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34381"/>
		<updated>2007-11-09T17:26:53Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This setup will let you use fn-F7 key combination to toggle between internal, external, or both screens.  Tested on ThinkPad X60s running Fedora 8.&lt;br /&gt;
&lt;br /&gt;
Note: you will need to change the internal and external resolution until someone fixes this script to figure it out from xrandr, you may also need to change output names from &amp;quot;VGA&amp;quot; and &amp;quot;LVDS&amp;quot; to what your xrandr tells you.&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
# fn-F7&lt;br /&gt;
event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#@ seva sevatech.com&lt;br /&gt;
&lt;br /&gt;
EXTERNAL_OUTPUT=VGA&lt;br /&gt;
EXTERNAL_MODE=1600x1200&lt;br /&gt;
&lt;br /&gt;
INTERNAL_OUTPUT=LVDS&lt;br /&gt;
INTERNAL_MODE=1024x768&lt;br /&gt;
&lt;br /&gt;
DO=$(basename $0)&lt;br /&gt;
&lt;br /&gt;
SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
&lt;br /&gt;
STATE_FILE=/var/lib/thinkpad/screen.state;&lt;br /&gt;
if [ ! -e $STATE_FILE ]; then&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
STATE=$(cat $STATE_FILE)&lt;br /&gt;
&lt;br /&gt;
function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --mode $EXTERNAL_MODE --left-of LVDS&amp;quot;&lt;br /&gt;
        echo &amp;quot;external&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --mode $INTERNAL_MODE --right-of VGA&amp;quot;&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --mode $EXTERNAL_MODE --left-of LVDS&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --mode $INTERNAL_MODE --right-of VGA&amp;quot;&lt;br /&gt;
        echo &amp;quot;both&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        thinkpad-fn-f7)&lt;br /&gt;
                case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                        internal)&lt;br /&gt;
                                screen_external&lt;br /&gt;
                                ;;&lt;br /&gt;
                        external)&lt;br /&gt;
                                screen_both&lt;br /&gt;
                                ;;&lt;br /&gt;
                        both)&lt;br /&gt;
                                screen_internal&lt;br /&gt;
                                ;;&lt;br /&gt;
                        *)&lt;br /&gt;
                                screen_internal&lt;br /&gt;
                                ;;&lt;br /&gt;
                esac&lt;br /&gt;
                ;;&lt;br /&gt;
        thinkpad-internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        thinkpad-external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        thinkpad-both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: rename to thinkpad-internal, thinkpad-external, or thinkpad-both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As root,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mkdir -p /var/lib/thinkpad&lt;br /&gt;
echo &amp;quot;internal&amp;quot; &amp;gt; /var/lib/thinkpad/screen.state&lt;br /&gt;
chmod 755 /usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
service acpid restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34380</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34380"/>
		<updated>2007-11-09T17:15:53Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This setup will let you use fn-F7 key combination to toggle between internal, external, or both screens.  Tested on ThinkPad X60s running Fedora 8.&lt;br /&gt;
&lt;br /&gt;
Note: you will need to change the internal and external resolution until someone fixes this script to figure it out from xrandr, you may also need to change output names from &amp;quot;VGA&amp;quot; and &amp;quot;LVDS&amp;quot; to what your xrandr tells you.&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
# fn-F7&lt;br /&gt;
event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
EXTERNAL_OUTPUT=VGA&lt;br /&gt;
EXTERNAL_MODE=1600x1200&lt;br /&gt;
&lt;br /&gt;
INTERNAL_OUTPUT=LVDS&lt;br /&gt;
INTERNAL_MODE=1024x768&lt;br /&gt;
&lt;br /&gt;
DO=$(basename $0)&lt;br /&gt;
&lt;br /&gt;
SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
&lt;br /&gt;
STATE_FILE=/var/lib/thinkpad/screen.state;&lt;br /&gt;
if [ ! -e $STATE_FILE ]; then&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
STATE=$(cat $STATE_FILE)&lt;br /&gt;
&lt;br /&gt;
function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --mode $EXTERNAL_MODE --left-of LVDS&amp;quot;&lt;br /&gt;
        echo &amp;quot;external&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --mode $INTERNAL_MODE --right-of VGA&amp;quot;&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --mode $EXTERNAL_MODE --left-of LVDS&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --mode $INTERNAL_MODE --right-of VGA&amp;quot;&lt;br /&gt;
        echo &amp;quot;both&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        thinkpad-fn-f7)&lt;br /&gt;
                case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                        internal)&lt;br /&gt;
                                screen_external&lt;br /&gt;
                                ;;&lt;br /&gt;
                        external)&lt;br /&gt;
                                screen_both&lt;br /&gt;
                                ;;&lt;br /&gt;
                        both)&lt;br /&gt;
                                screen_internal&lt;br /&gt;
                                ;;&lt;br /&gt;
                        *)&lt;br /&gt;
                                screen_internal&lt;br /&gt;
                                ;;&lt;br /&gt;
                esac&lt;br /&gt;
                ;;&lt;br /&gt;
        thinkpad-internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        thinkpad-external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        thinkpad-both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: rename to thinkpad-internal, thinkpad-external, or thinkpad-both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As root,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mkdir -p /var/lib/thinkpad&lt;br /&gt;
echo &amp;quot;internal&amp;quot; &amp;gt; /var/lib/thinkpad/screen.state&lt;br /&gt;
chmod 755 /usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
service acpid restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34379</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34379"/>
		<updated>2007-11-09T17:14:05Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This setup will let you use fn-F7 key combination to toggle between internal, external, or both screens.  Tested on ThinkPad X60s running Fedora 8.&lt;br /&gt;
&lt;br /&gt;
Note: you will need to change the internal and external resolution until someone fixes this script to figure it out from xrandr, you may also need to change output names from &amp;quot;VGA&amp;quot; and &amp;quot;LVDS&amp;quot; to what your xrandr tells you.&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
# fn-F7&lt;br /&gt;
event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
action=/usr/local/sbin/thinkpad-fn-f7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-fn-f7:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
EXTERNAL_OUTPUT=VGA&lt;br /&gt;
EXTERNAL_MODE=1600x1200&lt;br /&gt;
&lt;br /&gt;
INTERNAL_OUTPUT=LVDS&lt;br /&gt;
INTERNAL_MODE=1024x768&lt;br /&gt;
&lt;br /&gt;
DO=$(basename $0)&lt;br /&gt;
&lt;br /&gt;
SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
&lt;br /&gt;
STATE_FILE=/var/lib/thinkpad/screen.state;&lt;br /&gt;
if [ ! -e $STATE_FILE ]; then&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
STATE=$(cat $STATE_FILE)&lt;br /&gt;
&lt;br /&gt;
function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --mode $EXTERNAL_MODE --left-of LVDS&amp;quot;&lt;br /&gt;
        echo &amp;quot;external&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --mode $INTERNAL_MODE --right-of VGA&amp;quot;&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --mode $EXTERNAL_MODE --left-of LVDS&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --mode $INTERNAL_MODE --right-of VGA&amp;quot;&lt;br /&gt;
        echo &amp;quot;both&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        thinkpad-fn-f7)&lt;br /&gt;
                case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                        internal)&lt;br /&gt;
                                screen_external&lt;br /&gt;
                                ;;&lt;br /&gt;
                        external)&lt;br /&gt;
                                screen_both&lt;br /&gt;
                                ;;&lt;br /&gt;
                        both)&lt;br /&gt;
                                screen_internal&lt;br /&gt;
                                ;;&lt;br /&gt;
                        *)&lt;br /&gt;
                                screen_internal&lt;br /&gt;
                                ;;&lt;br /&gt;
                esac&lt;br /&gt;
                ;;&lt;br /&gt;
        thinkpad-internal)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        thinkpad-external)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        thinkpad-both)&lt;br /&gt;
                screen_both&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: rename to thinkpad-internal, thinkpad-external, or thinkpad-both&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As root,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mkdir -p /var/lib/thinkpad&lt;br /&gt;
echo &amp;quot;internal&amp;quot; &amp;gt; /var/lib/thinkpad/screen.state&lt;br /&gt;
chmod 755 /usr/local/sbin/thinkpad-f7&lt;br /&gt;
service acpid restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=How_to_get_special_keys_to_work&amp;diff=34378</id>
		<title>How to get special keys to work</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=How_to_get_special_keys_to_work&amp;diff=34378"/>
		<updated>2007-11-09T17:12:31Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
The following table gives an overview over the special keys found on ThinkPads and what is needed to make them work.&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
! key !! standard function{{footnote|1}} !! tools supporting key{{footnote|2}} !! configurability{{footnote|3}} !! remarks&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}} || - || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || on release without completed key combination&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F1}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F2}} || lock screen || [[#ibm-acpi events|ibm-acpi]] || full || in models from T/X/Z 60 onwards&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F3}} || blank screen || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F4}} || suspend to ram || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]] || full || may generate ACPI event when not enabled in the ibm-acpi hotkey mask&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F5}} || switch bluetooth || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]] || full || in models starting from 2002&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F6}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F7}} || toggle display || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]], [[#tpb configuration|tpb]] || additional actions || [[Sample fn-F7 script]]&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F8}} || toggle trackpoint/touchpad || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]], [[#tpb configuration|tpb]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F9}} || eject from dock || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F10}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F11}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F12}} || hibernate || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]] || full || may generate ACPI event when not enabled in the ibm-acpi hotkey mask&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Home}} / {{key|Fn}}{{key|Pos1}} || brightness up || [[#ibm-acpi events|ibm-acpi]], [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|End}} || brightness down || [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|PageUp}} || toggle thinklight || [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Space}} || toggle zoom || [[#tpb configuration|tpb]], [[KMilo]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Ins}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Del}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Backspace}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|NumLock}} || - || [[#xmodmap configuration|xmodmap]] || make working ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Windows}} || - || [[#xmodmap configuration|xmodmap]] || remapping ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Access IBM|#495988}} or {{ibmkey|ThinkPad|#494949}} or {{ibmkey|ThinkVantage|#495988}} || help application || [[#tpb configuration|tpb]], [[KMilo]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Home|#494949}} || open web browser || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]], [[KMilo]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Search|#494949}} || open search application || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]], [[KMilo]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Mail|#494949}} || open mail application || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]], [[KMilo]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Favorites|#494949}} || open favorites || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Reload|#494949}} || reload web page || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Abort|#494949}} || abort loading page || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Backward|#494949}} || previous page || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full ||  ext. keyboards and ThinkPads starting from 2002&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Forward|#494949}} || next page || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || ext. keyboards and ThinkPads starting from 2002&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume up|#494949}} || volume up || [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume down|#494949}} || volume down || [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume mute|#494949}} || mute volume || [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Play/Pause|#494949}} || start/pause playback  || [[#xmodmap configuration|xmodmap]] || full || {{X60s}} (Fn+Arrow Down)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Stop|#494949}} || stop playback || [[#xmodmap configuration|xmodmap]] || full || {{X60s}} (Fn+Arrow Up)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Next|#494949}} || play next || [[#xmodmap configuration|xmodmap]] || full || {{X60s}} (Fn+Arrow Right)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Previous|#494949}} || play previous || [[#xmodmap configuration|xmodmap]] || full || {{X60s}} (Fn+Arrow Left)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Power|#494949}} || shutdown || [[#ibm-acpi events|ibm-acpi]] || full || triggered on pressing 3secs, but notebook goes off on 5sec press&lt;br /&gt;
|-&lt;br /&gt;
| Display lid || blank screen || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| Ultrabay lid || announce ultrabay change || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| Dock eject || eject from dock || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet power|#494949}} || shutdown || [[#ibm-acpi events|ibm-acpi]] || full || triggered on pressing 3secs, but notebook goes off on 5sec press&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet orientation|#494949}} || rotates screen || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet shortcut|#494949}} || shortcut menu || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Esc|#494949}} || esc key || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Enter|#494949}} || enter key || [[#mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Up|#494949}} || up key || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Down|#494949}} || down key || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet (unlabeled)|#494949}} || down key || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Triggering key events==&lt;br /&gt;
===ibm-acpi events===&lt;br /&gt;
Some of the following events require a {{cmdroot|echo enable,0xffff &amp;gt;/proc/acpi/ibm/hotkey}} in order to make acpi able to get information on them. These events can be used to [[How to configure acpid|configure acpid]].&lt;br /&gt;
&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
|+ events triggered by [[ibm-acpi]] for {{path|/etc/acpi/events}} files. &lt;br /&gt;
! key !! event&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F1}} || ibm/hotkey HKEY 00000080 00001001&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F2}} || ibm/hotkey HKEY 00000080 00001002&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F3}} || ibm/hotkey HKEY 00000080 00001003&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F4}} || ibm/hotkey HKEY 00000080 00001004&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F5}} || ibm/hotkey HKEY 00000080 00001005&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F6}} || ibm/hotkey HKEY 00000080 00001006&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F7}} || ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F8}} || ibm/hotkey HKEY 00000080 00001008&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F9}} || ibm/hotkey HKEY 00000080 00001009&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F10}} || ibm/hotkey HKEY 00000080 0000100a&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F11}} || ibm/hotkey HKEY 00000080 0000100b&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F12}} || ibm/hotkey HKEY 00000080 0000100c&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Backspace}} || ibm/hotkey HKEY 00000080 0000100d&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Ins}} || ibm/hotkey HKEY 00000080 0000100e&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Del}} || ibm/hotkey HKEY 00000080 0000100f&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Home}}/{{key|Fn}}{{key|Pos1}} || ibm/hotkey HKEY 00000080 00001010&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|ThinkVantage|#495988}} ||ibm/hotkey HKEY 00000080 00001018&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Power|#494949}} || button/power PWRF 00000080 xxxxxxxx&lt;br /&gt;
|-&lt;br /&gt;
| Display lid || button/lid LID 00000080 xxxxxxxx&lt;br /&gt;
|-&lt;br /&gt;
| Ultrabay eject || ibm/bay MSTR 00000003 00000000&lt;br /&gt;
|-&lt;br /&gt;
| Ultrabay inserted || ibm/bay MSTR 00000001 00000000&lt;br /&gt;
|-&lt;br /&gt;
| Dock eject || ibm/dock GDCK 00000003 00000001&lt;br /&gt;
|-&lt;br /&gt;
| Wireless switch || ibm/hotkey HKEY 00000080 00007000&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
By disassembling and editing the DSDT, more events can be added.  HKEY events are triggered by calls to the MKHQ function, e.g. &amp;lt;tt&amp;gt;\_SB.PCI0.LPC.EC.HKEY.MHKQ(0Ã—1007)&amp;lt;/tt&amp;gt; will trigger &amp;quot;ibm/hotkey HKEY 00000080 00001007&amp;quot;.  Most of these can be found in &amp;lt;tt&amp;gt;_Qxx&amp;lt;/tt&amp;gt; methods within the DSDT, which are executed on embedded controller events, e.g. _Q10 is triggered by pressing Fn-F7.  You can add a call to MKHQ into an existing &amp;lt;tt&amp;gt;_Qxx&amp;lt;/tt&amp;gt; method to get it recognized by ibm-acpi as well as creating new &amp;lt;tt&amp;gt;_Qxx&amp;lt;/tt&amp;gt; methods, which if you're lucky will correspond to an EC event that IBM never used (e.g. A 770 will send Fn-Home/End/PgUp/PgDn to ibm-acpi if hacked in this fashion). For example, [http://www.wormnet.eu/ibm-g40/morebuttons.dsl this is a modified block of DSDT for a G40].&lt;br /&gt;
&lt;br /&gt;
=== Pure ACPI events ===&lt;br /&gt;
&lt;br /&gt;
A few keys can generate ACPI events of their own on certain ThinkPads, as long as they are masked off in the ibm-acpi hotkey's mask (or the hotkey feature is disabled in ibm-acpi).&lt;br /&gt;
&lt;br /&gt;
If you want the ThinkPad's BIOS and ACPI methods to know about these keys being pressed, you probably want to leave them masked out from ibm-acpi, and use their non-HKEY events listed below, instead.&lt;br /&gt;
&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
|+ events triggered by ACPI when hotkey is masked out or disabled. &lt;br /&gt;
! key !! event&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F4}} || button/sleep SLPB 00000080 00000001&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F12}} || ibm/hotkey HKEY 00000080 0000100c&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===tpb configuration===&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
|+ configuration keywords for [[tpb]] (to put in {{path|/etc/tpbrc}})&lt;br /&gt;
! key !! config keyword&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Access IBM|#495988}} or {{ibmkey|ThinkPad|#494949}} || THINKPAD&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Home|#494949}} || HOME&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Search|#494949}} || SEARCH&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Mail|#494949}} || MAIL&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Favorites|#494949}} || FAVORITES&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Reload|#494949}} || RELOAD&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Abort|#494949}} || ABORT&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Backward|#494949}} || BACKWARD&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Forward|#494949}} || FORWARD&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}} || FN&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Space}} || CALLBACK (zoom on/off)&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|PageUp}} || CALLBACK (thinklight on/off)&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F7}} || CALLBACK (display lcd/crt/both)&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F8}} || CALLBACK (expand on/off)&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Home}} / {{key|Fn}}{{key|Pos1}} || CALLBACK (brightness &amp;lt;percent&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|End}} || CALLBACK (brightness &amp;lt;percent&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume up|#494949}} || CALLBACK (volume &amp;lt;percent&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume down|#494949}} || CALLBACK (volume &amp;lt;percent&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume mute|#494949}} || CALLBACK (mute on/off)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To all parameter keywords should be assigned the full path to the executables supposed to be started on key press.&lt;br /&gt;
The exectable provided for the CALLBACK keyword should take the parameters given in parentheses and act according to them.&lt;br /&gt;
If you want to use xmodmap for the HOME, SEARCH, MAIL, FAVORITES, RELOAD, ABORT, BACKWARD, FORWARD and FN keys you should&lt;br /&gt;
provide a &amp;lt;tt&amp;gt;XEVENTS OFF&amp;lt;/tt&amp;gt; in your {{path|/etc/tpbrc}}. &lt;br /&gt;
You can use an appropriate executable to [[How to inject fake keystrokes|inject fake keystrokes]].&lt;br /&gt;
&lt;br /&gt;
For Debian users, tpb is started from {{path|/etc/X11/Xsession.d/90tpb}}.&lt;br /&gt;
&lt;br /&gt;
'''Sound Button configuration'''&lt;br /&gt;
&lt;br /&gt;
''Note: Tested on T60p with Ubuntu 6.06 LTS''&lt;br /&gt;
&lt;br /&gt;
Most Thinkpads have a hardware sound mixer, thus the volumes buttons should work without configuration. However, this change is not reflected in the software mixer. tpb has a switch to enable software mixer support via OSS. The manual recommends this only for devices without a hardware mixer, but it also works for other hadware mixer enabled devices, even with the ALSA system. Just put MIXER ON in your {{path|/etc/tpbrc}} file and you can see the effect immediately in any ALSA mixer (e.g. kmix). For this to work you need write permissions to {{path|/dev/nvram}}.&lt;br /&gt;
&lt;br /&gt;
''Note: Tested on X21 with Ubuntu 6.06 LTS''&lt;br /&gt;
&lt;br /&gt;
On the ThinkPad X21 (and maybe some other older models) ACPI causes problems with tpb.  On an X21 using acpi the volume buttons would work occasionally, and the OSD for tpb functions would rarely work.  If a volume buttons was pressed too often, sometimes the computer would enter a low power (unplugged state) and would require a reboot.  The solution is to use APM instead of ACPI.  Instructions can be found in [[How_to_make_APM_work]].&lt;br /&gt;
&lt;br /&gt;
===KMilo configuration===&lt;br /&gt;
The programs to be executed by [[KMilo]] are configured via the KDE Control Center (&amp;lt;tt&amp;gt;kcontrol&amp;lt;/tt&amp;gt;), under &amp;lt;tt&amp;gt;System Administration --&amp;gt; IBM Thinkpad Laptop&amp;lt;/tt&amp;gt;. Note that you can use appropriate commands to [[How to inject fake keystrokes|inject fake keystrokes]].&lt;br /&gt;
&lt;br /&gt;
===xmodmap configuration===&lt;br /&gt;
xmodmap enables you to edit the modifier map and keymap tables that are used to translate keycodes into keysyms.&lt;br /&gt;
Understood? Well, basically it allows you to give the X server a dictionary for the translation of keycodes like &amp;quot;97&amp;quot; into more human readable synonyms like &amp;quot;Home&amp;quot;. This way xmodmap allows you to make the special keys of your keyboard known to X applications.&lt;br /&gt;
&lt;br /&gt;
To discover the keycode that a certain keypress produces, use the tool {{cmduser|xev}} &lt;br /&gt;
&lt;br /&gt;
Usually you should write your keycode-keysym associations into the file {{path|~/.Xmodmap}}. This file is usually read by the X session startup scripts of your system, so that the mappings automatically get included everytime you run the X server.&lt;br /&gt;
&lt;br /&gt;
The {{path|~/.Xmodmap}} lines for our purpose are in the form of&lt;br /&gt;
 keycode &amp;lt;keycode&amp;gt; = &amp;lt;keysym&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load the assocation using the command&lt;br /&gt;
&lt;br /&gt;
{{cmduser|xmodmap ~/.Xmodmap}} &lt;br /&gt;
&lt;br /&gt;
(some configurations do this automatically upon X startup). &lt;br /&gt;
&lt;br /&gt;
The following table shows the keycodes generated by the ThinkPad special keys and sensible keysyms to assign them to.&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
|+ keycodes and recommended keysyms&lt;br /&gt;
! key !! keycode !! keysym&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Access IBM|#495988}} or {{ibmkey|ThinkPad|#494949}} || 159 || XF86LaunchA&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Backward|#494949}} || 234 || XF86Back or F19&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Forward|#494949}} || 233 || XF86Forward or F20&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Play/Pause|#494949}} || 162 || XF86AudioPlay&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Stop|#494949}} || 164 || XF86AudioStop&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Next|#494949}} || 153 || XF86AudioNext&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Previous|#494949}} || 144 || XF86AudioPrev&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| {{ibmkey|Home|#494949}} || 178 || XF86HomePage&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Search|#494949}} || 229 || XF86Search&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Mail|#494949}} || 236 || XF86Mail&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Favorites|#494949}} || 230 || XF86AddFavorite or XF86Favorites&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Reload|#494949}} || 231 || XF86Reload&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Abort|#494949}} || 232 || XF86Stop&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}} || 227 || F35&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: You can also use xkeycaps (an X tool to display and edit the X keyboard mapping) to generate proper .Xmodmap.&lt;br /&gt;
&lt;br /&gt;
Note: if you are running [[tpb]] you might need to add the line &amp;lt;tt&amp;gt;XEVENTS=off&amp;lt;/tt&amp;gt; into your tpbrc to stop it from grabbing the key events and allow them to get through to X instead. See [[http://www.thinkwiki.org/wiki/Tpb]] for more detailed instruction on how to use tpb and xmodmap.&lt;br /&gt;
&lt;br /&gt;
Note: XF86Forward and XF86Back do not work correctly in Firefox. You may want to map them to F19 and F20 instead if you use Firefox.&lt;br /&gt;
&lt;br /&gt;
Note: The &amp;quot;XF86AudioPlay&amp;quot; etc. just works with a few programs. To make it work with more multimedia programs you have map the key to use something like [http://www.kde-apps.org/content/show.php/ReMoot?content=63140 ReMoot]. ReMoot is a command line wrapper that control 18 of the most common multimedia applications. &lt;br /&gt;
&lt;br /&gt;
=====Enabling the Windows and Menu Keys=====&lt;br /&gt;
On some systems the Windows and Menu keys may not be recognized.  You can enable then by&lt;br /&gt;
making the following changes:&lt;br /&gt;
&lt;br /&gt;
        keycode 115 = F13&lt;br /&gt;
        keycode 227 = F35&lt;br /&gt;
&lt;br /&gt;
F13 and F35 are used for the Windows and and Menu keys respectively.  Labelling keycpode 227 as &amp;quot;Menu&amp;quot; may conflict with the right-mouse-click event.&lt;br /&gt;
&lt;br /&gt;
=====Using Caps Lock as Super L (Windows key)=====&lt;br /&gt;
You can easily use Caps Lock as Win key by adding the following in your ~/.Xmodmap:&lt;br /&gt;
        ! No Caps Lock&lt;br /&gt;
        clear lock&lt;br /&gt;
        ! Caps Lock as Win key&lt;br /&gt;
        add mod4 = Caps_Lock&lt;br /&gt;
=====NumLock=====&lt;br /&gt;
On the ThinkPad {{600}}, {{T20}}, {{T21}}, {{T22}}, {{T30}}, {{X20}}, {{X21}},  {{X31}}, {{X40}}, {{T42p}}, {{T43}}, {{R51}}, {{R52}} and possibly other models, X does not recognize the keycode for {{key|NumLk}} = {{key|Shift}}+{{key|ScrLk}}. To fix this, add the following to {{path|~/.Xmodmap}} in your home directory or {{path|/etc/X11/Xmodmap}} and run &amp;lt;tt&amp;gt;xmodmap&amp;lt;/tt&amp;gt;, ex: &amp;lt;tt&amp;gt;xmodmap ~/.Xmodmap&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 keycode 77 = Num_Lock&lt;br /&gt;
&lt;br /&gt;
This configuration also enables the respective LED.&lt;br /&gt;
&lt;br /&gt;
Please note, pressing the {{key|Shift}}+{{key|ScrLk}} key combination, without first following the above configuration, will start an accessibility feature, which will allow the numeric keypad to maneuver the mouse pointer.  Starting this accessibility feature and subsequently running xmodmap, as described above, results in the accessibility feature and the numeric lock LED functioning simultaneously.  As such, the above configuration should be completed before the accessibility feature is started in order to produce numbers.&lt;br /&gt;
&lt;br /&gt;
===Mapping keys with setkeycodes===&lt;br /&gt;
You can use the setkeycodes command to remap certain keys. I.e. you can use {{cmdroot|setkeycodes 6e 109 6d 104 69 28 6b 1}} to map the Tablets Up and Down keys to the standard PageUp and PageDown keys and Tablet Escape and Enter to their respective keys.&lt;br /&gt;
&lt;br /&gt;
The following table shows the keycodes generated by the ThinkPad keys.&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
|+ keycodes&lt;br /&gt;
! key !! keycode&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet orientation|#494949}} || 0x6d&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Shortcut|#494949}} || 0x6e&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Esc|#494949}} || 0x6b&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Enter|#494949}} || 0x69&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Up|#494949}} || 0x68&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Down|#494949}} || 0x6c&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet (unlabeled)|#494949}} || 0x67&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Example Applications==&lt;br /&gt;
===Web Browsers===&lt;br /&gt;
====Firefox====&lt;br /&gt;
&lt;br /&gt;
There are various ways to assign actions to the browser keys. The easiest way is to install [http://mozilla.dorando.at/keyconfig.xpi keyconfig.xpi] from http://mozilla.dorando.at, which adds a menu entry Tools-&amp;gt;Keyconfig. Then you can assign any action you want to the F19/F20 keys (you still need to create {{path|~/.Xmodmap}} as explained above).&lt;br /&gt;
&lt;br /&gt;
The remaining discussion gives you various more complicated ways to achieve the same thing. &lt;br /&gt;
To have firefox make use of the browser keys you need to modify one of its files{{footnote|4}}.&lt;br /&gt;
To do this you will first need to extract it from the {{path|browser.jar}} archive. Do...&lt;br /&gt;
&lt;br /&gt;
:{{cmdroot|cd &amp;lt;firefox-directory&amp;gt;/chrome}}&amp;lt;br /&amp;gt;&lt;br /&gt;
:{{cmdroot|unzip browser.jar}}&lt;br /&gt;
&lt;br /&gt;
The file of interest is {{path|content/browser/browser.xul}}. Edit it {and don't forget to make a backup copy first}...&lt;br /&gt;
:{{cmdroot|vi content/browser/browser.xul}}&lt;br /&gt;
&lt;br /&gt;
Look for the '''&amp;lt;keyset id=&amp;quot;mainKeyset&amp;quot;&amp;gt;''' section and add the following lines within...&lt;br /&gt;
 &amp;lt;key id=&amp;quot;goBackKb&amp;quot; keycode=&amp;quot;VK_F19&amp;quot; command=&amp;quot;Browser:Back&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;key id=&amp;quot;goForwardKb&amp;quot; keycode=&amp;quot;VK_F20&amp;quot; command=&amp;quot;Browser:Forward&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Command you need for Next Tab &lt;br /&gt;
 &amp;lt;key id=&amp;quot;goBackTabKb&amp;quot; keycode=&amp;quot;VK_F19&amp;quot; oncommand=&amp;quot;gBrowser.mTabContainer.advanceSelectedTab(-1)&amp;quot; /&amp;gt;&lt;br /&gt;
For the Previous Tab &lt;br /&gt;
 &amp;lt;key id=&amp;quot;goForwardTabKb&amp;quot; keycode=&amp;quot;VK_F20&amp;quot; oncommand=&amp;quot;gBrowser.mTabContainer.advanceSelectedTab(1)&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now save the file and repackage the {{path|browser.jar}} archive...&lt;br /&gt;
:{{cmdroot|zip -rD0 browser.jar content/browser/}}&lt;br /&gt;
&lt;br /&gt;
That's it.&lt;br /&gt;
&lt;br /&gt;
{{HINT|For Firefox 2.0, just edit &amp;lt;firefox-directory&amp;gt;/chrome/browser/content/browser/browser.xul}}&lt;br /&gt;
&lt;br /&gt;
{{HINT|Outdated: Another interesting Page on Firefox is http://dqd.com/~mayoff/notes/thinkpad/dqdnavkeys/ It uses different key mappings (F19 resp. F20) but a ready [http://dqd.com/~mayoff/notes/thinkpad/dqdnavkeys/dqdnavkeys-1.2.xpi .xpi] is provided which is pretty comfortable. However, this xpi file does not install on Firefox 1.5. or later.}}&lt;br /&gt;
&lt;br /&gt;
{{HINT|Outdated: You can also use the [http://extensionroom.mozdev.org/more-info/keyconfig keyconfig] extension to configure custom keys.  This extension works with Firefox 1.5 but not with Firefox 2.0. The Command you need for Next Tab is gBrowser.mTabContainer.advanceSelectedTab(1,true); For Previous Tab its gBrowser.mTabContainer.advanceSelectedTab(-1,true); }}.&lt;br /&gt;
&lt;br /&gt;
====Konqueror====&lt;br /&gt;
KDE allows you set key mappings for KDE applications (Go to KMenu &amp;gt; System &amp;gt; Control Center &amp;gt; Regional &amp;amp; Accessibility &amp;gt; Keyboard Shortcuts). By default (at least in KDE 3.5), XF86Back and XF86Forward are set as alternatives to Alt-Left and Alt-Right, and are mapped to KDE Back and Forward navigation actions.  &lt;br /&gt;
&lt;br /&gt;
If you use Konqueror as your only browser, you only need to set up {{path|~/.Xmodmap}} as described [[#xmodmap configuration|above]] to assign ThinkPad back/forward keys to the symbols XF86Back/XF86Forward. This also make these keys work for other KDE applications such as Quanta Plus, KPackage and so on (not all KDE applications honor this setting, e.g. KDE help system doesn't).&lt;br /&gt;
&lt;br /&gt;
If you want to use Firefox, however, the above settings do not work. You will have to map ThinkPad back/forward keys to F19/F20 as described [[#Firefox|above]], and change KDE navigation key settings to use F19/F20 instead of the default.&lt;br /&gt;
&lt;br /&gt;
====Opera====&lt;br /&gt;
However this isn't a simple configration file, you can set your browser manually.&amp;lt;br /&amp;gt;&lt;br /&gt;
Go to &amp;lt;i&amp;gt;Tool &amp;gt; Settings &amp;gt; Mouse and keyboard &amp;gt; Keyboard settings &amp;gt; Edit &amp;gt; Browser Window&amp;lt;/i&amp;gt;. There add F19 - Back and F20 - Forward. Now you can surf using your TP keys ;-)&lt;br /&gt;
&lt;br /&gt;
===Window Managers===&lt;br /&gt;
====fvwm====&lt;br /&gt;
To get the {{ibmkey|Forward|#494949}} and {{ibmkey|Backward|#494949}} keys to cycle through pages in the virtual desktop, add this to your {{path|~/.fvwmrc}}:&lt;br /&gt;
 Key    XF86Back     A      A   Scroll     -100000   0&lt;br /&gt;
 Key    XF86Forward  A      A   Scroll     +100000   0&lt;br /&gt;
If you use multiple virtual desktops, you could instead use the keys to flip between them by using GotoDesk.&lt;br /&gt;
&lt;br /&gt;
====fluxbox====&lt;br /&gt;
To get the keys to cycle through pages in the virtual desktop, add this to your {{path|~/.fluxbox/keys}}:&lt;br /&gt;
 None F19 :PrevWorkspace&lt;br /&gt;
 None F20 :NextWorkspace&lt;br /&gt;
&lt;br /&gt;
====pekwm configuration====&lt;br /&gt;
You can make the two browser keys switch workspaces in pekwm, by adding the following two lines to the {{path|~/.pekwm/keys}} file:&lt;br /&gt;
 KeyPress = &amp;quot;Mod1 XF86Back&amp;quot; { Actions = &amp;quot;GoToWorkspace prev&amp;quot; }&lt;br /&gt;
 KeyPress = &amp;quot;Mod1 XF86Forward&amp;quot; { Actions = &amp;quot;GoToWorkspace next&amp;quot; }&lt;br /&gt;
&lt;br /&gt;
====pwm====&lt;br /&gt;
Another example how to use these two keys to switch between pwm tabs. These two lines should be added to {{path|~/.pwm/keys-default.conf}} or {{path|/etc/pwm/keys-default.conf}}:&lt;br /&gt;
 kbind &amp;quot;Back&amp;quot;, &amp;quot;switch_rot&amp;quot;, -1&lt;br /&gt;
 kbind &amp;quot;Forward&amp;quot;, &amp;quot;switch_rot&amp;quot;, 1&lt;br /&gt;
&lt;br /&gt;
====IceWM====&lt;br /&gt;
To make IceWM cycle workspaces using the {{ibmkey|Forward|#494949}} and {{ibmkey|Backward|#494949}} keys, change these two options in {{path|~/.icewm/preferences}} (Provided you assigned keysyms F19 and F20 with xmodmap):&lt;br /&gt;
 # &amp;quot;Previous workspace&amp;quot; shortcut&lt;br /&gt;
 KeySysWorkspacePrev=&amp;quot;F19&amp;quot;&lt;br /&gt;
 # &amp;quot;Next workspace&amp;quot; shortcut&lt;br /&gt;
 KeySysWorkspaceNext=&amp;quot;F20&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Gnome/metacity ====&lt;br /&gt;
&lt;br /&gt;
Follow the [https://wiki.ubuntu.com/Keybindings Ubuntu guide].&lt;br /&gt;
&lt;br /&gt;
===Other Uses===&lt;br /&gt;
====Console tools configuraton====&lt;br /&gt;
To make the {{ibmkey|Forward|#494949}} and {{ibmkey|Backward|#494949}} keys useful in console, add this to your keymap ({{path|/etc/console/boottime.kmap.gz}} in {{Debian}}):&lt;br /&gt;
 keycode 158 = Decr_Console&lt;br /&gt;
 keycode 159 = Incr_Console&lt;br /&gt;
&lt;br /&gt;
Alternatively you can load this script (perhaps on system startup) to enable Backward/Forward button console (VT) switch:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 echo keycode 158 = Decr_Console | loadkeys&lt;br /&gt;
 echo keycode 159 = Incr_Console | loadkeys&lt;br /&gt;
&lt;br /&gt;
It should work with any distro.&lt;br /&gt;
&lt;br /&gt;
==External Sources==&lt;br /&gt;
*[http://www-307.ibm.com/pc/support/site.wss/document.do?lndocid=MIGR-51537 IBMs page on configuring the ThinkPad buttons (ThinkPad, Access IBM, Mail, Search, and Home buttons) under Linux]&lt;br /&gt;
*[http://dqd.com/~mayoff/notes/thinkpad/dqdnavkeys/ Rob Mayoffs page on using IBM Keyboard Navigation Keys in Linux Mozilla and Firefox]&lt;br /&gt;
*[http://snarfed.org/space/thinkpad+keys+in+firefox Ryan Barretts blog article about using the browser keys in Firefox]&lt;br /&gt;
*[http://chaotika.org/~bluesceada/?page=soft&amp;amp;sub=thinkpad#acpibutn DennisG's help to get the ibm-acpi buttons do useful things] on a {{Z61e}} and possibly {{Z61m}}, {{Z61t}} and {{Z61p}}&lt;br /&gt;
&lt;br /&gt;
{{footnotes|&lt;br /&gt;
#Note that the associated functionality for Fn-F* key combinations is not consistent amongst all ThinkPads. We are maintaining [[Default meanings of special keys|a table of associated meanings]].&lt;br /&gt;
#if there are more than one tool listed, one is sufficient&lt;br /&gt;
#'full' means you can completely reassign any action to be triggered by the key, 'additional actions' means you can trigger actions in addition to the standard function of the key, which can not be changed.&lt;br /&gt;
#Thanks go to Ryan Barrett for writing the [http://snarfed.org/space/thinkpad+keys+in+firefox little howto] on [http://snarfed.org/space/start his blog].&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=How_to_get_special_keys_to_work&amp;diff=34377</id>
		<title>How to get special keys to work</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=How_to_get_special_keys_to_work&amp;diff=34377"/>
		<updated>2007-11-09T17:12:14Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
The following table gives an overview over the special keys found on ThinkPads and what is needed to make them work.&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
! key !! standard function{{footnote|1}} !! tools supporting key{{footnote|2}} !! configurability{{footnote|3}} !! remarks&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}} || - || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || on release without completed key combination&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F1}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F2}} || lock screen || [[#ibm-acpi events|ibm-acpi]] || full || in models from T/X/Z 60 onwards&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F3}} || blank screen || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F4}} || suspend to ram || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]] || full || may generate ACPI event when not enabled in the ibm-acpi hotkey mask&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F5}} || switch bluetooth || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]] || full || in models starting from 2002&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F6}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F7}} || toggle display || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]], [[#tpb configuration|tpb]] || additional actions || [Sample fn-F7 script]&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F8}} || toggle trackpoint/touchpad || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]], [[#tpb configuration|tpb]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F9}} || eject from dock || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F10}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F11}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F12}} || hibernate || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]] || full || may generate ACPI event when not enabled in the ibm-acpi hotkey mask&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Home}} / {{key|Fn}}{{key|Pos1}} || brightness up || [[#ibm-acpi events|ibm-acpi]], [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|End}} || brightness down || [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|PageUp}} || toggle thinklight || [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Space}} || toggle zoom || [[#tpb configuration|tpb]], [[KMilo]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Ins}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Del}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Backspace}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|NumLock}} || - || [[#xmodmap configuration|xmodmap]] || make working ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Windows}} || - || [[#xmodmap configuration|xmodmap]] || remapping ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Access IBM|#495988}} or {{ibmkey|ThinkPad|#494949}} or {{ibmkey|ThinkVantage|#495988}} || help application || [[#tpb configuration|tpb]], [[KMilo]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Home|#494949}} || open web browser || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]], [[KMilo]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Search|#494949}} || open search application || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]], [[KMilo]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Mail|#494949}} || open mail application || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]], [[KMilo]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Favorites|#494949}} || open favorites || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Reload|#494949}} || reload web page || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Abort|#494949}} || abort loading page || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Backward|#494949}} || previous page || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full ||  ext. keyboards and ThinkPads starting from 2002&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Forward|#494949}} || next page || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || ext. keyboards and ThinkPads starting from 2002&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume up|#494949}} || volume up || [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume down|#494949}} || volume down || [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume mute|#494949}} || mute volume || [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Play/Pause|#494949}} || start/pause playback  || [[#xmodmap configuration|xmodmap]] || full || {{X60s}} (Fn+Arrow Down)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Stop|#494949}} || stop playback || [[#xmodmap configuration|xmodmap]] || full || {{X60s}} (Fn+Arrow Up)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Next|#494949}} || play next || [[#xmodmap configuration|xmodmap]] || full || {{X60s}} (Fn+Arrow Right)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Previous|#494949}} || play previous || [[#xmodmap configuration|xmodmap]] || full || {{X60s}} (Fn+Arrow Left)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Power|#494949}} || shutdown || [[#ibm-acpi events|ibm-acpi]] || full || triggered on pressing 3secs, but notebook goes off on 5sec press&lt;br /&gt;
|-&lt;br /&gt;
| Display lid || blank screen || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| Ultrabay lid || announce ultrabay change || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| Dock eject || eject from dock || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet power|#494949}} || shutdown || [[#ibm-acpi events|ibm-acpi]] || full || triggered on pressing 3secs, but notebook goes off on 5sec press&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet orientation|#494949}} || rotates screen || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet shortcut|#494949}} || shortcut menu || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Esc|#494949}} || esc key || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Enter|#494949}} || enter key || [[#mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Up|#494949}} || up key || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Down|#494949}} || down key || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet (unlabeled)|#494949}} || down key || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Triggering key events==&lt;br /&gt;
===ibm-acpi events===&lt;br /&gt;
Some of the following events require a {{cmdroot|echo enable,0xffff &amp;gt;/proc/acpi/ibm/hotkey}} in order to make acpi able to get information on them. These events can be used to [[How to configure acpid|configure acpid]].&lt;br /&gt;
&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
|+ events triggered by [[ibm-acpi]] for {{path|/etc/acpi/events}} files. &lt;br /&gt;
! key !! event&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F1}} || ibm/hotkey HKEY 00000080 00001001&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F2}} || ibm/hotkey HKEY 00000080 00001002&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F3}} || ibm/hotkey HKEY 00000080 00001003&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F4}} || ibm/hotkey HKEY 00000080 00001004&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F5}} || ibm/hotkey HKEY 00000080 00001005&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F6}} || ibm/hotkey HKEY 00000080 00001006&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F7}} || ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F8}} || ibm/hotkey HKEY 00000080 00001008&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F9}} || ibm/hotkey HKEY 00000080 00001009&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F10}} || ibm/hotkey HKEY 00000080 0000100a&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F11}} || ibm/hotkey HKEY 00000080 0000100b&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F12}} || ibm/hotkey HKEY 00000080 0000100c&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Backspace}} || ibm/hotkey HKEY 00000080 0000100d&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Ins}} || ibm/hotkey HKEY 00000080 0000100e&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Del}} || ibm/hotkey HKEY 00000080 0000100f&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Home}}/{{key|Fn}}{{key|Pos1}} || ibm/hotkey HKEY 00000080 00001010&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|ThinkVantage|#495988}} ||ibm/hotkey HKEY 00000080 00001018&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Power|#494949}} || button/power PWRF 00000080 xxxxxxxx&lt;br /&gt;
|-&lt;br /&gt;
| Display lid || button/lid LID 00000080 xxxxxxxx&lt;br /&gt;
|-&lt;br /&gt;
| Ultrabay eject || ibm/bay MSTR 00000003 00000000&lt;br /&gt;
|-&lt;br /&gt;
| Ultrabay inserted || ibm/bay MSTR 00000001 00000000&lt;br /&gt;
|-&lt;br /&gt;
| Dock eject || ibm/dock GDCK 00000003 00000001&lt;br /&gt;
|-&lt;br /&gt;
| Wireless switch || ibm/hotkey HKEY 00000080 00007000&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
By disassembling and editing the DSDT, more events can be added.  HKEY events are triggered by calls to the MKHQ function, e.g. &amp;lt;tt&amp;gt;\_SB.PCI0.LPC.EC.HKEY.MHKQ(0Ã—1007)&amp;lt;/tt&amp;gt; will trigger &amp;quot;ibm/hotkey HKEY 00000080 00001007&amp;quot;.  Most of these can be found in &amp;lt;tt&amp;gt;_Qxx&amp;lt;/tt&amp;gt; methods within the DSDT, which are executed on embedded controller events, e.g. _Q10 is triggered by pressing Fn-F7.  You can add a call to MKHQ into an existing &amp;lt;tt&amp;gt;_Qxx&amp;lt;/tt&amp;gt; method to get it recognized by ibm-acpi as well as creating new &amp;lt;tt&amp;gt;_Qxx&amp;lt;/tt&amp;gt; methods, which if you're lucky will correspond to an EC event that IBM never used (e.g. A 770 will send Fn-Home/End/PgUp/PgDn to ibm-acpi if hacked in this fashion). For example, [http://www.wormnet.eu/ibm-g40/morebuttons.dsl this is a modified block of DSDT for a G40].&lt;br /&gt;
&lt;br /&gt;
=== Pure ACPI events ===&lt;br /&gt;
&lt;br /&gt;
A few keys can generate ACPI events of their own on certain ThinkPads, as long as they are masked off in the ibm-acpi hotkey's mask (or the hotkey feature is disabled in ibm-acpi).&lt;br /&gt;
&lt;br /&gt;
If you want the ThinkPad's BIOS and ACPI methods to know about these keys being pressed, you probably want to leave them masked out from ibm-acpi, and use their non-HKEY events listed below, instead.&lt;br /&gt;
&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
|+ events triggered by ACPI when hotkey is masked out or disabled. &lt;br /&gt;
! key !! event&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F4}} || button/sleep SLPB 00000080 00000001&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F12}} || ibm/hotkey HKEY 00000080 0000100c&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===tpb configuration===&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
|+ configuration keywords for [[tpb]] (to put in {{path|/etc/tpbrc}})&lt;br /&gt;
! key !! config keyword&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Access IBM|#495988}} or {{ibmkey|ThinkPad|#494949}} || THINKPAD&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Home|#494949}} || HOME&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Search|#494949}} || SEARCH&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Mail|#494949}} || MAIL&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Favorites|#494949}} || FAVORITES&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Reload|#494949}} || RELOAD&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Abort|#494949}} || ABORT&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Backward|#494949}} || BACKWARD&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Forward|#494949}} || FORWARD&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}} || FN&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Space}} || CALLBACK (zoom on/off)&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|PageUp}} || CALLBACK (thinklight on/off)&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F7}} || CALLBACK (display lcd/crt/both)&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F8}} || CALLBACK (expand on/off)&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Home}} / {{key|Fn}}{{key|Pos1}} || CALLBACK (brightness &amp;lt;percent&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|End}} || CALLBACK (brightness &amp;lt;percent&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume up|#494949}} || CALLBACK (volume &amp;lt;percent&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume down|#494949}} || CALLBACK (volume &amp;lt;percent&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume mute|#494949}} || CALLBACK (mute on/off)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To all parameter keywords should be assigned the full path to the executables supposed to be started on key press.&lt;br /&gt;
The exectable provided for the CALLBACK keyword should take the parameters given in parentheses and act according to them.&lt;br /&gt;
If you want to use xmodmap for the HOME, SEARCH, MAIL, FAVORITES, RELOAD, ABORT, BACKWARD, FORWARD and FN keys you should&lt;br /&gt;
provide a &amp;lt;tt&amp;gt;XEVENTS OFF&amp;lt;/tt&amp;gt; in your {{path|/etc/tpbrc}}. &lt;br /&gt;
You can use an appropriate executable to [[How to inject fake keystrokes|inject fake keystrokes]].&lt;br /&gt;
&lt;br /&gt;
For Debian users, tpb is started from {{path|/etc/X11/Xsession.d/90tpb}}.&lt;br /&gt;
&lt;br /&gt;
'''Sound Button configuration'''&lt;br /&gt;
&lt;br /&gt;
''Note: Tested on T60p with Ubuntu 6.06 LTS''&lt;br /&gt;
&lt;br /&gt;
Most Thinkpads have a hardware sound mixer, thus the volumes buttons should work without configuration. However, this change is not reflected in the software mixer. tpb has a switch to enable software mixer support via OSS. The manual recommends this only for devices without a hardware mixer, but it also works for other hadware mixer enabled devices, even with the ALSA system. Just put MIXER ON in your {{path|/etc/tpbrc}} file and you can see the effect immediately in any ALSA mixer (e.g. kmix). For this to work you need write permissions to {{path|/dev/nvram}}.&lt;br /&gt;
&lt;br /&gt;
''Note: Tested on X21 with Ubuntu 6.06 LTS''&lt;br /&gt;
&lt;br /&gt;
On the ThinkPad X21 (and maybe some other older models) ACPI causes problems with tpb.  On an X21 using acpi the volume buttons would work occasionally, and the OSD for tpb functions would rarely work.  If a volume buttons was pressed too often, sometimes the computer would enter a low power (unplugged state) and would require a reboot.  The solution is to use APM instead of ACPI.  Instructions can be found in [[How_to_make_APM_work]].&lt;br /&gt;
&lt;br /&gt;
===KMilo configuration===&lt;br /&gt;
The programs to be executed by [[KMilo]] are configured via the KDE Control Center (&amp;lt;tt&amp;gt;kcontrol&amp;lt;/tt&amp;gt;), under &amp;lt;tt&amp;gt;System Administration --&amp;gt; IBM Thinkpad Laptop&amp;lt;/tt&amp;gt;. Note that you can use appropriate commands to [[How to inject fake keystrokes|inject fake keystrokes]].&lt;br /&gt;
&lt;br /&gt;
===xmodmap configuration===&lt;br /&gt;
xmodmap enables you to edit the modifier map and keymap tables that are used to translate keycodes into keysyms.&lt;br /&gt;
Understood? Well, basically it allows you to give the X server a dictionary for the translation of keycodes like &amp;quot;97&amp;quot; into more human readable synonyms like &amp;quot;Home&amp;quot;. This way xmodmap allows you to make the special keys of your keyboard known to X applications.&lt;br /&gt;
&lt;br /&gt;
To discover the keycode that a certain keypress produces, use the tool {{cmduser|xev}} &lt;br /&gt;
&lt;br /&gt;
Usually you should write your keycode-keysym associations into the file {{path|~/.Xmodmap}}. This file is usually read by the X session startup scripts of your system, so that the mappings automatically get included everytime you run the X server.&lt;br /&gt;
&lt;br /&gt;
The {{path|~/.Xmodmap}} lines for our purpose are in the form of&lt;br /&gt;
 keycode &amp;lt;keycode&amp;gt; = &amp;lt;keysym&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load the assocation using the command&lt;br /&gt;
&lt;br /&gt;
{{cmduser|xmodmap ~/.Xmodmap}} &lt;br /&gt;
&lt;br /&gt;
(some configurations do this automatically upon X startup). &lt;br /&gt;
&lt;br /&gt;
The following table shows the keycodes generated by the ThinkPad special keys and sensible keysyms to assign them to.&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
|+ keycodes and recommended keysyms&lt;br /&gt;
! key !! keycode !! keysym&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Access IBM|#495988}} or {{ibmkey|ThinkPad|#494949}} || 159 || XF86LaunchA&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Backward|#494949}} || 234 || XF86Back or F19&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Forward|#494949}} || 233 || XF86Forward or F20&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Play/Pause|#494949}} || 162 || XF86AudioPlay&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Stop|#494949}} || 164 || XF86AudioStop&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Next|#494949}} || 153 || XF86AudioNext&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Previous|#494949}} || 144 || XF86AudioPrev&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| {{ibmkey|Home|#494949}} || 178 || XF86HomePage&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Search|#494949}} || 229 || XF86Search&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Mail|#494949}} || 236 || XF86Mail&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Favorites|#494949}} || 230 || XF86AddFavorite or XF86Favorites&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Reload|#494949}} || 231 || XF86Reload&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Abort|#494949}} || 232 || XF86Stop&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}} || 227 || F35&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: You can also use xkeycaps (an X tool to display and edit the X keyboard mapping) to generate proper .Xmodmap.&lt;br /&gt;
&lt;br /&gt;
Note: if you are running [[tpb]] you might need to add the line &amp;lt;tt&amp;gt;XEVENTS=off&amp;lt;/tt&amp;gt; into your tpbrc to stop it from grabbing the key events and allow them to get through to X instead. See [[http://www.thinkwiki.org/wiki/Tpb]] for more detailed instruction on how to use tpb and xmodmap.&lt;br /&gt;
&lt;br /&gt;
Note: XF86Forward and XF86Back do not work correctly in Firefox. You may want to map them to F19 and F20 instead if you use Firefox.&lt;br /&gt;
&lt;br /&gt;
Note: The &amp;quot;XF86AudioPlay&amp;quot; etc. just works with a few programs. To make it work with more multimedia programs you have map the key to use something like [http://www.kde-apps.org/content/show.php/ReMoot?content=63140 ReMoot]. ReMoot is a command line wrapper that control 18 of the most common multimedia applications. &lt;br /&gt;
&lt;br /&gt;
=====Enabling the Windows and Menu Keys=====&lt;br /&gt;
On some systems the Windows and Menu keys may not be recognized.  You can enable then by&lt;br /&gt;
making the following changes:&lt;br /&gt;
&lt;br /&gt;
        keycode 115 = F13&lt;br /&gt;
        keycode 227 = F35&lt;br /&gt;
&lt;br /&gt;
F13 and F35 are used for the Windows and and Menu keys respectively.  Labelling keycpode 227 as &amp;quot;Menu&amp;quot; may conflict with the right-mouse-click event.&lt;br /&gt;
&lt;br /&gt;
=====Using Caps Lock as Super L (Windows key)=====&lt;br /&gt;
You can easily use Caps Lock as Win key by adding the following in your ~/.Xmodmap:&lt;br /&gt;
        ! No Caps Lock&lt;br /&gt;
        clear lock&lt;br /&gt;
        ! Caps Lock as Win key&lt;br /&gt;
        add mod4 = Caps_Lock&lt;br /&gt;
=====NumLock=====&lt;br /&gt;
On the ThinkPad {{600}}, {{T20}}, {{T21}}, {{T22}}, {{T30}}, {{X20}}, {{X21}},  {{X31}}, {{X40}}, {{T42p}}, {{T43}}, {{R51}}, {{R52}} and possibly other models, X does not recognize the keycode for {{key|NumLk}} = {{key|Shift}}+{{key|ScrLk}}. To fix this, add the following to {{path|~/.Xmodmap}} in your home directory or {{path|/etc/X11/Xmodmap}} and run &amp;lt;tt&amp;gt;xmodmap&amp;lt;/tt&amp;gt;, ex: &amp;lt;tt&amp;gt;xmodmap ~/.Xmodmap&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 keycode 77 = Num_Lock&lt;br /&gt;
&lt;br /&gt;
This configuration also enables the respective LED.&lt;br /&gt;
&lt;br /&gt;
Please note, pressing the {{key|Shift}}+{{key|ScrLk}} key combination, without first following the above configuration, will start an accessibility feature, which will allow the numeric keypad to maneuver the mouse pointer.  Starting this accessibility feature and subsequently running xmodmap, as described above, results in the accessibility feature and the numeric lock LED functioning simultaneously.  As such, the above configuration should be completed before the accessibility feature is started in order to produce numbers.&lt;br /&gt;
&lt;br /&gt;
===Mapping keys with setkeycodes===&lt;br /&gt;
You can use the setkeycodes command to remap certain keys. I.e. you can use {{cmdroot|setkeycodes 6e 109 6d 104 69 28 6b 1}} to map the Tablets Up and Down keys to the standard PageUp and PageDown keys and Tablet Escape and Enter to their respective keys.&lt;br /&gt;
&lt;br /&gt;
The following table shows the keycodes generated by the ThinkPad keys.&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
|+ keycodes&lt;br /&gt;
! key !! keycode&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet orientation|#494949}} || 0x6d&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Shortcut|#494949}} || 0x6e&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Esc|#494949}} || 0x6b&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Enter|#494949}} || 0x69&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Up|#494949}} || 0x68&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Down|#494949}} || 0x6c&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet (unlabeled)|#494949}} || 0x67&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Example Applications==&lt;br /&gt;
===Web Browsers===&lt;br /&gt;
====Firefox====&lt;br /&gt;
&lt;br /&gt;
There are various ways to assign actions to the browser keys. The easiest way is to install [http://mozilla.dorando.at/keyconfig.xpi keyconfig.xpi] from http://mozilla.dorando.at, which adds a menu entry Tools-&amp;gt;Keyconfig. Then you can assign any action you want to the F19/F20 keys (you still need to create {{path|~/.Xmodmap}} as explained above).&lt;br /&gt;
&lt;br /&gt;
The remaining discussion gives you various more complicated ways to achieve the same thing. &lt;br /&gt;
To have firefox make use of the browser keys you need to modify one of its files{{footnote|4}}.&lt;br /&gt;
To do this you will first need to extract it from the {{path|browser.jar}} archive. Do...&lt;br /&gt;
&lt;br /&gt;
:{{cmdroot|cd &amp;lt;firefox-directory&amp;gt;/chrome}}&amp;lt;br /&amp;gt;&lt;br /&gt;
:{{cmdroot|unzip browser.jar}}&lt;br /&gt;
&lt;br /&gt;
The file of interest is {{path|content/browser/browser.xul}}. Edit it {and don't forget to make a backup copy first}...&lt;br /&gt;
:{{cmdroot|vi content/browser/browser.xul}}&lt;br /&gt;
&lt;br /&gt;
Look for the '''&amp;lt;keyset id=&amp;quot;mainKeyset&amp;quot;&amp;gt;''' section and add the following lines within...&lt;br /&gt;
 &amp;lt;key id=&amp;quot;goBackKb&amp;quot; keycode=&amp;quot;VK_F19&amp;quot; command=&amp;quot;Browser:Back&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;key id=&amp;quot;goForwardKb&amp;quot; keycode=&amp;quot;VK_F20&amp;quot; command=&amp;quot;Browser:Forward&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Command you need for Next Tab &lt;br /&gt;
 &amp;lt;key id=&amp;quot;goBackTabKb&amp;quot; keycode=&amp;quot;VK_F19&amp;quot; oncommand=&amp;quot;gBrowser.mTabContainer.advanceSelectedTab(-1)&amp;quot; /&amp;gt;&lt;br /&gt;
For the Previous Tab &lt;br /&gt;
 &amp;lt;key id=&amp;quot;goForwardTabKb&amp;quot; keycode=&amp;quot;VK_F20&amp;quot; oncommand=&amp;quot;gBrowser.mTabContainer.advanceSelectedTab(1)&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now save the file and repackage the {{path|browser.jar}} archive...&lt;br /&gt;
:{{cmdroot|zip -rD0 browser.jar content/browser/}}&lt;br /&gt;
&lt;br /&gt;
That's it.&lt;br /&gt;
&lt;br /&gt;
{{HINT|For Firefox 2.0, just edit &amp;lt;firefox-directory&amp;gt;/chrome/browser/content/browser/browser.xul}}&lt;br /&gt;
&lt;br /&gt;
{{HINT|Outdated: Another interesting Page on Firefox is http://dqd.com/~mayoff/notes/thinkpad/dqdnavkeys/ It uses different key mappings (F19 resp. F20) but a ready [http://dqd.com/~mayoff/notes/thinkpad/dqdnavkeys/dqdnavkeys-1.2.xpi .xpi] is provided which is pretty comfortable. However, this xpi file does not install on Firefox 1.5. or later.}}&lt;br /&gt;
&lt;br /&gt;
{{HINT|Outdated: You can also use the [http://extensionroom.mozdev.org/more-info/keyconfig keyconfig] extension to configure custom keys.  This extension works with Firefox 1.5 but not with Firefox 2.0. The Command you need for Next Tab is gBrowser.mTabContainer.advanceSelectedTab(1,true); For Previous Tab its gBrowser.mTabContainer.advanceSelectedTab(-1,true); }}.&lt;br /&gt;
&lt;br /&gt;
====Konqueror====&lt;br /&gt;
KDE allows you set key mappings for KDE applications (Go to KMenu &amp;gt; System &amp;gt; Control Center &amp;gt; Regional &amp;amp; Accessibility &amp;gt; Keyboard Shortcuts). By default (at least in KDE 3.5), XF86Back and XF86Forward are set as alternatives to Alt-Left and Alt-Right, and are mapped to KDE Back and Forward navigation actions.  &lt;br /&gt;
&lt;br /&gt;
If you use Konqueror as your only browser, you only need to set up {{path|~/.Xmodmap}} as described [[#xmodmap configuration|above]] to assign ThinkPad back/forward keys to the symbols XF86Back/XF86Forward. This also make these keys work for other KDE applications such as Quanta Plus, KPackage and so on (not all KDE applications honor this setting, e.g. KDE help system doesn't).&lt;br /&gt;
&lt;br /&gt;
If you want to use Firefox, however, the above settings do not work. You will have to map ThinkPad back/forward keys to F19/F20 as described [[#Firefox|above]], and change KDE navigation key settings to use F19/F20 instead of the default.&lt;br /&gt;
&lt;br /&gt;
====Opera====&lt;br /&gt;
However this isn't a simple configration file, you can set your browser manually.&amp;lt;br /&amp;gt;&lt;br /&gt;
Go to &amp;lt;i&amp;gt;Tool &amp;gt; Settings &amp;gt; Mouse and keyboard &amp;gt; Keyboard settings &amp;gt; Edit &amp;gt; Browser Window&amp;lt;/i&amp;gt;. There add F19 - Back and F20 - Forward. Now you can surf using your TP keys ;-)&lt;br /&gt;
&lt;br /&gt;
===Window Managers===&lt;br /&gt;
====fvwm====&lt;br /&gt;
To get the {{ibmkey|Forward|#494949}} and {{ibmkey|Backward|#494949}} keys to cycle through pages in the virtual desktop, add this to your {{path|~/.fvwmrc}}:&lt;br /&gt;
 Key    XF86Back     A      A   Scroll     -100000   0&lt;br /&gt;
 Key    XF86Forward  A      A   Scroll     +100000   0&lt;br /&gt;
If you use multiple virtual desktops, you could instead use the keys to flip between them by using GotoDesk.&lt;br /&gt;
&lt;br /&gt;
====fluxbox====&lt;br /&gt;
To get the keys to cycle through pages in the virtual desktop, add this to your {{path|~/.fluxbox/keys}}:&lt;br /&gt;
 None F19 :PrevWorkspace&lt;br /&gt;
 None F20 :NextWorkspace&lt;br /&gt;
&lt;br /&gt;
====pekwm configuration====&lt;br /&gt;
You can make the two browser keys switch workspaces in pekwm, by adding the following two lines to the {{path|~/.pekwm/keys}} file:&lt;br /&gt;
 KeyPress = &amp;quot;Mod1 XF86Back&amp;quot; { Actions = &amp;quot;GoToWorkspace prev&amp;quot; }&lt;br /&gt;
 KeyPress = &amp;quot;Mod1 XF86Forward&amp;quot; { Actions = &amp;quot;GoToWorkspace next&amp;quot; }&lt;br /&gt;
&lt;br /&gt;
====pwm====&lt;br /&gt;
Another example how to use these two keys to switch between pwm tabs. These two lines should be added to {{path|~/.pwm/keys-default.conf}} or {{path|/etc/pwm/keys-default.conf}}:&lt;br /&gt;
 kbind &amp;quot;Back&amp;quot;, &amp;quot;switch_rot&amp;quot;, -1&lt;br /&gt;
 kbind &amp;quot;Forward&amp;quot;, &amp;quot;switch_rot&amp;quot;, 1&lt;br /&gt;
&lt;br /&gt;
====IceWM====&lt;br /&gt;
To make IceWM cycle workspaces using the {{ibmkey|Forward|#494949}} and {{ibmkey|Backward|#494949}} keys, change these two options in {{path|~/.icewm/preferences}} (Provided you assigned keysyms F19 and F20 with xmodmap):&lt;br /&gt;
 # &amp;quot;Previous workspace&amp;quot; shortcut&lt;br /&gt;
 KeySysWorkspacePrev=&amp;quot;F19&amp;quot;&lt;br /&gt;
 # &amp;quot;Next workspace&amp;quot; shortcut&lt;br /&gt;
 KeySysWorkspaceNext=&amp;quot;F20&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Gnome/metacity ====&lt;br /&gt;
&lt;br /&gt;
Follow the [https://wiki.ubuntu.com/Keybindings Ubuntu guide].&lt;br /&gt;
&lt;br /&gt;
===Other Uses===&lt;br /&gt;
====Console tools configuraton====&lt;br /&gt;
To make the {{ibmkey|Forward|#494949}} and {{ibmkey|Backward|#494949}} keys useful in console, add this to your keymap ({{path|/etc/console/boottime.kmap.gz}} in {{Debian}}):&lt;br /&gt;
 keycode 158 = Decr_Console&lt;br /&gt;
 keycode 159 = Incr_Console&lt;br /&gt;
&lt;br /&gt;
Alternatively you can load this script (perhaps on system startup) to enable Backward/Forward button console (VT) switch:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 echo keycode 158 = Decr_Console | loadkeys&lt;br /&gt;
 echo keycode 159 = Incr_Console | loadkeys&lt;br /&gt;
&lt;br /&gt;
It should work with any distro.&lt;br /&gt;
&lt;br /&gt;
==External Sources==&lt;br /&gt;
*[http://www-307.ibm.com/pc/support/site.wss/document.do?lndocid=MIGR-51537 IBMs page on configuring the ThinkPad buttons (ThinkPad, Access IBM, Mail, Search, and Home buttons) under Linux]&lt;br /&gt;
*[http://dqd.com/~mayoff/notes/thinkpad/dqdnavkeys/ Rob Mayoffs page on using IBM Keyboard Navigation Keys in Linux Mozilla and Firefox]&lt;br /&gt;
*[http://snarfed.org/space/thinkpad+keys+in+firefox Ryan Barretts blog article about using the browser keys in Firefox]&lt;br /&gt;
*[http://chaotika.org/~bluesceada/?page=soft&amp;amp;sub=thinkpad#acpibutn DennisG's help to get the ibm-acpi buttons do useful things] on a {{Z61e}} and possibly {{Z61m}}, {{Z61t}} and {{Z61p}}&lt;br /&gt;
&lt;br /&gt;
{{footnotes|&lt;br /&gt;
#Note that the associated functionality for Fn-F* key combinations is not consistent amongst all ThinkPads. We are maintaining [[Default meanings of special keys|a table of associated meanings]].&lt;br /&gt;
#if there are more than one tool listed, one is sufficient&lt;br /&gt;
#'full' means you can completely reassign any action to be triggered by the key, 'additional actions' means you can trigger actions in addition to the standard function of the key, which can not be changed.&lt;br /&gt;
#Thanks go to Ryan Barrett for writing the [http://snarfed.org/space/thinkpad+keys+in+firefox little howto] on [http://snarfed.org/space/start his blog].&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=How_to_get_special_keys_to_work&amp;diff=34376</id>
		<title>How to get special keys to work</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=How_to_get_special_keys_to_work&amp;diff=34376"/>
		<updated>2007-11-09T17:09:45Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
The following table gives an overview over the special keys found on ThinkPads and what is needed to make them work.&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
! key !! standard function{{footnote|1}} !! tools supporting key{{footnote|2}} !! configurability{{footnote|3}} !! remarks&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}} || - || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || on release without completed key combination&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F1}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F2}} || lock screen || [[#ibm-acpi events|ibm-acpi]] || full || in models from T/X/Z 60 onwards&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F3}} || blank screen || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F4}} || suspend to ram || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]] || full || may generate ACPI event when not enabled in the ibm-acpi hotkey mask&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F5}} || switch bluetooth || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]] || full || in models starting from 2002&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F6}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F7}} || toggle display || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]], [[#tpb configuration|tpb]] || additional actions || &lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F8}} || toggle trackpoint/touchpad || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]], [[#tpb configuration|tpb]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F9}} || eject from dock || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F10}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F11}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F12}} || hibernate || [[#ibm-acpi events|ibm-acpi]], [[thinkpad-acpi]] || full || may generate ACPI event when not enabled in the ibm-acpi hotkey mask&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Home}} / {{key|Fn}}{{key|Pos1}} || brightness up || [[#ibm-acpi events|ibm-acpi]], [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|End}} || brightness down || [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|PageUp}} || toggle thinklight || [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Space}} || toggle zoom || [[#tpb configuration|tpb]], [[KMilo]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Ins}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Del}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Backspace}} || - || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|NumLock}} || - || [[#xmodmap configuration|xmodmap]] || make working ||&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Windows}} || - || [[#xmodmap configuration|xmodmap]] || remapping ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Access IBM|#495988}} or {{ibmkey|ThinkPad|#494949}} or {{ibmkey|ThinkVantage|#495988}} || help application || [[#tpb configuration|tpb]], [[KMilo]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Home|#494949}} || open web browser || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]], [[KMilo]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Search|#494949}} || open search application || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]], [[KMilo]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Mail|#494949}} || open mail application || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]], [[KMilo]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Favorites|#494949}} || open favorites || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Reload|#494949}} || reload web page || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Abort|#494949}} || abort loading page || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Backward|#494949}} || previous page || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full ||  ext. keyboards and ThinkPads starting from 2002&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Forward|#494949}} || next page || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || ext. keyboards and ThinkPads starting from 2002&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume up|#494949}} || volume up || [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume down|#494949}} || volume down || [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume mute|#494949}} || mute volume || [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Play/Pause|#494949}} || start/pause playback  || [[#xmodmap configuration|xmodmap]] || full || {{X60s}} (Fn+Arrow Down)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Stop|#494949}} || stop playback || [[#xmodmap configuration|xmodmap]] || full || {{X60s}} (Fn+Arrow Up)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Next|#494949}} || play next || [[#xmodmap configuration|xmodmap]] || full || {{X60s}} (Fn+Arrow Right)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Previous|#494949}} || play previous || [[#xmodmap configuration|xmodmap]] || full || {{X60s}} (Fn+Arrow Left)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Power|#494949}} || shutdown || [[#ibm-acpi events|ibm-acpi]] || full || triggered on pressing 3secs, but notebook goes off on 5sec press&lt;br /&gt;
|-&lt;br /&gt;
| Display lid || blank screen || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| Ultrabay lid || announce ultrabay change || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| Dock eject || eject from dock || [[#ibm-acpi events|ibm-acpi]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet power|#494949}} || shutdown || [[#ibm-acpi events|ibm-acpi]] || full || triggered on pressing 3secs, but notebook goes off on 5sec press&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet orientation|#494949}} || rotates screen || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet shortcut|#494949}} || shortcut menu || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Esc|#494949}} || esc key || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Enter|#494949}} || enter key || [[#mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Up|#494949}} || up key || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Down|#494949}} || down key || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet (unlabeled)|#494949}} || down key || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Triggering key events==&lt;br /&gt;
===ibm-acpi events===&lt;br /&gt;
Some of the following events require a {{cmdroot|echo enable,0xffff &amp;gt;/proc/acpi/ibm/hotkey}} in order to make acpi able to get information on them. These events can be used to [[How to configure acpid|configure acpid]].&lt;br /&gt;
&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
|+ events triggered by [[ibm-acpi]] for {{path|/etc/acpi/events}} files. &lt;br /&gt;
! key !! event&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F1}} || ibm/hotkey HKEY 00000080 00001001&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F2}} || ibm/hotkey HKEY 00000080 00001002&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F3}} || ibm/hotkey HKEY 00000080 00001003&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F4}} || ibm/hotkey HKEY 00000080 00001004&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F5}} || ibm/hotkey HKEY 00000080 00001005&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F6}} || ibm/hotkey HKEY 00000080 00001006&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F7}} || ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F8}} || ibm/hotkey HKEY 00000080 00001008&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F9}} || ibm/hotkey HKEY 00000080 00001009&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F10}} || ibm/hotkey HKEY 00000080 0000100a&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F11}} || ibm/hotkey HKEY 00000080 0000100b&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F12}} || ibm/hotkey HKEY 00000080 0000100c&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Backspace}} || ibm/hotkey HKEY 00000080 0000100d&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Ins}} || ibm/hotkey HKEY 00000080 0000100e&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Del}} || ibm/hotkey HKEY 00000080 0000100f&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Home}}/{{key|Fn}}{{key|Pos1}} || ibm/hotkey HKEY 00000080 00001010&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|ThinkVantage|#495988}} ||ibm/hotkey HKEY 00000080 00001018&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Power|#494949}} || button/power PWRF 00000080 xxxxxxxx&lt;br /&gt;
|-&lt;br /&gt;
| Display lid || button/lid LID 00000080 xxxxxxxx&lt;br /&gt;
|-&lt;br /&gt;
| Ultrabay eject || ibm/bay MSTR 00000003 00000000&lt;br /&gt;
|-&lt;br /&gt;
| Ultrabay inserted || ibm/bay MSTR 00000001 00000000&lt;br /&gt;
|-&lt;br /&gt;
| Dock eject || ibm/dock GDCK 00000003 00000001&lt;br /&gt;
|-&lt;br /&gt;
| Wireless switch || ibm/hotkey HKEY 00000080 00007000&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
By disassembling and editing the DSDT, more events can be added.  HKEY events are triggered by calls to the MKHQ function, e.g. &amp;lt;tt&amp;gt;\_SB.PCI0.LPC.EC.HKEY.MHKQ(0Ã—1007)&amp;lt;/tt&amp;gt; will trigger &amp;quot;ibm/hotkey HKEY 00000080 00001007&amp;quot;.  Most of these can be found in &amp;lt;tt&amp;gt;_Qxx&amp;lt;/tt&amp;gt; methods within the DSDT, which are executed on embedded controller events, e.g. _Q10 is triggered by pressing Fn-F7.  You can add a call to MKHQ into an existing &amp;lt;tt&amp;gt;_Qxx&amp;lt;/tt&amp;gt; method to get it recognized by ibm-acpi as well as creating new &amp;lt;tt&amp;gt;_Qxx&amp;lt;/tt&amp;gt; methods, which if you're lucky will correspond to an EC event that IBM never used (e.g. A 770 will send Fn-Home/End/PgUp/PgDn to ibm-acpi if hacked in this fashion). For example, [http://www.wormnet.eu/ibm-g40/morebuttons.dsl this is a modified block of DSDT for a G40].&lt;br /&gt;
&lt;br /&gt;
=== Pure ACPI events ===&lt;br /&gt;
&lt;br /&gt;
A few keys can generate ACPI events of their own on certain ThinkPads, as long as they are masked off in the ibm-acpi hotkey's mask (or the hotkey feature is disabled in ibm-acpi).&lt;br /&gt;
&lt;br /&gt;
If you want the ThinkPad's BIOS and ACPI methods to know about these keys being pressed, you probably want to leave them masked out from ibm-acpi, and use their non-HKEY events listed below, instead.&lt;br /&gt;
&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
|+ events triggered by ACPI when hotkey is masked out or disabled. &lt;br /&gt;
! key !! event&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F4}} || button/sleep SLPB 00000080 00000001&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F12}} || ibm/hotkey HKEY 00000080 0000100c&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===tpb configuration===&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
|+ configuration keywords for [[tpb]] (to put in {{path|/etc/tpbrc}})&lt;br /&gt;
! key !! config keyword&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Access IBM|#495988}} or {{ibmkey|ThinkPad|#494949}} || THINKPAD&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Home|#494949}} || HOME&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Search|#494949}} || SEARCH&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Mail|#494949}} || MAIL&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Favorites|#494949}} || FAVORITES&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Reload|#494949}} || RELOAD&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Abort|#494949}} || ABORT&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Backward|#494949}} || BACKWARD&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Forward|#494949}} || FORWARD&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}} || FN&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Space}} || CALLBACK (zoom on/off)&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|PageUp}} || CALLBACK (thinklight on/off)&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F7}} || CALLBACK (display lcd/crt/both)&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|F8}} || CALLBACK (expand on/off)&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|Home}} / {{key|Fn}}{{key|Pos1}} || CALLBACK (brightness &amp;lt;percent&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}}{{key|End}} || CALLBACK (brightness &amp;lt;percent&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume up|#494949}} || CALLBACK (volume &amp;lt;percent&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume down|#494949}} || CALLBACK (volume &amp;lt;percent&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Volume mute|#494949}} || CALLBACK (mute on/off)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To all parameter keywords should be assigned the full path to the executables supposed to be started on key press.&lt;br /&gt;
The exectable provided for the CALLBACK keyword should take the parameters given in parentheses and act according to them.&lt;br /&gt;
If you want to use xmodmap for the HOME, SEARCH, MAIL, FAVORITES, RELOAD, ABORT, BACKWARD, FORWARD and FN keys you should&lt;br /&gt;
provide a &amp;lt;tt&amp;gt;XEVENTS OFF&amp;lt;/tt&amp;gt; in your {{path|/etc/tpbrc}}. &lt;br /&gt;
You can use an appropriate executable to [[How to inject fake keystrokes|inject fake keystrokes]].&lt;br /&gt;
&lt;br /&gt;
For Debian users, tpb is started from {{path|/etc/X11/Xsession.d/90tpb}}.&lt;br /&gt;
&lt;br /&gt;
'''Sound Button configuration'''&lt;br /&gt;
&lt;br /&gt;
''Note: Tested on T60p with Ubuntu 6.06 LTS''&lt;br /&gt;
&lt;br /&gt;
Most Thinkpads have a hardware sound mixer, thus the volumes buttons should work without configuration. However, this change is not reflected in the software mixer. tpb has a switch to enable software mixer support via OSS. The manual recommends this only for devices without a hardware mixer, but it also works for other hadware mixer enabled devices, even with the ALSA system. Just put MIXER ON in your {{path|/etc/tpbrc}} file and you can see the effect immediately in any ALSA mixer (e.g. kmix). For this to work you need write permissions to {{path|/dev/nvram}}.&lt;br /&gt;
&lt;br /&gt;
''Note: Tested on X21 with Ubuntu 6.06 LTS''&lt;br /&gt;
&lt;br /&gt;
On the ThinkPad X21 (and maybe some other older models) ACPI causes problems with tpb.  On an X21 using acpi the volume buttons would work occasionally, and the OSD for tpb functions would rarely work.  If a volume buttons was pressed too often, sometimes the computer would enter a low power (unplugged state) and would require a reboot.  The solution is to use APM instead of ACPI.  Instructions can be found in [[How_to_make_APM_work]].&lt;br /&gt;
&lt;br /&gt;
===KMilo configuration===&lt;br /&gt;
The programs to be executed by [[KMilo]] are configured via the KDE Control Center (&amp;lt;tt&amp;gt;kcontrol&amp;lt;/tt&amp;gt;), under &amp;lt;tt&amp;gt;System Administration --&amp;gt; IBM Thinkpad Laptop&amp;lt;/tt&amp;gt;. Note that you can use appropriate commands to [[How to inject fake keystrokes|inject fake keystrokes]].&lt;br /&gt;
&lt;br /&gt;
===xmodmap configuration===&lt;br /&gt;
xmodmap enables you to edit the modifier map and keymap tables that are used to translate keycodes into keysyms.&lt;br /&gt;
Understood? Well, basically it allows you to give the X server a dictionary for the translation of keycodes like &amp;quot;97&amp;quot; into more human readable synonyms like &amp;quot;Home&amp;quot;. This way xmodmap allows you to make the special keys of your keyboard known to X applications.&lt;br /&gt;
&lt;br /&gt;
To discover the keycode that a certain keypress produces, use the tool {{cmduser|xev}} &lt;br /&gt;
&lt;br /&gt;
Usually you should write your keycode-keysym associations into the file {{path|~/.Xmodmap}}. This file is usually read by the X session startup scripts of your system, so that the mappings automatically get included everytime you run the X server.&lt;br /&gt;
&lt;br /&gt;
The {{path|~/.Xmodmap}} lines for our purpose are in the form of&lt;br /&gt;
 keycode &amp;lt;keycode&amp;gt; = &amp;lt;keysym&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load the assocation using the command&lt;br /&gt;
&lt;br /&gt;
{{cmduser|xmodmap ~/.Xmodmap}} &lt;br /&gt;
&lt;br /&gt;
(some configurations do this automatically upon X startup). &lt;br /&gt;
&lt;br /&gt;
The following table shows the keycodes generated by the ThinkPad special keys and sensible keysyms to assign them to.&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
|+ keycodes and recommended keysyms&lt;br /&gt;
! key !! keycode !! keysym&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Access IBM|#495988}} or {{ibmkey|ThinkPad|#494949}} || 159 || XF86LaunchA&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Backward|#494949}} || 234 || XF86Back or F19&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Forward|#494949}} || 233 || XF86Forward or F20&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Play/Pause|#494949}} || 162 || XF86AudioPlay&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Stop|#494949}} || 164 || XF86AudioStop&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Next|#494949}} || 153 || XF86AudioNext&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Previous|#494949}} || 144 || XF86AudioPrev&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| {{ibmkey|Home|#494949}} || 178 || XF86HomePage&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Search|#494949}} || 229 || XF86Search&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Mail|#494949}} || 236 || XF86Mail&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Favorites|#494949}} || 230 || XF86AddFavorite or XF86Favorites&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Reload|#494949}} || 231 || XF86Reload&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Abort|#494949}} || 232 || XF86Stop&lt;br /&gt;
|-&lt;br /&gt;
| {{key|Fn}} || 227 || F35&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: You can also use xkeycaps (an X tool to display and edit the X keyboard mapping) to generate proper .Xmodmap.&lt;br /&gt;
&lt;br /&gt;
Note: if you are running [[tpb]] you might need to add the line &amp;lt;tt&amp;gt;XEVENTS=off&amp;lt;/tt&amp;gt; into your tpbrc to stop it from grabbing the key events and allow them to get through to X instead. See [[http://www.thinkwiki.org/wiki/Tpb]] for more detailed instruction on how to use tpb and xmodmap.&lt;br /&gt;
&lt;br /&gt;
Note: XF86Forward and XF86Back do not work correctly in Firefox. You may want to map them to F19 and F20 instead if you use Firefox.&lt;br /&gt;
&lt;br /&gt;
Note: The &amp;quot;XF86AudioPlay&amp;quot; etc. just works with a few programs. To make it work with more multimedia programs you have map the key to use something like [http://www.kde-apps.org/content/show.php/ReMoot?content=63140 ReMoot]. ReMoot is a command line wrapper that control 18 of the most common multimedia applications. &lt;br /&gt;
&lt;br /&gt;
=====Enabling the Windows and Menu Keys=====&lt;br /&gt;
On some systems the Windows and Menu keys may not be recognized.  You can enable then by&lt;br /&gt;
making the following changes:&lt;br /&gt;
&lt;br /&gt;
        keycode 115 = F13&lt;br /&gt;
        keycode 227 = F35&lt;br /&gt;
&lt;br /&gt;
F13 and F35 are used for the Windows and and Menu keys respectively.  Labelling keycpode 227 as &amp;quot;Menu&amp;quot; may conflict with the right-mouse-click event.&lt;br /&gt;
&lt;br /&gt;
=====Using Caps Lock as Super L (Windows key)=====&lt;br /&gt;
You can easily use Caps Lock as Win key by adding the following in your ~/.Xmodmap:&lt;br /&gt;
        ! No Caps Lock&lt;br /&gt;
        clear lock&lt;br /&gt;
        ! Caps Lock as Win key&lt;br /&gt;
        add mod4 = Caps_Lock&lt;br /&gt;
=====NumLock=====&lt;br /&gt;
On the ThinkPad {{600}}, {{T20}}, {{T21}}, {{T22}}, {{T30}}, {{X20}}, {{X21}},  {{X31}}, {{X40}}, {{T42p}}, {{T43}}, {{R51}}, {{R52}} and possibly other models, X does not recognize the keycode for {{key|NumLk}} = {{key|Shift}}+{{key|ScrLk}}. To fix this, add the following to {{path|~/.Xmodmap}} in your home directory or {{path|/etc/X11/Xmodmap}} and run &amp;lt;tt&amp;gt;xmodmap&amp;lt;/tt&amp;gt;, ex: &amp;lt;tt&amp;gt;xmodmap ~/.Xmodmap&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 keycode 77 = Num_Lock&lt;br /&gt;
&lt;br /&gt;
This configuration also enables the respective LED.&lt;br /&gt;
&lt;br /&gt;
Please note, pressing the {{key|Shift}}+{{key|ScrLk}} key combination, without first following the above configuration, will start an accessibility feature, which will allow the numeric keypad to maneuver the mouse pointer.  Starting this accessibility feature and subsequently running xmodmap, as described above, results in the accessibility feature and the numeric lock LED functioning simultaneously.  As such, the above configuration should be completed before the accessibility feature is started in order to produce numbers.&lt;br /&gt;
&lt;br /&gt;
===Mapping keys with setkeycodes===&lt;br /&gt;
You can use the setkeycodes command to remap certain keys. I.e. you can use {{cmdroot|setkeycodes 6e 109 6d 104 69 28 6b 1}} to map the Tablets Up and Down keys to the standard PageUp and PageDown keys and Tablet Escape and Enter to their respective keys.&lt;br /&gt;
&lt;br /&gt;
The following table shows the keycodes generated by the ThinkPad keys.&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
|+ keycodes&lt;br /&gt;
! key !! keycode&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet orientation|#494949}} || 0x6d&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Shortcut|#494949}} || 0x6e&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Esc|#494949}} || 0x6b&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Enter|#494949}} || 0x69&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Up|#494949}} || 0x68&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet Down|#494949}} || 0x6c&lt;br /&gt;
|-&lt;br /&gt;
| {{ibmkey|Tablet (unlabeled)|#494949}} || 0x67&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Example Applications==&lt;br /&gt;
===Web Browsers===&lt;br /&gt;
====Firefox====&lt;br /&gt;
&lt;br /&gt;
There are various ways to assign actions to the browser keys. The easiest way is to install [http://mozilla.dorando.at/keyconfig.xpi keyconfig.xpi] from http://mozilla.dorando.at, which adds a menu entry Tools-&amp;gt;Keyconfig. Then you can assign any action you want to the F19/F20 keys (you still need to create {{path|~/.Xmodmap}} as explained above).&lt;br /&gt;
&lt;br /&gt;
The remaining discussion gives you various more complicated ways to achieve the same thing. &lt;br /&gt;
To have firefox make use of the browser keys you need to modify one of its files{{footnote|4}}.&lt;br /&gt;
To do this you will first need to extract it from the {{path|browser.jar}} archive. Do...&lt;br /&gt;
&lt;br /&gt;
:{{cmdroot|cd &amp;lt;firefox-directory&amp;gt;/chrome}}&amp;lt;br /&amp;gt;&lt;br /&gt;
:{{cmdroot|unzip browser.jar}}&lt;br /&gt;
&lt;br /&gt;
The file of interest is {{path|content/browser/browser.xul}}. Edit it {and don't forget to make a backup copy first}...&lt;br /&gt;
:{{cmdroot|vi content/browser/browser.xul}}&lt;br /&gt;
&lt;br /&gt;
Look for the '''&amp;lt;keyset id=&amp;quot;mainKeyset&amp;quot;&amp;gt;''' section and add the following lines within...&lt;br /&gt;
 &amp;lt;key id=&amp;quot;goBackKb&amp;quot; keycode=&amp;quot;VK_F19&amp;quot; command=&amp;quot;Browser:Back&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;key id=&amp;quot;goForwardKb&amp;quot; keycode=&amp;quot;VK_F20&amp;quot; command=&amp;quot;Browser:Forward&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Command you need for Next Tab &lt;br /&gt;
 &amp;lt;key id=&amp;quot;goBackTabKb&amp;quot; keycode=&amp;quot;VK_F19&amp;quot; oncommand=&amp;quot;gBrowser.mTabContainer.advanceSelectedTab(-1)&amp;quot; /&amp;gt;&lt;br /&gt;
For the Previous Tab &lt;br /&gt;
 &amp;lt;key id=&amp;quot;goForwardTabKb&amp;quot; keycode=&amp;quot;VK_F20&amp;quot; oncommand=&amp;quot;gBrowser.mTabContainer.advanceSelectedTab(1)&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now save the file and repackage the {{path|browser.jar}} archive...&lt;br /&gt;
:{{cmdroot|zip -rD0 browser.jar content/browser/}}&lt;br /&gt;
&lt;br /&gt;
That's it.&lt;br /&gt;
&lt;br /&gt;
{{HINT|For Firefox 2.0, just edit &amp;lt;firefox-directory&amp;gt;/chrome/browser/content/browser/browser.xul}}&lt;br /&gt;
&lt;br /&gt;
{{HINT|Outdated: Another interesting Page on Firefox is http://dqd.com/~mayoff/notes/thinkpad/dqdnavkeys/ It uses different key mappings (F19 resp. F20) but a ready [http://dqd.com/~mayoff/notes/thinkpad/dqdnavkeys/dqdnavkeys-1.2.xpi .xpi] is provided which is pretty comfortable. However, this xpi file does not install on Firefox 1.5. or later.}}&lt;br /&gt;
&lt;br /&gt;
{{HINT|Outdated: You can also use the [http://extensionroom.mozdev.org/more-info/keyconfig keyconfig] extension to configure custom keys.  This extension works with Firefox 1.5 but not with Firefox 2.0. The Command you need for Next Tab is gBrowser.mTabContainer.advanceSelectedTab(1,true); For Previous Tab its gBrowser.mTabContainer.advanceSelectedTab(-1,true); }}.&lt;br /&gt;
&lt;br /&gt;
====Konqueror====&lt;br /&gt;
KDE allows you set key mappings for KDE applications (Go to KMenu &amp;gt; System &amp;gt; Control Center &amp;gt; Regional &amp;amp; Accessibility &amp;gt; Keyboard Shortcuts). By default (at least in KDE 3.5), XF86Back and XF86Forward are set as alternatives to Alt-Left and Alt-Right, and are mapped to KDE Back and Forward navigation actions.  &lt;br /&gt;
&lt;br /&gt;
If you use Konqueror as your only browser, you only need to set up {{path|~/.Xmodmap}} as described [[#xmodmap configuration|above]] to assign ThinkPad back/forward keys to the symbols XF86Back/XF86Forward. This also make these keys work for other KDE applications such as Quanta Plus, KPackage and so on (not all KDE applications honor this setting, e.g. KDE help system doesn't).&lt;br /&gt;
&lt;br /&gt;
If you want to use Firefox, however, the above settings do not work. You will have to map ThinkPad back/forward keys to F19/F20 as described [[#Firefox|above]], and change KDE navigation key settings to use F19/F20 instead of the default.&lt;br /&gt;
&lt;br /&gt;
====Opera====&lt;br /&gt;
However this isn't a simple configration file, you can set your browser manually.&amp;lt;br /&amp;gt;&lt;br /&gt;
Go to &amp;lt;i&amp;gt;Tool &amp;gt; Settings &amp;gt; Mouse and keyboard &amp;gt; Keyboard settings &amp;gt; Edit &amp;gt; Browser Window&amp;lt;/i&amp;gt;. There add F19 - Back and F20 - Forward. Now you can surf using your TP keys ;-)&lt;br /&gt;
&lt;br /&gt;
===Window Managers===&lt;br /&gt;
====fvwm====&lt;br /&gt;
To get the {{ibmkey|Forward|#494949}} and {{ibmkey|Backward|#494949}} keys to cycle through pages in the virtual desktop, add this to your {{path|~/.fvwmrc}}:&lt;br /&gt;
 Key    XF86Back     A      A   Scroll     -100000   0&lt;br /&gt;
 Key    XF86Forward  A      A   Scroll     +100000   0&lt;br /&gt;
If you use multiple virtual desktops, you could instead use the keys to flip between them by using GotoDesk.&lt;br /&gt;
&lt;br /&gt;
====fluxbox====&lt;br /&gt;
To get the keys to cycle through pages in the virtual desktop, add this to your {{path|~/.fluxbox/keys}}:&lt;br /&gt;
 None F19 :PrevWorkspace&lt;br /&gt;
 None F20 :NextWorkspace&lt;br /&gt;
&lt;br /&gt;
====pekwm configuration====&lt;br /&gt;
You can make the two browser keys switch workspaces in pekwm, by adding the following two lines to the {{path|~/.pekwm/keys}} file:&lt;br /&gt;
 KeyPress = &amp;quot;Mod1 XF86Back&amp;quot; { Actions = &amp;quot;GoToWorkspace prev&amp;quot; }&lt;br /&gt;
 KeyPress = &amp;quot;Mod1 XF86Forward&amp;quot; { Actions = &amp;quot;GoToWorkspace next&amp;quot; }&lt;br /&gt;
&lt;br /&gt;
====pwm====&lt;br /&gt;
Another example how to use these two keys to switch between pwm tabs. These two lines should be added to {{path|~/.pwm/keys-default.conf}} or {{path|/etc/pwm/keys-default.conf}}:&lt;br /&gt;
 kbind &amp;quot;Back&amp;quot;, &amp;quot;switch_rot&amp;quot;, -1&lt;br /&gt;
 kbind &amp;quot;Forward&amp;quot;, &amp;quot;switch_rot&amp;quot;, 1&lt;br /&gt;
&lt;br /&gt;
====IceWM====&lt;br /&gt;
To make IceWM cycle workspaces using the {{ibmkey|Forward|#494949}} and {{ibmkey|Backward|#494949}} keys, change these two options in {{path|~/.icewm/preferences}} (Provided you assigned keysyms F19 and F20 with xmodmap):&lt;br /&gt;
 # &amp;quot;Previous workspace&amp;quot; shortcut&lt;br /&gt;
 KeySysWorkspacePrev=&amp;quot;F19&amp;quot;&lt;br /&gt;
 # &amp;quot;Next workspace&amp;quot; shortcut&lt;br /&gt;
 KeySysWorkspaceNext=&amp;quot;F20&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Gnome/metacity ====&lt;br /&gt;
&lt;br /&gt;
Follow the [https://wiki.ubuntu.com/Keybindings Ubuntu guide].&lt;br /&gt;
&lt;br /&gt;
===Other Uses===&lt;br /&gt;
====Console tools configuraton====&lt;br /&gt;
To make the {{ibmkey|Forward|#494949}} and {{ibmkey|Backward|#494949}} keys useful in console, add this to your keymap ({{path|/etc/console/boottime.kmap.gz}} in {{Debian}}):&lt;br /&gt;
 keycode 158 = Decr_Console&lt;br /&gt;
 keycode 159 = Incr_Console&lt;br /&gt;
&lt;br /&gt;
Alternatively you can load this script (perhaps on system startup) to enable Backward/Forward button console (VT) switch:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 echo keycode 158 = Decr_Console | loadkeys&lt;br /&gt;
 echo keycode 159 = Incr_Console | loadkeys&lt;br /&gt;
&lt;br /&gt;
It should work with any distro.&lt;br /&gt;
&lt;br /&gt;
==External Sources==&lt;br /&gt;
*[http://www-307.ibm.com/pc/support/site.wss/document.do?lndocid=MIGR-51537 IBMs page on configuring the ThinkPad buttons (ThinkPad, Access IBM, Mail, Search, and Home buttons) under Linux]&lt;br /&gt;
*[http://dqd.com/~mayoff/notes/thinkpad/dqdnavkeys/ Rob Mayoffs page on using IBM Keyboard Navigation Keys in Linux Mozilla and Firefox]&lt;br /&gt;
*[http://snarfed.org/space/thinkpad+keys+in+firefox Ryan Barretts blog article about using the browser keys in Firefox]&lt;br /&gt;
*[http://chaotika.org/~bluesceada/?page=soft&amp;amp;sub=thinkpad#acpibutn DennisG's help to get the ibm-acpi buttons do useful things] on a {{Z61e}} and possibly {{Z61m}}, {{Z61t}} and {{Z61p}}&lt;br /&gt;
&lt;br /&gt;
{{footnotes|&lt;br /&gt;
#Note that the associated functionality for Fn-F* key combinations is not consistent amongst all ThinkPads. We are maintaining [[Default meanings of special keys|a table of associated meanings]].&lt;br /&gt;
#if there are more than one tool listed, one is sufficient&lt;br /&gt;
#'full' means you can completely reassign any action to be triggered by the key, 'additional actions' means you can trigger actions in addition to the standard function of the key, which can not be changed.&lt;br /&gt;
#Thanks go to Ryan Barrett for writing the [http://snarfed.org/space/thinkpad+keys+in+firefox little howto] on [http://snarfed.org/space/start his blog].&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34375</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34375"/>
		<updated>2007-11-09T16:51:57Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This setup will let you use fn-F7 key combination to toggle between internal, external, or both screens.  Tested on ThinkPad X60s running Fedora 8.&lt;br /&gt;
&lt;br /&gt;
Note: you will need to change the internal and external resolution until someone fixes this script to figure it out from xrandr, you may also need to change output names from &amp;quot;VGA&amp;quot; and &amp;quot;LVDS&amp;quot; to what your xrandr tells you.&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
# fn-F7&lt;br /&gt;
event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
action=/usr/local/sbin/thinkpad-f7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-f7:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
EXTERNAL_OUTPUT=VGA&lt;br /&gt;
EXTERNAL_MODE=1600x1200&lt;br /&gt;
&lt;br /&gt;
INTERNAL_OUTPUT=LVDS&lt;br /&gt;
INTERNAL_MODE=1024x768&lt;br /&gt;
&lt;br /&gt;
DO=$(basename $0)&lt;br /&gt;
&lt;br /&gt;
SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
&lt;br /&gt;
STATE_FILE=/var/lib/thinkpad/screen.state;&lt;br /&gt;
if [ ! -e $STATE_FILE ]; then&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
STATE=$(cat $STATE_FILE)&lt;br /&gt;
&lt;br /&gt;
function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --mode $EXTERNAL_MODE --left-of LVDS&amp;quot;&lt;br /&gt;
        echo &amp;quot;external&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --mode $INTERNAL_MODE --right-of VGA&amp;quot;&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output $EXTERNAL_OUTPUT --mode $EXTERNAL_MODE --left-of LVDS&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --mode $INTERNAL_MODE --right-of VGA&amp;quot;&lt;br /&gt;
        echo &amp;quot;both&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        thinkpad-toggle | thinkpad-f7)&lt;br /&gt;
                case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                        internal)&lt;br /&gt;
                                screen_external&lt;br /&gt;
                                ;;&lt;br /&gt;
                        external)&lt;br /&gt;
                                screen_both&lt;br /&gt;
                                ;;&lt;br /&gt;
                        both)&lt;br /&gt;
                                screen_internal&lt;br /&gt;
                                ;;&lt;br /&gt;
                        *)&lt;br /&gt;
                                screen_internal&lt;br /&gt;
                                ;;&lt;br /&gt;
                esac&lt;br /&gt;
                ;;&lt;br /&gt;
        thinkpad-dock)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        thinkpad-undock)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: rename to thinkpad-dock, thinkpad-undock, or thinkpad-toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As root,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mkdir -p /var/lib/thinkpad&lt;br /&gt;
echo &amp;quot;internal&amp;quot; &amp;gt; /var/lib/thinkpad/screen.state&lt;br /&gt;
chmod 755 /usr/local/sbin/thinkpad-f7&lt;br /&gt;
service acpid restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34374</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34374"/>
		<updated>2007-11-09T16:45:50Z</updated>

		<summary type="html">&lt;p&gt;Seva: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This setup will let you use fn-F7 key combination to toggle between internal, external, or both screens.  Tested on ThinkPad X60s running Fedora 8.&lt;br /&gt;
&lt;br /&gt;
Note: you will need to change the internal and external resolution until someone fixes this script to figure it out from xrandr.&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
# fn-F7&lt;br /&gt;
event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
action=/usr/local/sbin/thinkpad-f7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-f7:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
DO=$(basename $0)&lt;br /&gt;
&lt;br /&gt;
SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
&lt;br /&gt;
STATE_FILE=/var/lib/thinkpad/screen.state;&lt;br /&gt;
if [ ! -e $STATE_FILE ]; then&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
STATE=$(cat $STATE_FILE)&lt;br /&gt;
&lt;br /&gt;
function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output LVDS --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output VGA --mode 1600x1200 --left-of LVDS&amp;quot;&lt;br /&gt;
        echo &amp;quot;external&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output VGA --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output LVDS --mode 1024x768 --right-of VGA&amp;quot;&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output VGA --mode 1600x1200 --left-of LVDS&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output LVDS --mode 1024x768 --right-of VGA&amp;quot;&lt;br /&gt;
        echo &amp;quot;both&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        thinkpad-toggle | thinkpad-f7)&lt;br /&gt;
                case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                        internal)&lt;br /&gt;
                                screen_external&lt;br /&gt;
                                ;;&lt;br /&gt;
                        external)&lt;br /&gt;
                                screen_both&lt;br /&gt;
                                ;;&lt;br /&gt;
                        both)&lt;br /&gt;
                                screen_internal&lt;br /&gt;
                                ;;&lt;br /&gt;
                        *)&lt;br /&gt;
                                screen_internal&lt;br /&gt;
                                ;;&lt;br /&gt;
                esac&lt;br /&gt;
                ;;&lt;br /&gt;
        thinkpad-dock)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        thinkpad-undock)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: rename to thinkpad-dock, thinkpad-undock, or thinkpad-toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As root,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mkdir -p /var/lib/thinkpad&lt;br /&gt;
echo &amp;quot;internal&amp;quot; &amp;gt; /var/lib/thinkpad/screen.state&lt;br /&gt;
chmod 755 /usr/local/sbin/thinkpad-f7&lt;br /&gt;
service acpid restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34373</id>
		<title>Sample Fn-F7 script</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Sample_Fn-F7_script&amp;diff=34373"/>
		<updated>2007-11-09T16:41:35Z</updated>

		<summary type="html">&lt;p&gt;Seva: â†Created page with 'Tested on ThinkPad X60s running Fedora 8  Create /etc/acpi/events/thinkpad.conf:  &amp;lt;code&amp;gt; # fn-F7 event=ibm/hotkey HKEY 00000080 00001007 action=/usr/local/sbin/thinkpad-f7...'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Tested on ThinkPad X60s running Fedora 8&lt;br /&gt;
&lt;br /&gt;
Create /etc/acpi/events/thinkpad.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
# fn-F7&lt;br /&gt;
event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
action=/usr/local/sbin/thinkpad-f7&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /usr/local/sbin/thinkpad-f7:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
DO=$(basename $0)&lt;br /&gt;
&lt;br /&gt;
SU=&amp;quot;su $(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $1}') -c&amp;quot;&lt;br /&gt;
export DISPLAY=$(w -h -s | grep &amp;quot;:[0-9]&amp;quot; | head -1 | awk '{print $3}')&lt;br /&gt;
&lt;br /&gt;
STATE_FILE=/var/lib/thinkpad/screen.state;&lt;br /&gt;
if [ ! -e $STATE_FILE ]; then&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
STATE=$(cat $STATE_FILE)&lt;br /&gt;
&lt;br /&gt;
function screen_external(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output LVDS --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output VGA --mode 1600x1200 --left-of LVDS&amp;quot;&lt;br /&gt;
        echo &amp;quot;external&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function screen_internal(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output VGA --off&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output LVDS --mode 1024x768 --right-of VGA&amp;quot;&lt;br /&gt;
        echo &amp;quot;internal&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function screen_both(){&lt;br /&gt;
        $SU &amp;quot;xrandr --output VGA --mode 1600x1200 --left-of LVDS&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output LVDS --mode 1024x768 --right-of VGA&amp;quot;&lt;br /&gt;
        echo &amp;quot;both&amp;quot; &amp;gt; $STATE_FILE&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
case &amp;quot;$DO&amp;quot; in&lt;br /&gt;
        thinkpad-toggle | thinkpad-f7)&lt;br /&gt;
                case &amp;quot;$STATE&amp;quot; in&lt;br /&gt;
                        internal)&lt;br /&gt;
                                screen_external&lt;br /&gt;
                                ;;&lt;br /&gt;
                        external)&lt;br /&gt;
                                screen_both&lt;br /&gt;
                                ;;&lt;br /&gt;
                        both)&lt;br /&gt;
                                screen_internal&lt;br /&gt;
                                ;;&lt;br /&gt;
                        *)&lt;br /&gt;
                                screen_internal&lt;br /&gt;
                                ;;&lt;br /&gt;
                esac&lt;br /&gt;
                ;;&lt;br /&gt;
        thinkpad-dock)&lt;br /&gt;
                screen_internal&lt;br /&gt;
                ;;&lt;br /&gt;
        thinkpad-undock)&lt;br /&gt;
                screen_external&lt;br /&gt;
                ;;&lt;br /&gt;
        *)&lt;br /&gt;
                echo &amp;quot;usage: rename to thinkpad-dock, thinkpad-undock, or thinkpad-toggle&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
                ;;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As root,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mkdir -p /var/lib/thinkpad&lt;br /&gt;
echo &amp;quot;internal&amp;quot; &amp;gt; /var/lib/thinkpad/screen.state&lt;br /&gt;
chmod 755 /usr/local/sbin/thinkpad-f7&lt;br /&gt;
service acpid restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seva</name></author>
		
	</entry>
</feed>