From 84a9e07615a8909faf048928e797b739ffaec6ba Mon Sep 17 00:00:00 2001 From: Kyle Gospodnetich Date: Tue, 30 Jan 2024 15:52:03 -0800 Subject: [PATCH] feat: Add a warning when the currently booted image is over a month old --- system_files/desktop/shared/usr/libexec/ublue-motd | 13 ++++++++++++- .../shared/usr/share/ublue-os/motd/bazzite.md | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/system_files/desktop/shared/usr/libexec/ublue-motd b/system_files/desktop/shared/usr/libexec/ublue-motd index 9afe6d19..d08e1edd 100755 --- a/system_files/desktop/shared/usr/libexec/ublue-motd +++ b/system_files/desktop/shared/usr/libexec/ublue-motd @@ -10,7 +10,18 @@ if [[ -f "$TIP_FILE" ]]; then IMAGE_NAME_ESCAPED=$(escape "$IMAGE_NAME") IMAGE_TAG=$(jq -r '."image-tag"' < $IMAGE_INFO) IMAGE_TAG_ESCAPED=$(escape "$IMAGE_TAG") - TIP=$(shuf -n 1 "$TIP_FILE") + TIP="󰋼 $(shuf -n 1 "$TIP_FILE")" + + IMAGE_DATE=$(rpm-ostree status --booted | sed -n 's/.*Timestamp: \(.*\)/\1/p') + IMAGE_DATE_SECONDS=$(date -d "$IMAGE_DATE" +%s) + CURRENT_SECONDS=$(date +%s) + DIFFERENCE=$((CURRENT_SECONDS - IMAGE_DATE_SECONDS)) + MONTH=$((30 * 24 * 60 * 60)) + if [ "$DIFFERENCE" -ge "$MONTH" ]; then + TIP='# 󰇻 Your current image is over 1 month old, run `ujust update`' + fi + TIP_ESCAPED=$(escape "$TIP") + sed -e "s/%IMAGE_NAME%/$IMAGE_NAME_ESCAPED/g" -e "s/%IMAGE_TAG%/$IMAGE_TAG_ESCAPED/g" -e "s/%TIP%/$TIP_ESCAPED/g" /usr/share/ublue-os/motd/bazzite.md | /usr/bin/glow -s auto - fi \ No newline at end of file diff --git a/system_files/desktop/shared/usr/share/ublue-os/motd/bazzite.md b/system_files/desktop/shared/usr/share/ublue-os/motd/bazzite.md index 2579f21f..33e93e5f 100644 --- a/system_files/desktop/shared/usr/share/ublue-os/motd/bazzite.md +++ b/system_files/desktop/shared/usr/share/ublue-os/motd/bazzite.md @@ -7,7 +7,7 @@ | `ujust toggle-user-motd` | Toggle this banner on/off | | `neofetch` | View system information | -󰋼 %TIP% +%TIP% - [ Report an issue](https://github.com/ublue-os/bazzite/issues) - [󰈙 Documentation](http://docs.bazzite.gg/) - [󰙯 Discord](https://discord.bazzite.gg/)