From 844bc15182a0cefef322e447fb222d466c770f68 Mon Sep 17 00:00:00 2001 From: "Jorge O. Castro" Date: Sun, 28 Jan 2024 22:30:10 -0800 Subject: [PATCH] fix: update motd generation (#853) Co-authored-by: Kyle Gospodnetich --- usr/libexec/ublue-motd | 11 +- .../ublue-os/motd/{design => }/bluefin.md | 5 +- usr/share/ublue-os/motd/design/dracula.json | 192 ------------------ .../motd/tips/{10-tips => 10-tips.md} | 0 4 files changed, 11 insertions(+), 197 deletions(-) rename usr/share/ublue-os/motd/{design => }/bluefin.md (84%) delete mode 100644 usr/share/ublue-os/motd/design/dracula.json rename usr/share/ublue-os/motd/tips/{10-tips => 10-tips.md} (100%) diff --git a/usr/libexec/ublue-motd b/usr/libexec/ublue-motd index d10334731f1..760f6a53cc2 100755 --- a/usr/libexec/ublue-motd +++ b/usr/libexec/ublue-motd @@ -1,9 +1,16 @@ #!/usr/bin/bash -TIP_FILE=$(ls "/usr/share/ublue-os/motd/tips/"* | shuf -n 1) +escape() { + sed 's/[&/\]/\\&/g' <<< "$1" +} + +TIP_FILE=$(ls "/usr/share/ublue-os/motd/tips/"*".md" | shuf -n 1) if [[ -f "$TIP_FILE" ]]; then IMAGE_INFO="/usr/share/ublue-os/image-info.json" IMAGE_NAME=$(jq -r '."image-name"' < $IMAGE_INFO) + 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") - /usr/bin/glow -s /usr/share/ublue-os/motd/design/dracula.json /usr/share/ublue-os/motd/design/bluefin.md | sed -e "s/%IMAGE_NAME%/$IMAGE_NAME/g" -e "s/%IMAGE_TAG%/$IMAGE_TAG/g" -e "s/%TIP%/$TIP/g" + 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/bluefin.md | /usr/bin/glow -s auto - fi \ No newline at end of file diff --git a/usr/share/ublue-os/motd/design/bluefin.md b/usr/share/ublue-os/motd/bluefin.md similarity index 84% rename from usr/share/ublue-os/motd/design/bluefin.md rename to usr/share/ublue-os/motd/bluefin.md index 1e1f40fb6fa..69d2a0326f0 100644 --- a/usr/share/ublue-os/motd/design/bluefin.md +++ b/usr/share/ublue-os/motd/bluefin.md @@ -7,9 +7,8 @@ | `ujust toggle-user-motd` | Toggle this banner on/off | | `ujust bluefin-cli` | Configure the terminal (Alpha) | -Report issues at: 󰊤 https://issues.projectbluefin.io - -*Tip: %TIP%* +Tip: %TIP% +- 󰊤 [Issues](https://issues.projectbluefin.io) - 󰈙 [Documentation:](http://docs.projectbluefin.io/) - 󰊌 [Discuss:](https://community.projectbluefin.io/) diff --git a/usr/share/ublue-os/motd/design/dracula.json b/usr/share/ublue-os/motd/design/dracula.json deleted file mode 100644 index ef0d292769f..00000000000 --- a/usr/share/ublue-os/motd/design/dracula.json +++ /dev/null @@ -1,192 +0,0 @@ -{ - "document": { - "block_prefix": "\n", - "block_suffix": "\n", - "color": "#f8f8f2", - "margin": 2 - }, - "block_quote": { - "color": "#f1fa8c", - "italic": true, - "indent": 2 - }, - "paragraph": {}, - "list": { - "color": "#f8f8f2", - "level_indent": 2 - }, - "heading": { - "block_suffix": "\n", - "color": "#bd93f9", - "bold": true - }, - "h1": { - "prefix": "# " - }, - "h2": { - "prefix": "## " - }, - "h3": { - "prefix": "### " - }, - "h4": { - "prefix": "#### " - }, - "h5": { - "prefix": "##### " - }, - "h6": { - "prefix": "###### " - }, - "text": {}, - "strikethrough": { - "crossed_out": true - }, - "emph": { - "color": "#f1fa8c", - "italic": true - }, - "strong": { - "color": "#ffb86c", - "bold": true - }, - "hr": { - "color": "#6272A4", - "format": "\n--------\n" - }, - "item": { - "block_prefix": "• " - }, - "enumeration": { - "block_prefix": ". ", - "color": "#8be9fd" - }, - "task": { - "ticked": "[✓] ", - "unticked": "[ ] " - }, - "link": { - "color": "#8be9fd", - "underline": true - }, - "link_text": { - "color": "#ff79c6" - }, - "image": { - "color": "#8be9fd", - "underline": true - }, - "image_text": { - "color": "#ff79c6", - "format": "Image: {{.text}} →" - }, - "code": { - "color": "#50fa7b" - }, - "code_block": { - "color": "#ffb86c", - "margin": 2, - "chroma": { - "text": { - "color": "#f8f8f2" - }, - "error": { - "color": "#f8f8f2", - "background_color": "#ff5555" - }, - "comment": { - "color": "#6272A4" - }, - "comment_preproc": { - "color": "#ff79c6" - }, - "keyword": { - "color": "#ff79c6" - }, - "keyword_reserved": { - "color": "#ff79c6" - }, - "keyword_namespace": { - "color": "#ff79c6" - }, - "keyword_type": { - "color": "#8be9fd" - }, - "operator": { - "color": "#ff79c6" - }, - "punctuation": { - "color": "#f8f8f2" - }, - "name": { - "color": "#8be9fd" - }, - "name_builtin": { - "color": "#8be9fd" - }, - "name_tag": { - "color": "#ff79c6" - }, - "name_attribute": { - "color": "#50fa7b" - }, - "name_class": { - "color": "#8be9fd" - }, - "name_constant": { - "color": "#bd93f9" - }, - "name_decorator": { - "color": "#50fa7b" - }, - "name_exception": {}, - "name_function": { - "color": "#50fa7b" - }, - "name_other": {}, - "literal": {}, - "literal_number": { - "color": "#6EEFC0" - }, - "literal_date": {}, - "literal_string": { - "color": "#f1fa8c" - }, - "literal_string_escape": { - "color": "#ff79c6" - }, - "generic_deleted": { - "color": "#ff5555" - }, - "generic_emph": { - "color": "#f1fa8c", - "italic": true - }, - "generic_inserted": { - "color": "#50fa7b" - }, - "generic_strong": { - "color": "#ffb86c", - "bold": true - }, - "generic_subheading": { - "color": "#bd93f9" - }, - "background": { - "background_color": "#282a36" - } - } - }, - "table": { - "center_separator": "┼", - "column_separator": "│", - "row_separator": "─" - }, - "definition_list": {}, - "definition_term": {}, - "definition_description": { - "block_prefix": "\n🠶 " - }, - "html_block": {}, - "html_span": {} -} diff --git a/usr/share/ublue-os/motd/tips/10-tips b/usr/share/ublue-os/motd/tips/10-tips.md similarity index 100% rename from usr/share/ublue-os/motd/tips/10-tips rename to usr/share/ublue-os/motd/tips/10-tips.md