From 312db58775e8ae96e3f9653947590e25c33d4305 Mon Sep 17 00:00:00 2001 From: Joe Gitta Date: Sat, 23 May 2026 13:57:35 +0000 Subject: [PATCH] refactor: remove dead code, fix home screen config bug --- browser.py | 25 +++++++------------------ deploy.sh | 4 ++-- home-screen-index.html | 6 ++++-- 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/browser.py b/browser.py index dd1a038..9aa69f3 100755 --- a/browser.py +++ b/browser.py @@ -10,7 +10,7 @@ from PyQt5.QtGui import QFont, QColor, QPalette, QCursor from PyQt5.QtWidgets import ( QApplication, QWidget, QHBoxLayout, QVBoxLayout, QPushButton, QLabel, QScrollArea, QDialog, QLineEdit, - QMessageBox, QFrame, QMenu, QAction, + QMessageBox, QFrame, QTreeWidget, QTreeWidgetItem, QAbstractItemView ) @@ -18,7 +18,6 @@ HOME_URL = "file:///home/jgitta/kiosk-home/index.html" BOOKMARKS_FILE = "/home/jgitta/kiosk-browser/bookmarks.json" CDP_PORT = 9222 TOOLBAR_H = 72 # single row — was 142 (82 + 60) -TOP_H = TOOLBAR_H # Screen size is detected dynamically in main() after QApplication starts SCREEN_W = 1920 # overwritten at runtime SCREEN_H = 1080 # overwritten at runtime @@ -39,16 +38,6 @@ PURPLE = "#5a5a8a" PURPLE_HOVER = "#7a7aaa" FONT_SIZE = 18 -MENU_STYLE = """ - QMenu { - background: #1e3a5c; color: white; - border: 2px solid #3a6da4; border-radius: 8px; padding: 4px; - } - QMenu::item { padding: 14px 36px 14px 16px; border-radius: 6px; font-size: 17px; } - QMenu::item:selected { background: #3a6da4; color: white; } - QMenu::separator { height: 1px; background: #3a6da4; margin: 4px 8px; } -""" - # ── Helpers ─────────────────────────────────────────────────────── def mk_btn(label, color, hover, min_w=120, min_h=52, fs=FONT_SIZE): b = QPushButton(label) @@ -603,7 +592,7 @@ class KioskOverlay(QWidget): Qt.Tool ) self.setAttribute(Qt.WA_ShowWithoutActivating) - self.setGeometry(0, 0, SCREEN_W, TOP_H) + self.setGeometry(0, 0, SCREEN_W, TOOLBAR_H) self.setStyleSheet("background:transparent;") QApplication.instance().installEventFilter(self) @@ -629,8 +618,8 @@ class KioskOverlay(QWidget): if w < 400 or h < 200: return SCREEN_W, SCREEN_H = w, h - self.setGeometry(0, 0, SCREEN_W, TOP_H) - self.resize(SCREEN_W, TOP_H) + self.setGeometry(0, 0, SCREEN_W, TOOLBAR_H) + self.resize(SCREEN_W, TOOLBAR_H) if self.bm_panel.isVisible(): pw = self.bm_panel.width() self.bm_panel.move(SCREEN_W - pw - 4, TOOLBAR_H) @@ -638,7 +627,7 @@ class KioskOverlay(QWidget): QTimer.singleShot(500, self._resize_chrome) def _resize_chrome(self): - self.cdp.resize_window(0, TOP_H, SCREEN_W, SCREEN_H - TOP_H) + self.cdp.resize_window(0, TOOLBAR_H, SCREEN_W, SCREEN_H - TOOLBAR_H) def changeEvent(self, event): """Un-minimise the toolbar the instant it gets iconified.""" @@ -787,7 +776,7 @@ def launch_chrome(): except Exception as e: print(f"Cookie clear warning: {e}") - chrome_h = SCREEN_H - TOP_H + chrome_h = SCREEN_H - TOOLBAR_H cmd = [ "chromium", "--no-first-run", @@ -803,7 +792,7 @@ def launch_chrome(): "--user-data-dir=/home/jgitta/chromium-kiosk", f"--remote-debugging-port={CDP_PORT}", "--remote-allow-origins=*", - f"--window-position=0,{TOP_H}", + f"--window-position=0,{TOOLBAR_H}", f"--window-size={SCREEN_W},{chrome_h}", f"--app={HOME_URL}", ] diff --git a/deploy.sh b/deploy.sh index 6f5fd32..838ce81 100755 --- a/deploy.sh +++ b/deploy.sh @@ -23,7 +23,7 @@ inject_config() { if [ -f "$config" ]; then local config_json=$(cat "$config" | sed 's/\\/\\\\/g' | sed 's/"/\\"/g' | tr '\n' ' ') - sed "s|const config = {.*};|const config = $config_json;|" "$src" > "$dst" + sed "s|const config = {};|const config = $config_json;|" "$src" > "$dst" echo " Injected config.json into home screen" else cp "$src" "$dst" @@ -67,7 +67,7 @@ if [ -n "$KIOSK" ]; then git pull # Inject config at deploy time config_json=\$(cat config.json | sed 's/\\\\/\\\\\\\\/g' | sed 's/\"/\\\\\"/g' | tr '\n' ' ') - sed \"s|const config = {.*};|const config = \$config_json;|\" home-screen-index.html > /home/jgitta/kiosk-home/index.html + sed \"s|const config = {};|const config = \$config_json;|\" home-screen-index.html > /home/jgitta/kiosk-home/index.html /usr/local/bin/kiosk-restart " echo " Production updated." diff --git a/home-screen-index.html b/home-screen-index.html index 5301411..83a15e0 100644 --- a/home-screen-index.html +++ b/home-screen-index.html @@ -98,6 +98,8 @@