Skip to content

Commit

Permalink
feat: Add a warning when the currently booted image is over a month old
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleGospo committed Jan 30, 2024
1 parent 38cc4d0 commit 84a9e07
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion system_files/desktop/shared/usr/libexec/ublue-motd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand Down

0 comments on commit 84a9e07

Please sign in to comment.