2024-01-28 15:39:43 -08:00
|
|
|
#!/usr/bin/bash
|
2024-01-28 21:20:02 -08:00
|
|
|
escape() {
|
|
|
|
sed 's/[&/\]/\\&/g' <<< "$1"
|
|
|
|
}
|
|
|
|
|
2024-01-28 19:42:03 -08:00
|
|
|
TIP_FILE=$(ls "/usr/share/ublue-os/motd/tips/"*".md" | shuf -n 1)
|
2024-01-28 15:39:43 -08:00
|
|
|
if [[ -f "$TIP_FILE" ]]; then
|
|
|
|
IMAGE_INFO="/usr/share/ublue-os/image-info.json"
|
|
|
|
IMAGE_NAME=$(jq -r '."image-name"' < $IMAGE_INFO)
|
2024-01-28 21:20:02 -08:00
|
|
|
IMAGE_NAME_ESCAPED=$(escape "$IMAGE_NAME")
|
2024-01-28 15:39:43 -08:00
|
|
|
IMAGE_TAG=$(jq -r '."image-tag"' < $IMAGE_INFO)
|
2024-01-28 21:20:02 -08:00
|
|
|
IMAGE_TAG_ESCAPED=$(escape "$IMAGE_TAG")
|
2024-01-28 15:39:43 -08:00
|
|
|
TIP=$(shuf -n 1 "$TIP_FILE")
|
2024-01-28 21:20:02 -08:00
|
|
|
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 -
|
2024-01-28 15:39:43 -08:00
|
|
|
fi
|