2

I recently returned to ubuntu (14.10) and I'm currently trying to get my multiple monitor setup to work properly.

It worked fine after the first setup in the desired configuration: A 1600x900 built-in monitor (Thinkpad T430) besides a 1920x1200 external Monitor (Asus VK226H) which is connected by DVI or VGA or mDP.

However, after the first reboot it greeted me with 'the selected configuration for displays could not be applied' and showed me a partially overlapping and highly distorted background with weird placement of the launcher and a non-functional mouse interaction (does not click where it's shown). Switching to mirrored mode made everything functional again.

Having a look at the X Server Configuration I've noticed that only the external monitor is being represented in the layout graphic and 'Selection' drop down menu while displays shows them both. The 'the selected configuration for displays could not be applied' started to pop up almost anytime I apply something to displays or X Server, apply something to displays, reboot or reconnect the external monitor (no matter which port).

since this is a new Account I'm not allowed to embed any pictures. Here are 2 screenshots with driver rev 331 showing both displays and the X Server config before and after i managed to get everything visible/not overlapping after a reboot. While it was heavily distorted along the vertical dimension (and parts of the desktop off-screen) on the physical screens this is not reflected in the screenshot

Failing horribly with lots of X Server settings, I decided to try the legacy drivers. I've purged the current drivers via this method and installed the 304 version though Software & Updates. The same thing happened. It worked after the initial setup and installation but failed again after a reboot. The built-in monitor still did not show up in X Server.

Since this didn't achieve anything I've reverted back to 331 and tried it once more with the same result. Everything looks fine to me in lshw and dpkg.

dpkg -l | grep nvidia
ii  nvidia-331                                           331.113-0ubuntu0.1                       amd64        NVIDIA binary driver - version 331.113
ii  nvidia-331-uvm                                       331.113-0ubuntu0.1                       amd64        NVIDIA Unified Memory kernel module
ii  nvidia-opencl-icd-331                                331.113-0ubuntu0.1                       amd64        NVIDIA OpenCL ICD
ii  nvidia-prime                                         0.6.7                                    amd64        Tools to enable NVIDIA's Prime
ii  nvidia-settings                                      331.20-0ubuntu8                          amd64        Tool for configuring the NVIDIA graphics driver

sudo lshw -C display
   *-display               
        description: VGA compatible controller
    product: GF108M [NVS 5400M]
    vendor: NVIDIA Corporation
    physical id: 0
    bus info: pci@0000:01:00.0
    version: a1
    width: 64 bits
    clock: 33MHz
    capabilities: pm msi pciexpress vga_controller bus_master cap_list rom
    configuration: driver=nvidia latency=0
    resources: irq:48 memory:f0000000-f0ffffff memory:c0000000-cfffffff memory:d000
0000-d1ffffff ioport:4000(size=128) memory:f1000000-f107ffff

At this point I have no Idea what to do since it's obviously a problem with the placement of my screens on the virtual screen but it doesn't show all of them in the configuration menu. How do I get it to show up so that I can configure everything properly?

Any help would be greatly appreciated.

If you need any more log extracts or other information please let me know.

Argysh
  • 123
  • I ended up solving a similar problem with a script that runs approximately 5 seconds after boot-up (I had to put this delay in or it would go bad again) and sets all the configurations right. It's a little annoying because it effectively makes the boot-up time longer (since you have to wait 5 extra seconds till everything is working), but it's the best solution I could find. If you think that might work for you I could try to dig the script up and post it as an answer. – fifaltra Jan 10 '15 at 02:58
  • Nice to know someone else had sth similar too. I'd be very much interested in your workaround. 5s additional boot time sounds much better than being restricted to a single screen. – Argysh Jan 10 '15 at 11:26

1 Answers1

0

Ok, this is a little perl script, which sets the display configurations right again after the reboot destroys them. Since I got my local Linux hero to write this for me, I only understand about half of it. So maybe you have to ask a follow up question to get this to work for you.

#!/usr/bin/perl

# settings
our @preferred_outputs = qw(HDMI1 VGA1 LVDS1);
our $poll_interval_seconds = 5.0; #this script actually keeps running and
     # periodically checks whether I plugged in my external monitor or not
our $sleep_seconds_at_start = 5.0; #this is the important bit
our $sleep_after_set = 5.0;

# end of settings

use strict;
use feature ":5.10";
use Time::HiRes qw(sleep);

sub eq_hashes (\%\%);

fork && exit;
#this is to make sure this script runs only once... I think
my @pids = split /\s+/, qx/pgrep -x `basename '$0'`/;
my @other_pids = grep { $_ != $$ } @pids;

if(@other_pids > 0) {
    kill "TERM", @other_pids;
}

sleep $sleep_seconds_at_start;

my %old_mode = get_default_mode();
set_auto_mode();
sleep $sleep_after_set;

while(sleep $poll_interval_seconds) {
    my %cur_mode = get_default_mode();
    unless(eq_hashes(%cur_mode, %old_mode)) {
        %old_mode = %cur_mode;
        set_auto_mode();
        sleep $sleep_after_set;
    }
}

sub eq_hashes (\%\%) {
    my ($h1, $h2) = @_;
    return hashref_to_string($h1) eq hashref_to_string($h2);
}

sub hashref_to_string {
    my $m = $_[0];
    return join "\0", map { $_, $m->{$_} } sort keys %$m;
}

#so this seems to be using xrandr to find out the resolution of the screen
#and then it returns that value 
sub get_default_mode {
    open my $xrout, "-|", "xrandr"
        or die $!;

    my %default_mode;
    my $cur_output;

    while(<$xrout>) {
        given($_) {
            when(/^(\w+) connected/) {
                $cur_output = $1;
            }
    #xrandr prints all possible resolutions, and puts a + next to the default one
            when(/^\s*(\d+x\d+)\s+[0-9.]+.\+/) {
                $default_mode{$cur_output} = $1;
            }
        }
    }

    close $xrout;

    return %default_mode;
}

sub set_auto_mode {
    my %default_mode = get_default_mode();
    my @opts;
    my $display_chosen = 0;

    for my $output (@preferred_outputs) {
        push @opts, "--output", $output;
        if(exists $default_mode{$output} && $display_chosen == 0) {
            push @opts, "--mode", $default_mode{$output};
            $display_chosen = 1;
        }
        push @opts, "--off";
    }

    system "xrandr", @opts;
}

Ok, so I don't know if you are familiar with perl. This script basically uses xrandr to do all the configurations. So you need to have xrandr and perl installed for this to work. But I think it might actually work out of the box (if I understand your problem correctly). Maybe you have to play around with xrandr a bit.

My setup is such that I have different things on my two screens and they're supposed to be next to each other. If I remember correctly. I don't really see where in the script that happens, but somehow fixing the resolutions of the screens did the trick for me. (I can't do any testing now because I don't have my second screen at hand.)

This is obviously a hack, so I would be happy if there was a more canonical solution (and someone could post it).

fifaltra
  • 363
  • 4
  • 20