<?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=Mflechl</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=Mflechl"/>
	<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/wiki/Special:Contributions/Mflechl"/>
	<updated>2026-05-09T08:45:08Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.12</generator>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Talk:Sample_Fn-F7_script&amp;diff=37874</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=37874"/>
		<updated>2008-05-31T14:50:38Z</updated>

		<summary type="html">&lt;p&gt;Mflechl: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;----&lt;br /&gt;
&lt;br /&gt;
Using Fedora 9 on a Thinkpad R50e, and works like a charm for me - only had to do one modification:&lt;br /&gt;
If the environment is such that X_USER equals USER, then the version with citation marks - like in&lt;br /&gt;
&lt;br /&gt;
 $SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
&lt;br /&gt;
does not work, bash would complain that the command was not found.&lt;br /&gt;
It would then have to be&lt;br /&gt;
&lt;br /&gt;
 $SU xrandr --output $INTERNAL_OUTPUT --off&lt;br /&gt;
&lt;br /&gt;
However, this does not work anymore then as soon as $SU is not empty.&lt;br /&gt;
&lt;br /&gt;
The simplest solution - can surely be done in a more elegant way - is thus to replace e.g. the first two lines of this kind with&lt;br /&gt;
&lt;br /&gt;
       if [ -z &amp;quot;$SU&amp;quot; ]; then&lt;br /&gt;
           xrandr --output $INTERNAL_OUTPUT --off&lt;br /&gt;
           xrandr --output $EXTERNAL_OUTPUT --auto&lt;br /&gt;
       else&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;
       fi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thanks a lot! --mflechl&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&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;
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>Mflechl</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Talk:Sample_Fn-F7_script&amp;diff=37873</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=37873"/>
		<updated>2008-05-31T14:50:05Z</updated>

		<summary type="html">&lt;p&gt;Mflechl: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;----&lt;br /&gt;
&lt;br /&gt;
Using Fedora 9 on a Thinkpad R50e, and works like a charm for me - only had to do one modification:&lt;br /&gt;
If the environment is such that X_USER equals USER, then the version with citation marks - like in&lt;br /&gt;
&lt;br /&gt;
$SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
&lt;br /&gt;
does not work, bash would complain that the command was not found.&lt;br /&gt;
It would then have to be&lt;br /&gt;
&lt;br /&gt;
$SU xrandr --output $INTERNAL_OUTPUT --off&lt;br /&gt;
&lt;br /&gt;
However, this does not work anymore then as soon as $SU is not empty.&lt;br /&gt;
&lt;br /&gt;
The simplest solution - can surely be done in a more elegant way - is thus to replace e.g. the first two lines of this kind with&lt;br /&gt;
&lt;br /&gt;
       if [ -z &amp;quot;$SU&amp;quot; ]; then&lt;br /&gt;
           xrandr --output $INTERNAL_OUTPUT --off&lt;br /&gt;
           xrandr --output $EXTERNAL_OUTPUT --auto&lt;br /&gt;
	else&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;
      	fi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thanks a lot! --mflechl&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&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;
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>Mflechl</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Talk:Sample_Fn-F7_script&amp;diff=37872</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=37872"/>
		<updated>2008-05-31T14:33:09Z</updated>

		<summary type="html">&lt;p&gt;Mflechl: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;----&lt;br /&gt;
&lt;br /&gt;
Using Fedora 9 on a Thinkpad R50e, and works like a charm for me - only had to do one modification:&lt;br /&gt;
If the environment is such that X_USER equals USER, then the version with citation marks - like in&lt;br /&gt;
&lt;br /&gt;
$SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
&lt;br /&gt;
does not work, bash would complain that the command was not found.&lt;br /&gt;
It would then have to be&lt;br /&gt;
&lt;br /&gt;
$SU xrandr --output $INTERNAL_OUTPUT --off&lt;br /&gt;
&lt;br /&gt;
However, this does not work anymore then as soon as $SU is not empty. &lt;br /&gt;
&lt;br /&gt;
Thanks a lot! --mflechl&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&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;
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>Mflechl</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Talk:Sample_Fn-F7_script&amp;diff=37871</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=37871"/>
		<updated>2008-05-31T14:29:49Z</updated>

		<summary type="html">&lt;p&gt;Mflechl: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;----&lt;br /&gt;
&lt;br /&gt;
Using Fedora 9 on a Thinkpad R50e, and works like a charm for me - only had to do one modification:&lt;br /&gt;
Had to remove all citation marks like in&lt;br /&gt;
&lt;br /&gt;
$SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
&lt;br /&gt;
thus, having now&lt;br /&gt;
&lt;br /&gt;
$SU xrandr --output $INTERNAL_OUTPUT --off&lt;br /&gt;
&lt;br /&gt;
otherwise bash would complain that the command was not found.&lt;br /&gt;
&lt;br /&gt;
Thanks a lot! --mflechl&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&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;
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>Mflechl</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Talk:Sample_Fn-F7_script&amp;diff=37870</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=37870"/>
		<updated>2008-05-31T12:50:52Z</updated>

		<summary type="html">&lt;p&gt;Mflechl: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Using Fedora 9 on a Thinkpad R50e, and works like a charm for me - only had to do one modification:&lt;br /&gt;
Had to remove all citation marks like in&lt;br /&gt;
$SU &amp;quot;xrandr --output $INTERNAL_OUTPUT --off&amp;quot;&lt;br /&gt;
thus, having now&lt;br /&gt;
$SU xrandr --output $INTERNAL_OUTPUT --off&lt;br /&gt;
otherwise bash would complain that the command was not found.&lt;br /&gt;
&lt;br /&gt;
Thanks a lot! --mflechl&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&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;
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>Mflechl</name></author>
		
	</entry>
</feed>