[plug] X resolutions for presentations using a laptop

Anthony J. Breeds-Taurima tony at cantech.net.au
Tue Aug 6 10:56:27 WST 2002


On 6 Aug 2002, Bill Kenworthy wrote:

> Using the ctrl-alt-+/- keys to switch resolutions in X magnifies the
> screen in a virtual desktop in all versions of X that I have used. 
> Instead, I need to be able to switch resolutions to so I can have a
> normal desktop at each resolution.  Reading the X docs and trying a few
> different setups has not allowed me to do this yet.

When you "shrink" your physical res. from say "1280x1024" to "1024x768",
then X _will_ leave your desktop size at the latter.  TTBOMK there is no
way to stop that from happening without exiting X altogther and restarting it
with a different/modified config file.

> The reason is when I use the laptop for a presentation, I have to boot
> it connected to the projector for X to start in the correct resolution
> (usually 1024x768), or it defaults to the LCD 1400x1050 unless I edit
> the config file for the session beforehand (preset the default to
> 1024x768).

Make yourself a script to set the "default" X res and then startx for you
ie:
	$ runX 1024x768

Where runX is something like:
#!/usr/bin/perl -i.bak

$res=shift || die;
@ARGV='/etc/X11/XF86Config-4';
undef $/;
while (<>) {
	s/(__MODE_INDICATOR__\n)(^.*)/$1\"$res\"/im;
	print;
}
exec '/usr/X11R6/bin/startx';

In theory what this does is:
Get the res you want from the command line (ie 1024x768)
Use perl magic to:
	1. make a backup of the /etc/X11/XF86Config-4 file
	2. read the whole /etc/X11/XF86Config-4 into memory
find the line in /etc/X11/XF86Config-4 that end in  "__MODE_INDICATOR__"
Then change the whole line below it to be the res you supplied on thr command
line.
Save file to disk,
run startx

The main problem with this approach is, you need to be able to write to 
/etc/X11/XF86Config-4 to do it, It is effecyivly what you currently do
but less manual.
 
Yours Tony

   Jan 22-25 2003           Linux.Conf.AU            http://linux.conf.au/
		  The Australian Linux Technical Conference!



More information about the plug mailing list