Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions usr/lib/linuxmint/mintreport/bios.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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):
Expand All @@ -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")
Expand Down Expand Up @@ -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
# -------------------------------------------------------------------
Expand Down