FrameworkComputer / linux-docs

Linux Markdown Guides
108 stars 20 forks source link

Consider implement the OEM Kernel alert using a separate script file #26

Open brlin-tw opened 4 months ago

brlin-tw commented 4 months ago

Currently, the OEM Kernel alert dialog is implemented directly into the one-liner command:

Which is counter-intuitive, lacks transparency, and hard to troubleshoot problems like #24.

We also need to hack through the escaping requirements introduced by The Exec key | Desktop Entry Specification which increases the difficulty in maintaining a working solution for the users.

I suggest moving the logic into a separate shell script file and instructing the user to install it to a proper location and write the autostart configuration file to execute it instead.

I've read through and made a sample script(installed in ~/.local/bin/check-oem-kernel-update) as the following:

#!/usr/bin/env bash
# Check whether an updated OEM kernel package is installed, and notify
# the user to also update the default boot entry of the GRUB bootloader

set \
    -o errexit \
    -o nounset

latest_oem_kernel=$(
    ls /boot/vmlinuz-* \
        | grep '6.5.0-10..-oem' \
        | sort -V \
        | tail -n1 \
        | awk -F'/' '{print $NF}' \
        | sed 's/vmlinuz-//'
)

current_grub_kernel=$(
    grep '^GRUB_DEFAULT=' /etc/default/grub \
        | sed \
            -e 's/GRUB_DEFAULT=\"Advanced options for Ubuntu>Ubuntu, with Linux //g' \
            -e 's/\"//g'
)

if test "${latest_oem_kernel}" != "${current_grub_kernel}"; then
    zenity_opts=(
        --text-info

        # No longer works on Ubuntu >=23.10, see #25.
        #--html

        --width=300
        --height=200
        --title="Kernel Update Notification"
    )
    zenity "${zenity_opts[@]}" \
        --filename=<(
            echo -e \
                "A newer OEM D kernel is available than what is set in GRUB.  Open the following URL in the web browser to learn more:"
            echo
            echo "    https://github.com/FrameworkComputer/linux-docs/blob/main/22.04-OEM-D.md"
        )
fi

I've modified the autostart script as the following and can verify the alert dialog is properly triggered after login:

[Desktop Entry]
Type=Application
Exec=check-oem-kernel-update
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=Kernel check
Name=Kernel check
Comment[en_US]=
Comment=
ctsdownloads commented 4 months ago

Going to dive deeper into this once we circle back into 24.04. Good suggestion, added to wishlist as a great idea. Thanks for the feedback.