From 38e4b8ec019702314cf070a34de978cbdca97004 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Fri, 1 Nov 2024 00:53:53 -0400 Subject: [PATCH] jovian-updater-logo-helper: Add support for BGRT --- .../jovian-updater-logo-helper.sh | 86 +++++++++++++++++-- 1 file changed, 78 insertions(+), 8 deletions(-) diff --git a/pkgs/jovian-updater-logo-helper/jovian-updater-logo-helper.sh b/pkgs/jovian-updater-logo-helper/jovian-updater-logo-helper.sh index 1d1135f0..90f9dd2a 100644 --- a/pkgs/jovian-updater-logo-helper/jovian-updater-logo-helper.sh +++ b/pkgs/jovian-updater-logo-helper/jovian-updater-logo-helper.sh @@ -51,14 +51,84 @@ MAGICK_INVOCATION=( "canvas:black[${image_width}x${image_height}!]" ) -MAGICK_INVOCATION+=( - # Add the logo - "$logo" - # Centered - -gravity center - # (This means 'add') - -composite -) +if [[ "$logo" == "--bgrt" ]]; then + # Status field described here: + # - https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/05_ACPI_Software_Programming_Model/ACPI_Software_Programming_Model.html#boot-graphics-resource-table-bgrt + bgrt_rotation="$(( ($(cat /sys/firmware/acpi/bgrt/status) >> 1) & 2#11 ))" + bgrt_xoffset=$(cat /sys/firmware/acpi/bgrt/xoffset) + bgrt_yoffset=$(cat /sys/firmware/acpi/bgrt/yoffset) + bgrt_dimensions="$(magick identify /sys/firmware/acpi/bgrt/image | cut -d' ' -f3)" + bgrt_height=${bgrt_dimensions#*x} + bgrt_width=${bgrt_dimensions%x*} + + case "$bgrt_rotation" in + "$(( 2#00 ))") + bgrt_offset="+$(( + bgrt_xoffset + ))+$(( + bgrt_yoffset + ))" + bgrt_rotation="0" + ;; + "$(( 2#01 ))") # 90 + bgrt_offset="+$(( + image_height - bgrt_height - bgrt_yoffset + ))+$(( + bgrt_xoffset + ))" + bgrt_rotation="90" + ;; + "$(( 2#10 ))") # 180 + bgrt_offset="+$(( + image_width - bgrt_width - bgrt_xoffset + ))+$(( + image_height - bgrt_height - bgrt_yoffset + ))" + bgrt_rotation="180" + ;; + "$(( 2#11 ))") # -90 + bgrt_offset="+$(( + bgrt_yoffset + ))+$(( + image_width - bgrt_width - bgrt_xoffset + ))" + bgrt_rotation="-90" + ;; + esac + + MAGICK_INVOCATION+=( + # Put the canvas back into the panel native orientation. + -rotate -$(( display_rotation )) + + # Add the BGRT (bmp image) + # Group operation so we don't operate on the canvas. + '(' + # Load the image + "/sys/firmware/acpi/bgrt/image" + + # Rotate the BGRT to its expected rotation for composition + -rotate $(( bgrt_rotation )) + + # At its defined offset, again considering pre-composed rotation + -geometry "$bgrt_offset" + ')' + + # (This means 'add' for the previous image) + -composite + + # Undo the native orientation we added back. + -rotate $(( display_rotation )) + ) +else + MAGICK_INVOCATION+=( + # Add the logo + "$logo" + # Centered + -gravity center + # (This means 'add') + -composite + ) +fi # Final fixups to the image MAGICK_INVOCATION+=(