Skip to content

Commit

Permalink
fix: Perfomance improvements in ublue-motd (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeglius authored Jan 20, 2025
1 parent 11a8ab4 commit 0463429
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions ublue/motd/src/ublue-motd
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ THEMES_DIRECTORY="$(get_config '."themes-directory"' "/usr/share/ublue-os/motd/t
# HOOKS_DIRECTORY="$(get_config '."hooks-directory"' "/usr/share/ublue-os/motd/hooks.d")"
[ ! -f "$TEMPLATE_FILE" ] && die "Failed reading template file"

TIP_FILE="$(find "$TIP_DIRECTORY" -iname "*.md" 2>/dev/null | shuf -n 1)"

if [ "$CHECK_OUTDATED" == "true" ] ; then
IMAGE_DATE=$(rpm-ostree status --booted | sed -n 's/.*Timestamp: \(.*\)/\1/p')
IMAGE_DATE_SECONDS=$(date -d "$IMAGE_DATE" +%s)
IMAGE_DATE_SECONDS=$(rpm-ostree status --booted --json | jq -r '.deployments[].timestamp')
CURRENT_SECONDS=$(date +%s)
DIFFERENCE=$((CURRENT_SECONDS - IMAGE_DATE_SECONDS))
ONE_MONTH=$((30 * 24 * 60 * 60))
Expand All @@ -47,7 +44,7 @@ if [ "$CHECK_OUTDATED" == "true" ] ; then
fi
fi

TIP="${TIP:-$(shuf -n 1 "$TIP_FILE")}"
TIP="${TIP:-"$(/usr/bin/cat "$TIP_DIRECTORY"/*.md 2>/dev/null | shuf -n 1)"}"
TIP_ESCAPED="󰋼 $(escape "$TIP")"

KEY_WARN_FILE="/run/user-motd-sbkey-warn.md"
Expand Down
2 changes: 1 addition & 1 deletion ublue/motd/ublue-motd.spec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%global debug_package %{nil}

Name: ublue-motd
Version: 0.2.2
Version: 0.2.3
Release: 1%{?dist}
Summary: MOTD scripts for Universal Blue images

Expand Down

0 comments on commit 0463429

Please sign in to comment.