From 49b8ad6efbd1628ae20be9975745c187faaef124 Mon Sep 17 00:00:00 2001 From: qoijjj <129108030+qoijjj@users.noreply.github.com> Date: Sun, 18 Aug 2024 21:41:21 -0700 Subject: [PATCH] fix: parse epoch time directly from json for motd --- files/system/usr/libexec/ublue-motd | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/files/system/usr/libexec/ublue-motd b/files/system/usr/libexec/ublue-motd index 7da83df..2e1d583 100755 --- a/files/system/usr/libexec/ublue-motd +++ b/files/system/usr/libexec/ublue-motd @@ -2,12 +2,13 @@ # Modified from https://github.com/ublue-os/bazzite/blob/main/system_files/desktop/shared/usr/libexec/ublue-motd -RPM_OSTREE_STATUS=$(rpm-ostree status --json) +RPM_OSTREE_STATUS=$(rpm-ostree status --json --booted) IMAGE_REF_NAME=$(echo $RPM_OSTREE_STATUS | jq -r '.deployments[0]."container-image-reference" // empty | split("/")[-1]') IMAGE_TAG=$(echo $RPM_OSTREE_STATUS | jq -r '.deployments[0]."container-image-reference" // empty | split(":")[-1]') TIP="" -IMAGE_DATE=$(rpm-ostree status --json --booted | sed -n 's/.*Timestamp: \(.*\)/\1/p') +IMAGE_DATE_EPOCH=$(echo $RPM_OSTREE_STATUS | jq -r '.deployments[0].timestamp') +IMAGE_DATE=$(date -d "@$IMAGE_DATE_EPOCH") IMAGE_DATE_SECONDS=$(date -d "$IMAGE_DATE" +%s) CURRENT_SECONDS=$(date +%s) DIFFERENCE=$((CURRENT_SECONDS - IMAGE_DATE_SECONDS))