gnu: grub: Allow a PNG image and replace "aspect-ratio" with "resolution".
* gnu/bootloaders/grub.scm (<grub-image>): Remove this record and replace it by ... (<grub-theme>)[image]: ... this field with the default from %background-image, (<grub-theme>)[resolution]: ... this field with the defaults from 'width' and 'height' of 'grub-background-image'. (<grub-theme>)[images]: Remove this field. (svg->png): Rename to ... (image->png): ... and 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 <grub-image> 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 <grub-image> record unnecessary. Moving the default values from '%background-image' and '%default-theme' into <grub-theme> makes a customisation easier without (inherit) and allows to remove the undocumented variables %background-image' and '%default-theme'. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>master
parent
2e59ae2384
commit
9cdb10d52e
|
@ -37,19 +37,13 @@
|
||||||
#:use-module (ice-9 regex)
|
#:use-module (ice-9 regex)
|
||||||
#:use-module (srfi srfi-1)
|
#:use-module (srfi srfi-1)
|
||||||
#:use-module (srfi srfi-2)
|
#:use-module (srfi srfi-2)
|
||||||
#:export (grub-image
|
#:export (grub-theme
|
||||||
grub-image?
|
|
||||||
grub-image-aspect-ratio
|
|
||||||
grub-image-file
|
|
||||||
|
|
||||||
grub-theme
|
|
||||||
grub-theme?
|
grub-theme?
|
||||||
grub-theme-images
|
grub-theme-image
|
||||||
|
grub-theme-resolution
|
||||||
grub-theme-color-normal
|
grub-theme-color-normal
|
||||||
grub-theme-color-highlight
|
grub-theme-color-highlight
|
||||||
|
grub-theme-gfxmode
|
||||||
%background-image
|
|
||||||
%default-theme
|
|
||||||
|
|
||||||
grub-bootloader
|
grub-bootloader
|
||||||
grub-efi-bootloader
|
grub-efi-bootloader
|
||||||
|
@ -77,70 +71,57 @@ denoting a file name."
|
||||||
file))))
|
file))))
|
||||||
(#f file)))
|
(#f file)))
|
||||||
|
|
||||||
(define-record-type* <grub-image>
|
|
||||||
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* <grub-theme>
|
(define-record-type* <grub-theme>
|
||||||
|
;; Default theme contributed by Felipe López.
|
||||||
grub-theme make-grub-theme
|
grub-theme make-grub-theme
|
||||||
grub-theme?
|
grub-theme?
|
||||||
(images grub-theme-images
|
(image grub-theme-image
|
||||||
(default '())) ;list of <grub-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
|
(color-normal grub-theme-color-normal
|
||||||
(default '((fg . cyan) (bg . blue))))
|
(default '((fg . light-gray) (bg . black))))
|
||||||
(color-highlight grub-theme-color-highlight
|
(color-highlight grub-theme-color-highlight
|
||||||
(default '((fg . white) (bg . blue))))
|
(default '((fg . yellow) (bg . black))))
|
||||||
(gfxmode grub-gfxmode
|
(gfxmode grub-theme-gfxmode
|
||||||
(default '("auto")))) ;list of string
|
(default '("auto")))) ;list of string
|
||||||
|
|
||||||
(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ópez.
|
|
||||||
(grub-theme
|
|
||||||
(images (list %background-image))
|
|
||||||
(color-highlight '((fg . yellow) (bg . black)))
|
|
||||||
(color-normal '((fg . light-gray) (bg . black))))) ;XXX: #x303030
|
|
||||||
|
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
;;; Background image & themes.
|
;;; Background image & themes.
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
(define (bootloader-theme config)
|
(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."
|
otherwise."
|
||||||
(or (bootloader-configuration-theme config) %default-theme))
|
(or (bootloader-configuration-theme config) (grub-theme)))
|
||||||
|
|
||||||
(define* (svg->png svg #:key width height)
|
(define* (image->png image #:key width height)
|
||||||
"Build a PNG of HEIGHT x WIDTH from SVG."
|
"Build a PNG of HEIGHT x WIDTH from IMAGE if its file suffix is \".svg\".
|
||||||
|
Otherwise the picture in IMAGE is just copied."
|
||||||
(computed-file "grub-image.png"
|
(computed-file "grub-image.png"
|
||||||
(with-imported-modules '((gnu build svg))
|
(with-imported-modules '((gnu build svg))
|
||||||
(with-extensions (list guile-rsvg guile-cairo)
|
(with-extensions (list guile-rsvg guile-cairo)
|
||||||
#~(begin
|
#~(if (string-suffix? ".svg" #+image)
|
||||||
(use-modules (gnu build svg))
|
(begin
|
||||||
(svg->png #+svg #$output
|
(use-modules (gnu build svg))
|
||||||
#:width #$width
|
(svg->png #+image #$output
|
||||||
#:height #$height))))))
|
#:width #$width
|
||||||
|
#:height #$height))
|
||||||
|
(copy-file #+image #$output))))))
|
||||||
|
|
||||||
(define* (grub-background-image config #:key (width 1024) (height 768))
|
(define* (grub-background-image config)
|
||||||
"Return the GRUB background image defined in CONFIG with a ratio of
|
"Return the GRUB background image defined in CONFIG or #f if none was found.
|
||||||
WIDTH/HEIGHT, or #f if none was found."
|
If the suffix of the image file is \".svg\", then it is converted into a PNG
|
||||||
(let* ((ratio (/ width height))
|
file with the resolution provided in CONFIG."
|
||||||
(image (find (lambda (image)
|
(let* ((theme (bootloader-theme config))
|
||||||
(= (grub-image-aspect-ratio image) ratio))
|
(image (grub-theme-image theme)))
|
||||||
(grub-theme-images
|
|
||||||
(bootloader-theme config)))))
|
|
||||||
(and image
|
(and image
|
||||||
(svg->png (grub-image-file image)
|
(match (grub-theme-resolution theme)
|
||||||
#:width width #:height height))))
|
(((? number? width) . (? number? height))
|
||||||
|
(image->png image #:width width #:height height))
|
||||||
|
(_ #f)))))
|
||||||
|
|
||||||
(define* (eye-candy config store-device store-mount-point
|
(define* (eye-candy config store-device store-mount-point
|
||||||
#:key system port)
|
#:key system port)
|
||||||
|
@ -153,7 +134,7 @@ system string---e.g., \"x86_64-linux\"."
|
||||||
(define setup-gfxterm-body
|
(define setup-gfxterm-body
|
||||||
(let ((gfxmode
|
(let ((gfxmode
|
||||||
(or (and-let* ((theme (bootloader-configuration-theme config))
|
(or (and-let* ((theme (bootloader-configuration-theme config))
|
||||||
(gfxmode (grub-gfxmode theme)))
|
(gfxmode (grub-theme-gfxmode theme)))
|
||||||
(string-join gfxmode ";"))
|
(string-join gfxmode ";"))
|
||||||
"auto")))
|
"auto")))
|
||||||
|
|
||||||
|
|
Reference in New Issue