diff options
| author | Andrew Dolgov <fox@fakecake.org> | 2026-07-03 10:00:13 +0300 |
|---|---|---|
| committer | Andrew Dolgov <fox@fakecake.org> | 2026-07-03 10:00:13 +0300 |
| commit | 862b3156f7e6b19af570e7bcaaaf52614d0672be (patch) | |
| tree | b8668864ea2f0c995b0c6e70635a7c59cb7e239d | |
| parent | 6e68b142244c09c20ef54de4c1800e3bfa9a0fcd (diff) | |
| download | fungus-launcher-862b3156f7e6b19af570e7bcaaaf52614d0672be.tar.gz fungus-launcher-862b3156f7e6b19af570e7bcaaaf52614d0672be.tar.xz | |
store timestamp of last steamrt check
| -rw-r--r-- | fungus/settings_dialog.py | 27 | ||||
| -rw-r--r-- | fungus/umu_manager.py | 41 |
2 files changed, 65 insertions, 3 deletions
diff --git a/fungus/settings_dialog.py b/fungus/settings_dialog.py index 15a1df0..58f7f84 100644 --- a/fungus/settings_dialog.py +++ b/fungus/settings_dialog.py @@ -23,6 +23,8 @@ from fungus.umu_manager import ( check_and_install_if_needed, get_installed_umu_version, get_latest_umu_version, + get_steamrt_last_check, + save_steamrt_last_check, update_steam_runtime, ) @@ -302,10 +304,17 @@ class SettingsDialog(EntryTooltipMixin, Gtk.Dialog): grid_umu.attach(self.progress_umu, 0, 4, 2, 1) # Steam Runtime section + self.label_umu_runtime_last = Gtk.Label(label="Last checked: -") + self.label_umu_runtime_last.set_halign(Gtk.Align.START) + self.label_umu_runtime_last.set_margin_start(10) + self.label_umu_runtime_last.set_max_width_chars(30) + self.label_umu_runtime_last.set_ellipsize(Pango.EllipsizeMode.END) + grid_umu.attach(self.label_umu_runtime, 0, 5, 1, 1) grid_umu.attach(self.label_umu_runtime_status, 0, 6, 1, 1) - grid_umu.attach(self.button_umu_runtime, 0, 7, 1, 1) - grid_umu.attach(self.progress_umu_runtime, 0, 8, 2, 1) + grid_umu.attach(self.label_umu_runtime_last, 0, 7, 1, 1) + grid_umu.attach(self.button_umu_runtime, 0, 8, 1, 1) + grid_umu.attach(self.progress_umu_runtime, 0, 9, 2, 1) grid_miscellaneous.attach(self.checkbox_discrete_gpu, 0, 2, 1, 1) grid_miscellaneous.attach(self.checkbox_show_hidden, 0, 3, 1, 1) @@ -695,7 +704,12 @@ class SettingsDialog(EntryTooltipMixin, Gtk.Dialog): GLib.idle_add(self.progress_umu_runtime.set_fraction, percent / 100.0) GLib.idle_add(update_progress, "Updating…") - success, message = update_steam_runtime(runner, progress_callback=progress_cb) + def on_success(): + save_steamrt_last_check() + + success, message = update_steam_runtime( + runner, progress_callback=progress_cb, on_success=on_success + ) GLib.idle_add(self._on_runtime_done, success, message) threading.Thread(target=runtime_thread, daemon=True).start() @@ -797,6 +811,13 @@ class SettingsDialog(EntryTooltipMixin, Gtk.Dialog): else: self.label_umu_installed.set_text("Not installed") + # Load Steam Runtime last-check time + last_check = get_steamrt_last_check() + if last_check: + self.label_umu_runtime_last.set_text(f"Last checked: {last_check}") + else: + self.label_umu_runtime_last.set_text("Last checked: -") + def load_liststore_from_file(self, filename=envar_dir): """Read environment variable lines from *filename* and populate the liststore.""" self.liststore.clear() diff --git a/fungus/umu_manager.py b/fungus/umu_manager.py index 68bfc4e..21d80f3 100644 --- a/fungus/umu_manager.py +++ b/fungus/umu_manager.py @@ -10,6 +10,7 @@ import subprocess import tarfile import tempfile from pathlib import Path +from collections.abc import Callable import requests @@ -22,6 +23,7 @@ xdg_data_home = os.getenv("XDG_DATA_HOME", os.path.expanduser("~/.local/share")) UMU_INSTALL_DIR = os.path.join(xdg_data_home, "fungus-launcher") UMU_VERSION_FILE = os.path.join(UMU_INSTALL_DIR, "version.txt") UMU_BIN_PATH = os.path.join(UMU_INSTALL_DIR, "umu-run") +STEAMRT_CHECK_FILE = os.path.join(UMU_INSTALL_DIR, "steamrt.txt") # Path to the umu-run binary (may differ from UMU_BIN_PATH depending on deployment) def get_umu_run_path() -> str: @@ -68,6 +70,40 @@ def is_umu_installed() -> bool: return os.path.isfile(UMU_BIN_PATH) and os.access(UMU_BIN_PATH, os.X_OK) +def get_steamrt_last_check() -> str | None: + """Read the last Steam Runtime update-check timestamp. + + Returns a human-readable string (e.g. ``"2025-07-01 14:30"``) or ``None`` + if the file does not exist or is empty. + """ + if os.path.exists(STEAMRT_CHECK_FILE): + try: + with open(STEAMRT_CHECK_FILE, encoding="utf-8") as f: + value = f.read().strip() + return value if value else None + except OSError: + return None + return None + + +def save_steamrt_last_check() -> bool: + """Write the current timestamp to the SteamRT last-check file. + + Returns ``True`` on success, ``False`` on failure. + """ + from datetime import datetime + + timestamp = datetime.now().strftime("%Y-%m-%d %H:%M") + try: + os.makedirs(UMU_INSTALL_DIR, exist_ok=True) + with open(STEAMRT_CHECK_FILE, "w", encoding="utf-8") as f: + f.write(timestamp) + return True + except OSError as e: + print(f"[Runtime] Failed to save last-check timestamp: {e}") + return False + + def download_umu_run(version: str, progress_callback=None) -> bool: """Download and install the UMU-Launcher binary from a tar archive. @@ -210,6 +246,7 @@ def check_and_install_if_needed(progress_callback=None) -> tuple[bool, str]: def update_steam_runtime( protonpath: str, progress_callback=None, + on_success: Callable[[], None] | None = None, ) -> tuple[bool, str]: """Trigger the UMU Steam Runtime download/update for a given Proton path. @@ -258,6 +295,8 @@ def update_steam_runtime( if progress_callback: progress_callback(50) elif "up to date" in line.lower(): + if on_success: + on_success() return (True, "Already up to date") proc.wait() @@ -265,6 +304,8 @@ def update_steam_runtime( if proc.returncode == 0: if progress_callback: progress_callback(100) + if on_success: + on_success() return (True, "Update OK") return (False, f"Update failed (exit code {proc.returncode})") |
