Enhanced About window
This commit is contained in:
1 parent
df7c4854cd
commit
c096fa1fc0
2 files changed
+89
-89
No files matched your search
+81
-88
@@ -1,7 +1,6 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
import time
|
|
||||||
import gi # type: ignore
|
|
||||||
import re
|
import re
|
||||||
|
import gi # type: ignore
|
||||||
|
|
||||||
from fabric.widgets.label import Label
|
from fabric.widgets.label import Label
|
||||||
from fabric.widgets.button import Button
|
from fabric.widgets.button import Button
|
||||||
@@ -36,41 +35,35 @@ def get_gpu_name():
|
|||||||
desc = line.split(":", 2)[-1]
|
desc = line.split(":", 2)[-1]
|
||||||
return desc.replace("Corporation", "").strip()
|
return desc.replace("Corporation", "").strip()
|
||||||
|
|
||||||
# Prefer dGPU
|
|
||||||
for line in output:
|
for line in output:
|
||||||
if any(vendor in line.lower() for vendor in ["nvidia", "amd", "radeon"]):
|
if any(vendor in line.lower() for vendor in ["nvidia", "amd", "radeon"]):
|
||||||
return clean(line)
|
return clean(line)
|
||||||
|
|
||||||
# Fallback to iGPU
|
|
||||||
if output:
|
if output:
|
||||||
return clean(output[0])
|
return clean(output[0])
|
||||||
|
|
||||||
return "Unknown GPU"
|
return "Unknown GPU"
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
return "Unknown GPU"
|
return "Unknown GPU"
|
||||||
|
|
||||||
|
|
||||||
class About(Gtk.Window):
|
class About(Gtk.Window):
|
||||||
"""About app for envshell"""
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(title="About Menu")
|
super().__init__(title="About Menu")
|
||||||
self.set_default_size(250, 335)
|
self.set_default_size(300, 550)
|
||||||
self.set_size_request(250, 355)
|
self.set_size_request(300, 500)
|
||||||
self.set_resizable(False)
|
self.set_resizable(False)
|
||||||
self.set_wmclass("modus-about-menu", "modus-about-menu")
|
self.set_wmclass("modus-about-menu", "modus-about-menu")
|
||||||
self.set_name("about-menu")
|
self.set_name("about-menu")
|
||||||
self.set_visible(False)
|
self.set_visible(False)
|
||||||
|
|
||||||
# Main vertical box
|
|
||||||
main_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
|
main_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
|
||||||
main_box.set_margin_top(20)
|
main_box.set_margin_top(10)
|
||||||
main_box.set_margin_bottom(20)
|
main_box.set_margin_bottom(20)
|
||||||
main_box.set_margin_start(20)
|
main_box.set_margin_start(20)
|
||||||
main_box.set_margin_end(20)
|
main_box.set_margin_end(20)
|
||||||
|
|
||||||
# About logo
|
# Logo
|
||||||
logo_box = Gtk.Box(halign=Gtk.Align.CENTER, valign=Gtk.Align.CENTER)
|
logo_box = Gtk.Box(halign=Gtk.Align.CENTER, valign=Gtk.Align.CENTER)
|
||||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
|
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
|
||||||
get_relative_path("../config/assets/icons/imac.svg"),
|
get_relative_path("../config/assets/icons/imac.svg"),
|
||||||
@@ -80,102 +73,102 @@ class About(Gtk.Window):
|
|||||||
)
|
)
|
||||||
logo = Gtk.Image.new_from_pixbuf(pixbuf)
|
logo = Gtk.Image.new_from_pixbuf(pixbuf)
|
||||||
logo_box.pack_start(logo, False, False, 0)
|
logo_box.pack_start(logo, False, False, 0)
|
||||||
|
logo_box.set_margin_top(60)
|
||||||
|
|
||||||
# Labels
|
# Product Name & Vendor
|
||||||
name_label = Gtk.Label(label=read_dmi("product_name"))
|
name_label = Gtk.Label()
|
||||||
date_label = Gtk.Label(label=read_dmi("sys_vendor"))
|
name_label.set_margin_top(30)
|
||||||
|
name_label.set_markup(
|
||||||
# Info Section
|
f"<b><span size='16000'>{read_dmi('product_name')}</span></b>"
|
||||||
info_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10)
|
|
||||||
info_title_box = Gtk.Box(
|
|
||||||
orientation=Gtk.Orientation.VERTICAL, valign=Gtk.Align.CENTER
|
|
||||||
)
|
|
||||||
info_box_labels = Gtk.Box(
|
|
||||||
orientation=Gtk.Orientation.VERTICAL, valign=Gtk.Align.CENTER
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Titles
|
vendor_label = Gtk.Label(label=read_dmi("sys_vendor"))
|
||||||
info_title_box.pack_start(
|
vendor_label.set_name("vendor-label")
|
||||||
Gtk.Label(label="Kernel", halign=Gtk.Align.END), False, False, 0
|
vendor_label.set_halign(Gtk.Align.CENTER)
|
||||||
)
|
|
||||||
info_title_box.pack_start(
|
|
||||||
Gtk.Label(label="CPU", halign=Gtk.Align.END), False, False, 0
|
|
||||||
)
|
|
||||||
info_title_box.pack_start(
|
|
||||||
Gtk.Label(label="Memory", halign=Gtk.Align.END), False, False, 0
|
|
||||||
)
|
|
||||||
info_title_box.pack_start(
|
|
||||||
Gtk.Label(label="GPU", halign=Gtk.Align.END), False, False, 0
|
|
||||||
)
|
|
||||||
info_title_box.pack_start(
|
|
||||||
Gtk.Label(label="Uptime", halign=Gtk.Align.END), False, False, 0
|
|
||||||
)
|
|
||||||
|
|
||||||
# Values
|
# Info Grid
|
||||||
|
info_grid = Gtk.Grid()
|
||||||
|
info_grid.set_row_spacing(6)
|
||||||
|
info_grid.set_column_spacing(10)
|
||||||
|
info_grid.set_valign(Gtk.Align.CENTER)
|
||||||
|
info_grid.set_halign(Gtk.Align.FILL)
|
||||||
|
|
||||||
kernel_label = Gtk.Label(
|
def make_label(text, align_end=False, name=None):
|
||||||
label=subprocess.run(
|
label = Gtk.Label(label=text)
|
||||||
"uname -r", shell=True, capture_output=True, text=True
|
label.set_halign(Gtk.Align.END if align_end else Gtk.Align.START)
|
||||||
).stdout.strip(),
|
if name:
|
||||||
halign=Gtk.Align.START,
|
label.set_name(name)
|
||||||
)
|
return label
|
||||||
chip_label = Gtk.Label(
|
|
||||||
label=subprocess.run(
|
|
||||||
"lscpu | grep 'Model name:' | cut -d ':' -f2-",
|
|
||||||
shell=True,
|
|
||||||
capture_output=True,
|
|
||||||
text=True,
|
|
||||||
).stdout.strip(),
|
|
||||||
halign=Gtk.Align.START,
|
|
||||||
)
|
|
||||||
mem_label = Gtk.Label(
|
|
||||||
label=subprocess.run(
|
|
||||||
"free -h --giga | grep Mem | tr -s ' ' | cut -d ' ' -f 2",
|
|
||||||
shell=True,
|
|
||||||
capture_output=True,
|
|
||||||
text=True,
|
|
||||||
).stdout.strip(),
|
|
||||||
halign=Gtk.Align.START,
|
|
||||||
)
|
|
||||||
uptime_label = Gtk.Label(
|
|
||||||
label=subprocess.run(
|
|
||||||
"uptime -p",
|
|
||||||
shell=True,
|
|
||||||
capture_output=True,
|
|
||||||
text=True,
|
|
||||||
).stdout.strip(),
|
|
||||||
halign=Gtk.Align.START,
|
|
||||||
)
|
|
||||||
gpu_label = Gtk.Label(label=get_gpu_name(), halign=Gtk.Align.START)
|
|
||||||
|
|
||||||
info_box_labels.pack_start(kernel_label, False, False, 0)
|
# Info values
|
||||||
info_box_labels.pack_start(chip_label, False, False, 0)
|
labels = [
|
||||||
info_box_labels.pack_start(mem_label, False, False, 0)
|
(
|
||||||
info_box_labels.pack_start(gpu_label, False, False, 0)
|
"Kernel",
|
||||||
info_box_labels.pack_start(uptime_label, False, False, 0)
|
subprocess.run(
|
||||||
|
"uname -r", shell=True, capture_output=True, text=True
|
||||||
|
).stdout.strip(),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"CPU",
|
||||||
|
subprocess.run(
|
||||||
|
"lscpu | grep 'Model name:' | cut -d ':' -f2-",
|
||||||
|
shell=True,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
).stdout.strip(),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"Memory",
|
||||||
|
subprocess.run(
|
||||||
|
"free -h --giga | grep Mem | tr -s ' ' | cut -d ' ' -f 2",
|
||||||
|
shell=True,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
).stdout.strip(),
|
||||||
|
),
|
||||||
|
("GPU", get_gpu_name()),
|
||||||
|
(
|
||||||
|
"Uptime",
|
||||||
|
subprocess.run(
|
||||||
|
"uptime -p", shell=True, capture_output=True, text=True
|
||||||
|
).stdout.strip(),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
info_box.pack_start(info_title_box, False, False, 10)
|
for i, (title, value) in enumerate(labels):
|
||||||
info_box.pack_start(info_box_labels, False, False, 10)
|
title_label = make_label(title, align_end=True)
|
||||||
|
value_label = make_label(value, align_end=False, name="info-label")
|
||||||
|
info_grid.attach(title_label, 0, i, 1, 1)
|
||||||
|
info_grid.attach(value_label, 1, i, 1, 1)
|
||||||
|
|
||||||
# More Info Button
|
# Button
|
||||||
button_box = Gtk.Box(halign=Gtk.Align.CENTER)
|
button_box = Gtk.Box(halign=Gtk.Align.CENTER)
|
||||||
button_box.set_margin_top(20) # Add 20 pixels of vertical spacing
|
button_box.set_margin_top(20)
|
||||||
more_info_button = Gtk.Button(label="More Info...", name="more-info-button")
|
more_info_button = Gtk.Button(label="More Info...", name="more-info-button")
|
||||||
more_info_button.connect("clicked", self.open_more_info)
|
more_info_button.connect("clicked", self.open_more_info)
|
||||||
button_box.pack_start(more_info_button, False, False, 0)
|
button_box.pack_start(more_info_button, False, False, 0)
|
||||||
|
|
||||||
# Add everything to the main box
|
# Info Footer
|
||||||
|
info = Gtk.Label(
|
||||||
|
label="™ and © 2025 Linux Inc.\nAll rights reserved.\n\n",
|
||||||
|
justify=Gtk.Justification.CENTER,
|
||||||
|
halign=Gtk.Align.CENTER,
|
||||||
|
)
|
||||||
|
info.set_name("info-label")
|
||||||
|
info.set_margin_top(10)
|
||||||
|
|
||||||
|
# Layout Order
|
||||||
main_box.pack_start(logo_box, False, False, 0)
|
main_box.pack_start(logo_box, False, False, 0)
|
||||||
main_box.pack_start(name_label, False, False, 0)
|
main_box.pack_start(name_label, False, False, 0)
|
||||||
main_box.pack_start(date_label, False, False, 0)
|
main_box.pack_start(vendor_label, False, False, 0)
|
||||||
main_box.pack_start(info_box, False, False, 0)
|
main_box.pack_start(info_grid, False, False, 0)
|
||||||
main_box.pack_start(button_box, False, False, 0)
|
main_box.pack_start(button_box, False, False, 0)
|
||||||
|
main_box.pack_start(info, False, False, 0)
|
||||||
|
|
||||||
# Add main box to the window
|
|
||||||
self.add(main_box)
|
self.add(main_box)
|
||||||
|
|
||||||
def open_more_info(self, button):
|
def open_more_info(self, button):
|
||||||
# TODO: Implement the logic to open more info
|
# TODO: Implement the logic to open more information
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def toggle(self, b):
|
def toggle(self, b):
|
||||||
|
|||||||
+8
-1
@@ -1,5 +1,5 @@
|
|||||||
#about-menu {
|
#about-menu {
|
||||||
background-color: alpha(#111, 0.1);
|
background-color: alpha(#111, 0.6);
|
||||||
box-shadow: inset 0 -0.5px 0 .5px alpha(#555, 0.7), inset 0 0.5px 0 .5px alpha(#777, 0.7);
|
box-shadow: inset 0 -0.5px 0 .5px alpha(#555, 0.7), inset 0 0.5px 0 .5px alpha(#777, 0.7);
|
||||||
border: 1px solid alpha(#111, 0.3);
|
border: 1px solid alpha(#111, 0.3);
|
||||||
border-top: none;
|
border-top: none;
|
||||||
@@ -21,7 +21,14 @@
|
|||||||
#about-button-box {
|
#about-button-box {
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
}
|
}
|
||||||
|
#vendor-label{
|
||||||
|
color: #888888;
|
||||||
|
margin-top : -1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#info-label{
|
||||||
|
color: #888888;
|
||||||
|
}
|
||||||
#about-info-title-box {
|
#about-info-title-box {
|
||||||
padding-left: 4rem;
|
padding-left: 4rem;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user