[mdlug] Command-line utility to set screen resolution?
Raymond McLaughlin
driveray at ameritech.net
Mon Nov 27 23:53:34 EST 2006
Ingles, Raymond wrote:
> I've got several commercial games (my only Windows use) moved over now
> to my Ubuntu 6.06 installation.
>
> Two that are slight sticking points - "Return to Castle Wolfenstein" and
> "American McGee's Alice". The former has a proper Linux port, and the latter
> runs apparently flawlessly under Wine. But they mess up the screen resolution
> when they exit.
>
> Now, both are run via startup scripts. If there was a command-line tool to
> change the resolution, I'd just add a call to that to the scripts. But I
> haven't turned one up in my searches. Anyone know of a tool like that? I
> think I could hack one up with a bit of effort but I gotta believe someone's
> already done this somewhere...
>
> Sincerely,
>
> Ray Ingles (313) 227-2317
The way I handle full screen games like this is to run them in a
separate X session. SuSE makes this easy, ubuntu is a bit more challenging.
The basic scheme is to run the commands
WINDOWMANAGER=<some executable>
startx -- :1
to start a second X session on the second X terminal. Unfortunately
ubuntu doesn't make it easy to pick your windowmanager. You will need to
create a file ~/.xinitrc containing the line:
exec $WINDOWMANAGER
Once you have this test it out:
WINDOWMANAGER=xterm
startx -- :1
When you exit the called program you should drop back to the terminal
you started on. In this case, type "exit" in the xterm.
This should work from a real tty, or an xterminal. If you get this much
working you can then go ahead and create "pseudo-windowmanagers",
executable scripts (on your $PATH) containing the lines needed to start
your desired programs, i.e.
#! /bin/bash
cd ".wine/c_drive/Program Files/Alice"
wine ".wine/c_drive/Program Files/Alice/alice.exe"
Some programs, such as quake3, work well when run directly, (ie
WINDOWMANAGER=/usr/local/games/quake3/quake3). But if you need a more
complex command line then a pseudo-windowmanager script works better.
Some pseudo-windowmanagers I regularly use are like these:
pts/1 $ cat /usr/local/games/quake/quakewm
#!/bin/bash
cd /usr/local/games/quake
/usr/local/games/quake/quake.x11 -sound nodma -mem 256 -winsize 1024\ 768
pts/1 $ cat ~/bin/vnc-newbie
while true; do vncviewer -passwd ~/.vnc/passwd.newbie -fullscreen\
192.168.1.198; done
Of course if you get this much working from a command console, you
should able to script the "WINDOWMANAGER=..." and "startx -- :1" parts,
and then associate the script with a desktop icon.
This might sound like a bit of work, but it can be a useful technique.
If only more distros included a proper ~/.xinitrc in their standard
install.
In your case the program in the second X session can do whatever it
wants with the resolution, your original session should be as it was
when you exit (or Ctrl+Alt+F7) back to your desktop.
I hope this helps
Raymond McLaughlin
More information about the mdlug
mailing list