Skip to content

Commit

Permalink
minor improvements to Python code.
Browse files Browse the repository at this point in the history
  • Loading branch information
PanderMusubi committed May 31, 2024
1 parent 511d74f commit cb26653
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 15 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Framework-System-Details

Go to Activities, search for Framework System Details, launch the application. This will tell you the BIOS version your using, your CPU version (11th or 12th Gen), and of course your kernel version on Ubuntu 22.04.

Running

sudo python3 bios-checker.py

will show the following window.

![screenshot](screenshot.png)
47 changes: 32 additions & 15 deletions bios-checker.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,43 @@
import subprocess
import gi
"""Show system details such as BIOS version, CPU version and kernel version."""

gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Pango
from subprocess import check_output
from gi import require_version
require_version('Gtk', '3.0')
from gi.repository import Gtk # nopep8 # noqa: E402 # pylint: disable=C0413

# Set locale to US English so output matches the expected strings
# Set locale to US English so output matches the expected strings.
env = {"LC_ALL": "en_US.utf8"}

# Function to run a command with pkexec
def run_with_pkexec(cmd):
return subprocess.check_output(['pkexec', 'sh', '-c', cmd], env=env)

# Run the commands and store their output in variables
def run_with_pkexec(cmd: str) -> bytes:
"""Run a command with pkexec.
:param cmd: The command to run.
:return: The output of the command.
"""
return check_output(['pkexec', 'sh', '-c', cmd], env=env)


# Run the commands and store their output in variables.
bios_info = run_with_pkexec("dmidecode | grep -A3 'Vendor:'")
cpu_info = subprocess.check_output("lshw -C cpu | grep -A3 'product:'", shell=True, env=env)
kernel_version = subprocess.check_output("uname -r", shell=True, env=env)
cpu_info = check_output("lshw -C cpu | grep -A3 'product:'", shell=True,
env=env)
kernel_version = check_output("uname -r", shell=True, env=env)

# Create a GTK dialog window with larger text and a bigger size
dialog = Gtk.MessageDialog(parent=None, flags=0, message_type=Gtk.MessageType.INFO, buttons=Gtk.ButtonsType.OK, text="Framework System Details")
dialog.set_markup("<span size='xx-large' weight='bold'>BIOS Information:</span>\n{}\n<span size='xx-large' weight='bold'>CPU Information:</span>\n{}\n<span size='xx-large' weight='bold'>Kernel Version:</span> {}".format(bios_info.decode(), cpu_info.decode(), kernel_version.decode()))
# Create a GTK dialog window with larger text and a bigger size.
dialog = Gtk.MessageDialog(parent=None, flags=0,
message_type=Gtk.MessageType.INFO,
buttons=Gtk.ButtonsType.OK,
text="Framework System Details")
markup = f"""<span size='xx-large' weight='bold'>BIOS Information:</span>
{bios_info.decode()}
<span size='xx-large' weight='bold'>CPU Information:</span>
{cpu_info.decode()}
<span size='xx-large' weight='bold'>Kernel Version:</span>
{kernel_version.decode()}"""
print(markup)
dialog.set_markup(markup)
dialog.format_secondary_markup(None)
dialog.set_size_request(600, 400)
dialog.run()
dialog.destroy()

Binary file added screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cb26653

Please sign in to comment.