]> git.proxmox.com Git - pve-installer.git/commitdiff
unconfigured: heuristically detect high-dpi and adapt font/GDK_SCALE
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 15 Jun 2021 12:56:26 +0000 (14:56 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 15 Jun 2021 12:56:35 +0000 (14:56 +0200)
Use the biggest terminus font we can get our hands on, and use the
Uni2 variant, which seems like an OK trade-off (the installer is
rather ascii anyway).

The detection uses the console columns in such away that high-dpi
screen should be detected but just wide-formats (like 21:9) should
not. This is a bit brittle, but even miss-detecting it should still
allow using it (the installer is made for 1024x768, which when
doubled still fits on WQXGA (2560x1600) and mostly on 1440p too.

It could be more robust to depend on edid-decode, but as physical
dimensions are not required there, and even if specified often quite
off, it's not a sure thing either. So go for simple first.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
unconfigured.sh

index 3a0386567420abae79e37b5c63dee958ccd6e164..5460821fdb78cb24e15c264062743e1d5fbcedc2 100755 (executable)
@@ -141,6 +141,18 @@ mount -t tmpfs tmpfs /dev/shm
 mkdir -p /dev/pts
 mount -vt devpts devpts /dev/pts -o gid=5,mode=620
 
+# shellcheck disable=SC2207
+console_dim=($(IFS=' ' stty size)) # [height, width]
+DPI=96
+if (("${console_dim[0]}" > 100)) && (("${console_dim[1]}" > 400)); then
+    # heuristic only, high resolution can still mean normal/low DPI if it's a really big screen
+    # FIXME: use `edid-decode` as it can contain physical dimensions to calculate actual dpi?
+    echo "detected huge console, setting bigger font/dpi"
+    DPI=192
+    export GDK_SCALE=2
+    setfont /usr/share/consolefonts/Uni2-Terminus32x16.psf.gz
+fi
+
 # set the hostname
 hostname proxmox
 
@@ -172,7 +184,7 @@ chronyd || echo "starting chrony failed ($?)"
 echo "Starting a root shell on tty3."
 setsid /sbin/agetty -a root --noclear tty3 &
 
-xinit -- -dpi 96 >/dev/tty2 2>&1
+xinit -- -dpi "$DPI" >/dev/tty2 2>&1
 
 # just to be sure everything is on disk
 sync