Ubuntu – Start a second X session with different resolution and sound

pulseaudiowinexorg

I have two screens hooked together with twinview. Some applications treat it as one big 3840*1200 panel but that's pretty undesirable in first person shooters as your sights end up in the gap between the two screens.

So I usually run Wine games in a 1920*1200px window. The window manager makes it full-screen on one screen and that works great for some games. However some games lag and that allows the mouse to fly out the side of the Wine window, causing my player to spin like a fox on drugs.

And then there are a whole load of native games (X3, OpenArena, Quake4, QuakeWars, etc) that don't have a good windowed mode. Using windowed mode on X3 results in the mouse becoming uber-sensitive.

Wouldn't it be nice if I could launch some games in a new X session that just used one screen?!

It would. I've got as far as this for Steam:

#!/bin/sh

X :3 -ac & nvidia-settings --load-config-only
sleep 10 # wait for X to catch up

cd ~/.wine/drive_c/Program\ Files/Steam/
DISPLAY=:3 WINEDEBUG=-all wine "Steam.exe"

Now this technically uses two screens but when games launch in fullscreen mode once they've already been set to 1920*1200, they seem to adapt and use one of my xorg.conf metamodes. It would be better if I could explicitly state the mode in this executable. Is there a way to do that?

There's also no sound. I've got the WinePulse patch so I just need to get PulseAudio hooked into this session (or vice versa) and I'm good to go for now, I think.

Edit: Ralf picked up on a few things but missed (or misconstrued) some others. This is probably down to my over-verbose question. Despite the length of the post, I only have two problems.

Here are my problems in a succinct setting:

  • How can I start a new X session with a specified resolution? I would preferably like to specify an existing metamode or the exact resolution when I call X.

  • How can I get applications on the new X session talking with the right PulseAudio server? At the moment, they don't seem to line up. I've tested this with totem, not just Wine apps.

Best Answer

To answer your question more specifically. You can use nvidia-settings to change the meta-mode. A fragment from nvidia-settings --help:

-a, --assign=[ASSIGN]
  The ASSIGN argument to the '--assign' commandline option is of the form:

    {DISPLAY}/{attribute name}[{display devices}]={value}

  This assigns the attribute {attribute name} to the value {value} on the X
  Display {DISPLAY}.  {DISPLAY} follows the usual {host}:{display}.{screen}
  syntax of the DISPLAY environment variable and is optional; when it is
  not specified, then it is implied following the same rule as the
  --ctrl-display option.  If the X screen is not specified, then the
  assignment is made to all X screens.  Note that the '/' is only required
  when {DISPLAY} is present.

  {DISPLAY} can additionally include a target specification to direct an
  assignment to something other than an X screen.  A target specification
  is contained within brackets and consists of a target type name, a colon,
  and the target id.  The target type name can be one of "screen", "gpu",
  "framelock", "vcs", "gvi", or "fan"; the target id is the index into the
  list of targets (for that target type).  The target specification can be
  used in {DISPLAY} wherever an X screen can be used, following the syntax
  {host}:{display}[{target_type}:{target_id}].  See the output of
  `nvidia-settings -q all` for information on which target types can be
  used with which attributes.  See the output of `nvidia-settings -q
  screens -q gpus -q framelocks -q vcs -q gvis -q fans` for lists of
  targets for each target type.

  The [{display devices}] portion is also optional; if it is not specified,
  then the attribute is assigned to all display devices.

  Some examples:

    -a FSAA=5
    -a localhost:0.0/DigitalVibrance[CRT-0]=0
    --assign="SyncToVBlank=1"
    -a [gpu:0]/DigitalVibrance[DFP-1]=63