From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 4NJ5CkK1wV6IMgAA0tVLHw (envelope-from ) for ; Sun, 17 May 2020 22:05:54 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 6SNdBkK1wV5CRAAA1q6Kng (envelope-from ) for ; Sun, 17 May 2020 22:05:54 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 84C139402D1 for ; Sun, 17 May 2020 22:05:53 +0000 (UTC) Received: from localhost ([::1]:47760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jaRPs-0003ZB-C4 for larch@yhetil.org; Sun, 17 May 2020 18:05:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33564) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jaRFO-0000TA-V7 for guix-patches@gnu.org; Sun, 17 May 2020 17:55:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:33425) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jaRFN-00051K-WA for guix-patches@gnu.org; Sun, 17 May 2020 17:55:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jaRFN-0005S6-Ur for guix-patches@gnu.org; Sun, 17 May 2020 17:55:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41163] [PATCH] gnu: grub: Allow a PNG image and replace (aspect-ratio) with (resolution). Resent-From: Stefan Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 17 May 2020 21:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41163 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Mathieu Othacehe Cc: 41163@debbugs.gnu.org Received: via spool by 41163-submit@debbugs.gnu.org id=B41163.158975244420889 (code B ref 41163); Sun, 17 May 2020 21:55:01 +0000 Received: (at 41163) by debbugs.gnu.org; 17 May 2020 21:54:04 +0000 Received: from localhost ([127.0.0.1]:44971 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jaRER-0005Qr-Vm for submit@debbugs.gnu.org; Sun, 17 May 2020 17:54:04 -0400 Received: from mx009.vodafonemail.xion.oxcs.net ([153.92.174.39]:25369) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jaREP-0005QL-Ke for 41163@debbugs.gnu.org; Sun, 17 May 2020 17:54:02 -0400 Received: from vsmx002.vodafonemail.xion.oxcs.net (unknown [192.168.75.192]) by mta-6-out.mta.xion.oxcs.net (Postfix) with ESMTP id 9AC906046F3; Sun, 17 May 2020 21:53:55 +0000 (UTC) Received: from macbook-pro.kuh-wiese.my-router.de (unknown [94.220.249.154]) by mta-6-out.mta.xion.oxcs.net (Postfix) with ESMTPA id 40F2C604040; Sun, 17 May 2020 21:53:51 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) From: Stefan In-Reply-To: <9A0DB516-B428-40D9-8E00-2C189457F425@vodafonemail.de> Date: Sun, 17 May 2020 23:53:50 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <9EBB480D-957F-4A77-B01A-B8A8F39172D1@vodafonemail.de> References: <87y2q0i7xx.fsf@gnu.org> <9A0DB516-B428-40D9-8E00-2C189457F425@vodafonemail.de> X-Mailer: Apple Mail (2.3124) X-VADE-STATUS: LEGIT X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -3.3 (---) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: -0.51 X-TUID: Bo8sNiHwFj6g * gnu/bootloaders/grub.scm (): Remove this record and = replace it by ... ()[image]: ... this field with the default from = %background-image, ()[resolution]: ... this field with the defaults from = 'width' and 'height' of 'grub-background-image'. ()[images]: Remove this field. (svg->png): Use 'copy-file' instead of 'svg->png', if the suffix of the = image file is not ".svg". (grub-background-image): Remove the arguments 'width' and 'height'. (grub-theme-image): Add function. (grub-theme-resolution): Add function. (grub-theme-gfxmode): Add function. (grub-image): Remove function. (grub-image?): Remove function. (grub-image-aspect-ratio): Remove function. (grub-image-file): Remove function. (grub-theme-images): Remove function. (%default-theme): Remove variable. (%background-image): Remove variable. Using image formats different to SVG was not possible. For a to be chosen, the 'aspect-ratio' of it had to be 4/3, = as the resolution of any image was defaulting to 1024 x 768. There was no code to determine the proper boot-resolution to make any = use of a list of images with different aspect-ratios. It seems to be a better solution to only define a single image with any = format, and use a given resolution only for the conversion from a SVG file. This = also makes the use of a special record unnecessary. Moving the default values from '%background-image' and '%default-theme' = into makes a customisation easier without (inherit) and allows = to remove the undocumented variables %background-image' and '%default-theme'. --- gnu/bootloader/grub.scm | 93 ++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 56 deletions(-) diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index 3f61b4a963..fb2e4cc00d 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -37,19 +37,13 @@ #:use-module (ice-9 regex) #:use-module (srfi srfi-1) #:use-module (srfi srfi-2) - #:export (grub-image - grub-image? - grub-image-aspect-ratio - grub-image-file - - grub-theme + #:export (grub-theme grub-theme? - grub-theme-images + grub-theme-image + grub-theme-resolution grub-theme-color-normal grub-theme-color-highlight - - %background-image - %default-theme + grub-theme-gfxmode =20 grub-bootloader grub-efi-bootloader @@ -77,70 +71,57 @@ denoting a file name." file)))) (#f file))) =20 -(define-record-type* - grub-image make-grub-image - grub-image? - (aspect-ratio grub-image-aspect-ratio ;rational number - (default 4/3)) - (file grub-image-file)) ;file-valued gexp = (SVG) - (define-record-type* + ;; Default theme contributed by Felipe L=C3=B3pez. grub-theme make-grub-theme grub-theme? - (images grub-theme-images - (default '())) ;list of + (image grub-theme-image + (default (file-append %artwork-repository + = "/grub/GuixSD-fully-black-4-3.svg"))) + (resolution grub-theme-resolution + (default '(1024 . 768))) (color-normal grub-theme-color-normal - (default '((fg . cyan) (bg . blue)))) + (default '((fg . light-gray) (bg . black)))) (color-highlight grub-theme-color-highlight - (default '((fg . white) (bg . blue)))) - (gfxmode grub-gfxmode + (default '((fg . yellow) (bg . black)))) + (gfxmode grub-theme-gfxmode (default '("auto")))) ;list of string =20 -(define %background-image - (grub-image - (aspect-ratio 4/3) - (file (file-append %artwork-repository - "/grub/GuixSD-fully-black-4-3.svg")))) - -(define %default-theme - ;; Default theme contributed by Felipe L=C3=B3pez. - (grub-theme - (images (list %background-image)) - (color-highlight '((fg . yellow) (bg . black))) - (color-normal '((fg . light-gray) (bg . black))))) ;XXX: #x303030 - ^L ;;; ;;; Background image & themes. ;;; =20 (define (bootloader-theme config) - "Return user defined theme in CONFIG if defined or %default-theme + "Return user defined theme in CONFIG if defined or a default theme otherwise." - (or (bootloader-configuration-theme config) %default-theme)) + (or (bootloader-configuration-theme config) (grub-theme))) =20 (define* (svg->png svg #:key width height) - "Build a PNG of HEIGHT x WIDTH from SVG." + "Build a PNG of HEIGHT x WIDTH from SVG if its file suffix is = \".svg\". +Otherwise the picture in SVG is just copied." (computed-file "grub-image.png" (with-imported-modules '((gnu build svg)) (with-extensions (list guile-rsvg guile-cairo) - #~(begin - (use-modules (gnu build svg)) - (svg->png #+svg #$output - #:width #$width - #:height #$height)))))) - -(define* (grub-background-image config #:key (width 1024) (height 768)) - "Return the GRUB background image defined in CONFIG with a ratio of -WIDTH/HEIGHT, or #f if none was found." - (let* ((ratio (/ width height)) - (image (find (lambda (image) - (=3D (grub-image-aspect-ratio image) ratio)) - (grub-theme-images - (bootloader-theme config))))) - (and image - (svg->png (grub-image-file image) - #:width width #:height height)))) + #~(if (string-suffix? ".svg" #+svg) + (begin + (use-modules (gnu build svg)) + (svg->png #+svg #$output + #:width #$width + #:height #$height)) + (copy-file #+svg #$output)))))) + +(define* (grub-background-image config) + "Return the GRUB background image defined in CONFIG or #f if none = was found. +If the suffix of the image file is \".svg\", then it is converted into = a PNG +file with the resolution provided in CONFIG." + (let* ((theme (bootloader-theme config)) + (image (grub-theme-image theme))) + (and image + (match (grub-theme-resolution theme) + (((? number? width) . (? number? height)) + (svg->png image #:width width #:height height)) + (_ #f))))) =20 (define* (eye-candy config store-device store-mount-point #:key system port) @@ -153,7 +134,7 @@ system string---e.g., \"x86_64-linux\"." (define setup-gfxterm-body (let ((gfxmode (or (and-let* ((theme (bootloader-configuration-theme = config)) - (gfxmode (grub-gfxmode theme))) + (gfxmode (grub-theme-gfxmode theme))) (string-join gfxmode ";")) "auto"))) =20 --=20 2.26.0