<?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=Bubeck</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=Bubeck"/>
	<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/wiki/Special:Contributions/Bubeck"/>
	<updated>2026-05-05T13:35:34Z</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=34432</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=34432"/>
		<updated>2007-11-11T20:34:25Z</updated>

		<summary type="html">&lt;p&gt;Bubeck: change LVDS and VGA to use user-defined constants&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 $INTERNAL_OUTPUT&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 $EXTERNAL_OUTPUT&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 $INTERNAL_OUTPUT&amp;quot;&lt;br /&gt;
        $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --mode $INTERNAL_MODE --right-of $EXTERNAL_OUTPUT&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>Bubeck</name></author>
		
	</entry>
</feed>