Is it possible to set default screen resolution, FPS, relative position and whether it is a “main” display for an external screen connected with a dock before connecting it?
I am trying to solve two different problems.
It is annoying to configure everything once again from “Settings” each time I connect the phone to a dock.
For example, I want an external display to become a “main” display and the phone’s built-in touchscreen should become landscape.
It becomes annoying squared considering that with the hardware I have (Hoco HB37 hub → HDMI-to-DVI adapter → DVI-D “Single-Link” cable → display) the display frequently turns off while the Librem 5 seems to not notice it. This makes me disconnect everything and connect it back, and then reconfigure it again, and sometimes display immediately turns off after applying new configurations…
When an external screen turns off the following can be seen in dmesg logs:
With an another cable it seems like the screen is automatically configured in a wrong way, then something fails, the display flashes for a split second with its built-in message about “Not Optimum Mode” (it was almost impossible to read it during that short moment it appeared), turns off, flashes with that message again and so on.
UPD: It was just a bad connection. I have just unplugged the cable on the screen’s end and pluged it again and it just worked. The question about changing defaults is still valid.
Details about how the bad connection problem may look like, if you are interested, are under this spoiler.
The cable is a new HDMI to DVI-D “Dual Link” one I have just bought to rule out the HDMI-to-DVI adapter from the equation in hope that it might make the display not turn off unexpectedly.
These are the messages in dmesg log I get with this new cable:
[Jun20 14:32] [drm] hpd irq
[ +0.201418] [drm] Connector status: 1
[ +0.000548] [drm] HDMI/DP Cable Plug In
[ +0.014265] [drm] Connector status: 1
[ +0.014272] cdns-mhdp-imx 32c00000.hdmi: 0,ff,ff,ff,ff,ff,ff,0
[ +0.090409] [drm] Mode: 1920x1080p138640
[ +0.197643] cdns-mhdp-imx 32c00000.hdmi: [drm:cdns_mhdp_set_host_cap [cdns_mhdp_drmcore]] Using 2 lanes
[ +0.048566] imx-dcss 32e00000.display-controller: Pixel clock set to 138636 kHz instead of 138640 kHz.
[ +0.000066] cdns-mhdp-imx 32c00000.hdmi: [drm:cdns_mhdp_train_link [cdns_mhdp_drmcore]] Starting link training
One answer: UPERFECT X Mini lapdock works with Librem 5 - #96 by tendays (would need to be adapted and note that it is triggering on the appearance of a particular USB device, the lapdock touchscreen device, and you would need to find a device that works for your situation).
Yes, on a Debian-based distro using Wayland, you can configure predefined display settings for external monitors. While Wayland doesn’t use xrandr (which was common in X11), there are still several ways to achieve this depending on your desktop environment and tools available.
Options for Preconfigured Display Settings on Wayland
1. Desktop Environment Tools
Most modern DEs (like GNOME, KDE Plasma) on Wayland support display profiles:
GNOME:
Automatically remembers display configurations per monitor.
You can manually configure displays via Settings > Displays.
Profiles are stored in dconf and can be scripted using gsettings.
KDE Plasma:
Has built-in support for display profiles.
You can save and switch between profiles using KScreen.
Profiles are stored in ~/.local/share/kscreen/.
2. udev + systemd + scripts
You can create a udev rule that triggers a script when an external display is connected.
I have just tried to run kanshi from terminal (with appropriate config) and for some reason profiles are not triggered with display connect/disconnect. Instead they are triggered only once when the daemon is started.
And also each time the display configuration is changed or display itself is connected/disconnected there is a chance that phosh unexpectedly restarts (with all windows closed and displaying login screen).
Also, is there a command to specify the “main” screen in Phosh so that I can add this command into profile?
I have also configured kanshi to be started as systemd service as suggested in the answer you referred and made display description less specific (DP-1 instead of full display name in double quotes). It did not change anything.
I do not remember why it is so long (udev->systemd->bash->python->dbus) and I can not check it now as far as my type-c port still a little bit broken. However I believe this solution could be useful for someone.