[PLUG] Unprotected X with strangers
Ben Koenig
techkoenig at protonmail.com
Fri May 27 22:42:48 UTC 2022
------- Original Message -------
On Wednesday, May 25th, 2022 at 10:31 PM, Keith Lofstrom <keithl at kl-ic.com> wrote:
> A week or three ago, I whinged on this list about X forgetting
> my oddball rotated-two-screen configuration and displaying
> distorted and sideways after switching the KVM (Keyboard Video
> Mouse) between two computers.
>
> Problem (semi-adequately) solved.
>
> I learned many things (some disturbing) while solving the
> problem. My problem wasn't X or linux (this time), but I
> learned that we may ALL have Big Problems Ahead if we don't
> describe and document how X actually works, including
> decades of accumulated assumptions that reside mostly in
> 60+year-old brains ... and 30 years of accumulated Q&A on
> the web that is mostly 25 years obsolete.
>
> House built on sand, folks ...
>
> Anyway ... My real problem is that video cards (not Linux
> or other OS) are designed to reconfigure into basic 1024x768
> VGA mode (not rotated like my screens) if they are not
> getting EDID (Extended Display Identification Data) from
> the display.
>
> With a "dumb" KVM switch, the EDID information only goes to
> the computer and video card that is currently driving the
> display. The disconnected video card in the neglected
> computer is talking to Elvis and doing drugs, singing "Are
> You Lonesome Tonight", and regressing to its VGA childhood.
>
> ----
>
> I solved this two ways (and failed many more ways). The
> most important solution was switching my left-side "home
> screen" associated with mouse and keyboard with a better
> KVM (IOGEAR GCS932UB) which REMEMBERS the entire EDID
> configuration (many kilobytes) of the connected monitor,
> and sends it to BOTH computers that it connects to, even
> if that input channel isn't providing signal. That keeps
> the video cards in both computers feeding the KVM switch
> from listening to imaginary voices from decades past.
>
> Note, the exact IOGEAR model number GCS932UB matters;
> most models don't remember the EDID config. There are
> other KVM switches or inline dongles from Newegg and
> other outfits that remember EDID, but they cost hundreds
> to thousands of dollars. You will want those if you are
> monitoring tens to thousands of computers.
>
> What does NOT work is $20 "EDID emulators" from Amazon.
> I tried one of those; it can only remember one of 15
> widescreen modes, and spew that EDID modeline only,
> and only for the one computer it is in-line to.
> I'd call that the Forest Gump EDID mode, except that
> Forest was smarter, and knew how to keep running.
>
> ----
>
> The Other Trick is to build a shell script around the
> "xrandr" command which configures (and reconfigures) your
> video card (two channels for both screens).
>
> ------------------------------------------------------
> #!/bin/bash
> # 2022 May 14 KHL
> # 2022 May 25 KHL
> # /usr/local/bin/twoscreenR7450
> # two side-by-side Planar screens for ohmate using Radeon R7 450
> # activate with:
> # "ln /usr/local/bin/twoscreenR7450 /usr/local/bin/twoscreen"
>
> DISPLAY=:0; export DISPLAY
>
> xrandr --output DisplayPort-0 --rotate left --primary --pos 0x0 \
> --output DisplayPort-1 --rotate right --pos 1024x0
>
> echo -n "/usr/local/bin/twoscreenR7450" >> /var/log/twoscreenX
>
> date >> /var/log/twoscreenX
>
> ------------------------------------------------------
>
> I run this snippet of code in a timed loop; sleep 10
> seconds and repeat. Note that "right-of" (instead of
> "pos 1024x0") can fail with rotated screens.
>
> My customized config script ("twoscreen") lives
> in /usr/local/bin and is SUID root, which is probably
> dangerous and fattening. The loop is performed by
> another SUID script ("twoloop") which is launched "nohup"
> at startup ... in twisty little ways all different for
> newer/older redhat/debian/bsd distros.
>
> You can configure screens with the GUI system configuration,
> a program called "arandr" for many linux distros. However,
> operating a GUI and selecting nested menus and clicking
> modes and drop-down boxes using a sideways screen is a
> descent into Hell. All versions of arandr let you rotate
> a screen, but many versions don't understand that a rotated
> screen swaps width and height, so you cannot place two
> rotated screens adjacent in the X direction.
>
> The Workspace Switcher applet is similarly confused, and
> the lightdm login window refuses to rotate. Many more
> problems still need solving.
>
> But what goes into YOUR script? Every multiport graphics
> card uses different nomenclature for its ports:
>
> DisplayPort-0 and DisplayPort-1 for a Radeon R7 450
> with DisplayPort outputs.
>
> DisplayPort-0 and DVI-0 and HDMI-0 for a Radeon R7 450
> with those different outputs.
>
> DVI-I-1 and DVI-I-2 for an Nvidia 750T card with two
> DVI ports.
>
> DVI-I-1 and DVI-D-1 for an Nvidia 8800 with two graphics
> ports.
>
> Other names, some defamatory, for other hardware.
>
> "xrandr --query" (as root) will tell you about the port
> names and available modes ... except when it doesn't.
>
> ----
>
> If you have made it down this far, CONGRATULATIONS!
>
> In five minutes, you've travelled a distance that cost me
> 60 hours and a few hundred dollars for hardware. Some of
> which I will keep and use, most of which will be donated
> to FreeGeek, and some of which will be boiled in battery
> acid, along with the design engineers if I can find them.
>
> And for you young geeks seeking fame and fortune rather
> than twenty-to-life in prison, X needs an up-to-date user
> and debug and driver design book, cognizant of modern
> graphics cards rather than Sun workstations.
>
> The newest book I've found is Chris Tyler's 2008 "X Power
> Tools". Books will make a comeback, after those who learn
> from videos and tweets murder each other or themselves
> ("drink bleach to prevent COVID"). A very large pile
> of books is good shielding for your fallout shelter,
> and your "sunlight-powered Kindle" in the aftermath.
>
> Keith
>
> --
> Keith Lofstrom keithl at keithl.com
As interesting as this all is, I prefer to use the tools for their intended purpose. xrandr is powerful when working with dynamic and constantly changing monitor environments. In particular for laptops where you don't have a lot of control over the secondary display. For a less mobile use case (e.g. a desktop system where the monitors never change) I prefer to fall back on the traditional xorg.conf.
In the old days, you needed an entire /etc/X11/xorg.conf file to explicitly define every [Device], [Display], and [Screen]. These days, X11 can automatically build a temporary xorg.conf based on templates found in /usr/share/X11/xorg.conf.d/. But the syntax hasn't changed in the ~20 years I've been using it.
Since I have full control over my monitors, I can define them in excruciating detail and specify their exact layout at the pixel level. When running startx, this config will be loaded and be treated as the "default". Tools based on xrandr will still function using my xorg.conf file as the initial config. That way if I need to do something unusual for a day I still can.
In my preferred linux distro, the advice from 2008 is still relevant. Manpages are also still relevant, and sometimes you just gotta tell people to RTFM.
$ man xorg.conf
Honestly, it's right there...
Option "Rotate" "rotation"
This optional entry specifies the initial rotation of the given monitor. Valid values for rotation
are "normal", "left", "right", and "inverted". (RandR 1.2-supporting drivers only)
...explicitly stated in the documentation for xorg.conf on Ubuntu 18.04. I can't say it any better than David Dawes <dawes at xfree86.org> already has.
-Ben
More information about the PLUG
mailing list