Can not set external monitor to left of internal monitor on ubuntu 17.04

Xen list at xenhideout.nl
Mon Jul 10 23:43:19 UTC 2017


Liam Proven schreef op 11-07-2017 1:01:
> On 10 July 2017 at 18:53, Xen <list at xenhideout.nl> wrote:
>> Been more accustomed to KDE myself.... when I first connected my TV as
>> secondary on HDMI and set it to mirror, and then disconnected it 
>> again, both
>> screens went black and I had to reboot the machine to get a visual 
>> back.
>> 
> 
> This sometimes works:
> 
> Ctrl+Alt+F1 to a virtual console.
> Ctrl+Alt+F7 to get back to X.11
> 
> This resets the console into text mode and back into graphics mode,
> clearing up some glitches and issues.

Yes I know, but that didn't work. Anyway, not important now.

Now I just run "fixscreen" which is a little xrandr shell script and 
that will just detect the current display configuration and select an 
appropriate xrandr command to get it right again, I guess. I mean, to 
get the proper configuration.

It also hooks into udev but because KScreen also messes with the display 
I check journalctl, I mean I check syslog until there are no more 
KScreen messages and then I effectuate it :p.

And I just... I mean I can disable KScreen, there is some obscure little 
KDE configuration thing for that, but I wanted it to work easier than 
that, but I mean, more out of the box, but I have no idea how to hook 
into anything KDE does.

So It's not so simple to create something that will really cover a wide 
variety of use cases. You'd really have to intend to create a model that 
will cover every possible configuration and then execute your commands 
based on that, and that's what KScreen is supposed to do, but it kinda 
failed in 16.04.

Writing your own xrandr commands is guaranteed to work, but then you 
need a framework to ease the automation of it and that framework then 
doesn't exist. Because of that we Linux people often do something quick 
and dirty that works for us, but then everyone else also has to repeat 
that work for themselves ;-).

And then the ones who do make an effort often end up making something 
that works so badly that you still have to do the quick and dirty stuff 
yourself :(.

Well, not trying to be despondent here, anyway this is what is needed to 
automate execution after monitor change:



/etc/udev/rules.d/99-monitor-change.rules

ACTION=="change", SUBSYSTEM=="drm", RUN+="/path/to/script"

I then ran xrandr as my user using:

sudo_xrandr() {
     sudo -u xen DISPLAY=:0 xrandr "$@"
}

although that isn't exactly fool-proof. At that point you can do things 
such as:

sudo_xrandr --output DVI-I-1 --primary --mode 1440x900 --output HDMI-1 
--same-as DVI-I-1 --mode 1360x768 --scale-from 1440x900

I believe.

Your script would then run after every monitor change and you can put it 
in some KDE startup folder (add it to the list of startup scripts). In 
KDE you then have to disable KScreen using:

kcmshell5 kded.

Which is in that sense the easiest to get around it. Then you have 
basically your custom xrandr commands executed after login and after 
monitor changes.

It is then of course possible to use the xrandr -q command to 
differentiate between different configurations, or use cases.

For instance you could detect whether the HDMI is connected or not, etc. 
etc.




More information about the ubuntu-users mailing list