diff --git a/src/kiosk/boot.py b/src/kiosk/boot.py index 55710e3..155bd09 100644 --- a/src/kiosk/boot.py +++ b/src/kiosk/boot.py @@ -6,13 +6,15 @@ # (at your option) any later version. from PyQt6.QtWidgets import ( - QWidget, QPushButton, QVBoxLayout, QHBoxLayout, QLabel, QToolButton + QWidget, QPushButton, QVBoxLayout, QHBoxLayout, QLabel, QToolButton, QFrame ) from PyQt6.QtCore import Qt, QSize, pyqtSignal from PyQt6.QtGui import QPixmap, QIcon from src.utils.probe import OSFamily from src.kiosk.config import * from src.kiosk.theme import * +from src.utils.net import * +import os class BootView(QWidget): @@ -31,11 +33,42 @@ class BootView(QWidget): self.layout.setSpacing(10) self.layout.setAlignment(Qt.AlignmentFlag.AlignCenter) + # Client data frame + self.data_widget = QFrame(self) + self.data_widget.setFrameStyle(QFrame.Shape.StyledPanel | QFrame.Shadow.Plain) + data_layout = QVBoxLayout(self.data_widget) + data_layout.setAlignment(Qt.AlignmentFlag.AlignCenter) + + ethernet_interface = get_ethernet_interface() + client_ip = getifaddr(ethernet_interface) + client_mac = get_mac_from_interface(ethernet_interface) + client_hostname = os.uname().nodename + client_link = ethtool(ethernet_interface) + + label_data_list = [ + f'IP: {client_ip}', + f'MAC: {client_mac}', + f'HOSTNAME: {client_hostname}', + f'LINK: {client_link} Mbps' + ] + + for label_text in label_data_list: + data_label = QLabel(label_text) + data_label.setStyleSheet('font-weight: 600;') + data_layout.addWidget(data_label) + + self.data_widget.setParent(self) + self.data_widget.adjustSize() + self.data_widget.move(0, 0) + + # Header image_label = QLabel() + image_label.setStyleSheet("background: transparent;") pixmap = get_image('header.png') image_label.setPixmap(pixmap) image_label.setAlignment(Qt.AlignmentFlag.AlignCenter) self.layout.addWidget(image_label) + self.layout.addStretch() boot_os_list = get_boot_os_list() @@ -121,7 +154,9 @@ class BootView(QWidget): poweroff_button.clicked.connect(self.on_poweroff_pressed) # Footer + self.layout.addStretch() image_label = QLabel() + image_label.setStyleSheet("background: transparent;") pixmap = get_image('footer.png') image_label.setPixmap(pixmap) image_label.setAlignment(Qt.AlignmentFlag.AlignCenter) diff --git a/src/kiosk/config.py b/src/kiosk/config.py index bee540a..38f4b78 100644 --- a/src/kiosk/config.py +++ b/src/kiosk/config.py @@ -37,11 +37,8 @@ def set_status(value): def is_busy_enabled(): return config_data.get('status', 'idle') == 'busy' -def get_ip(): - return getifaddr(get_ethernet_interface()) - def get_log_path(): - return f'/opt/opengnsys/log/{get_ip()}.log' + return f'/opt/opengnsys/log/{getifaddr(get_ethernet_interface())}.log' def get_os_columns(): return config_data.get('os_columns', 2) diff --git a/src/utils/net.py b/src/utils/net.py index 65839a2..9fc71ca 100644 --- a/src/utils/net.py +++ b/src/utils/net.py @@ -82,6 +82,14 @@ def get_ethernet_interface(): return eth_interfaces[0] +def get_mac_from_interface(interface): + interfaces = psutil.net_if_addrs() + if interface in interfaces: + for addr in interfaces[interface]: + if addr.family == psutil.AF_LINK: + return addr.address + return None + def ethtool(interface): try: ETHTOOL_GSET = 0x00000001