nixos-generate-config: add rudimentary high-DPI detection

Fixes the main remaining part of #12345
This commit is contained in:
Linus Heckemann 2019-02-25 11:58:38 +01:00
parent 61bad5b84c
commit 89b64ab5e1

View File

@ -464,6 +464,21 @@ EOF
} }
} }
# For lack of a better way to determine it, guess whether we should use a
# bigger font for the console from the display mode on the first
# framebuffer. A way based on the physical size/actual DPI reported by
# the monitor would be nice, but I don't know how to do this without X :)
my $fb_modes_file = "/sys/class/graphics/fb0/modes";
if (-f $fb_modes_file && -r $fb_modes_file) {
my $modes = read_file($fb_modes_file);
$modes =~ m/([0-9]+)x([0-9]+)/;
my $console_width = $1, my $console_height = $2;
if ($console_width > 1920) {
push @attrs, "# High-DPI console";
push @attrs, 'i18n.consoleFont = lib.mkDefault "${pkgs.terminus_font}/share/consolefonts/ter-u28n.psf.gz";';
}
}
# Generate the hardware configuration file. # Generate the hardware configuration file.