From 41192e6d7966fd043e4be8fc7ebce13084f793a0 Mon Sep 17 00:00:00 2001 From: Loc Huynh Date: Sat, 21 Feb 2026 12:48:12 +0700 Subject: [PATCH] bios.py: Add UEFI firmware setup button and boot mode detection --- usr/lib/linuxmint/mintreport/bios.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/usr/lib/linuxmint/mintreport/bios.py b/usr/lib/linuxmint/mintreport/bios.py index a54b852..1e29fcf 100644 --- a/usr/lib/linuxmint/mintreport/bios.py +++ b/usr/lib/linuxmint/mintreport/bios.py @@ -1,6 +1,8 @@ #!/usr/bin/python3 import gi import os +import subprocess +import shutil import xapp.SettingsWidgets as Xs import xapp.threading as xt import xapp.util @@ -20,6 +22,8 @@ def __init__(self): self.set_margin_bottom(0) self.section_bios = self.add_section(_("BIOS")) self.section_motherboard = self.add_section(_("Motherboard")) + # we will only show the firmware setup button on UEFI systems + self.has_uefi = False @xt.run_async def load(self): @@ -34,11 +38,14 @@ def load(self): infos_bios.append([_('Release'), read_dmi('bios_release')]) infos_bios.append([_('Release Date'), read_dmi('bios_date')]) + # determine boot mode (BIOS/UEFI) and whether to show firmware setup if not os.path.exists("/sys/firmware/efi"): infos_bios.append([_('Boot Mode'), 'BIOS']) infos_bios.append([_('Secure Boot'), _("Disabled")]) + self.has_uefi = False else: infos_bios.append([_('Boot Mode'), 'UEFI']) + self.has_uefi = True if read_efi("SecureBoot") == 1: infos_bios.append([_('Secure Boot'), _("Enabled")]) setup_mode = read_efi("SetupMode") @@ -80,8 +87,26 @@ def update_ui(self, infos_bios, infos_motherboard): labelValue.set_line_wrap(True) widget.pack_end(labelValue, False, False, 0) self.section_motherboard.add_row(widget) + # if we detected UEFI we add a button at the end of the BIOS section + # require systemctl to be available since that's what the button will call + if self.has_uefi and shutil.which("systemctl"): + btn = Gtk.Button(label=_("Enter Firmware Setup")) + btn.connect("clicked", self.on_enter_firmware_setup) + # wrap the button in a SettingsWidget row so that it gets the proper margins + widget = Xs.SettingsWidget() + widget.set_spacing(40) + widget.pack_start(btn, False, False, 0) + self.section_bios.add_row(widget) self.show_all() + def on_enter_firmware_setup(self, button): + """Trigger a reboot into firmware/UEFI setup mode.""" + try: + subprocess.Popen(["systemctl", "reboot", "--firmware-setup"]) + except Exception as e: + # we don't want the UI to crash if systemctl is missing + print("Failed to request firmware setup reboot:", e) + # ------------------------------------------------------------------- # Standalone test window # -------------------------------------------------------------------