Search Mabox Forum From CLI

Search the Mabox, Manjaro and Endevouros Forum.

With this very simple script it is possible to,
not only search the Mabox forum from terminal,
but also Manjaro and EndevourOs are searched.

search-mabox-forum.sh

#!/bin/bash
# ─── Forum Search Tool ───────────────────────────────────────────────

clear 

# Forums to search
FORUMS=(
    "EndeavourOS|https://forum.endeavouros.com"
    "Manjaro|https://forum.manjaro.org"
    "Mabox|https://forum.maboxlinux.org"
)

# ─── Dependency checks ──────────────────────────────────────────────
MISSING=false
for dep in curl jq notify-send; do
  if ! command -v "$dep" &>/dev/null; then
    echo "Missing dependency: $dep"
    MISSING=true
  fi
done
if [ "$MISSING" = true ]; then
  echo "Please install missing dependencies and re-run."
  exit 1
fi

# Directories & files
CACHE_DIR="$HOME/.cache/mabox_forum"
mkdir -p "$CACHE_DIR"
BOOKMARK_FILE="$CACHE_DIR/bookmarks.log"
HISTORY_FILE="$CACHE_DIR/history.log"

# ─── Colors ────────────────────────────────────────────────────────
BOLD=$(tput bold)
NORMAL=$(tput sgr0)
GREEN=$(tput setaf 2)
CYAN=$(tput setaf 6)
RED=$(tput setaf 1)
YELLOW=$(tput setaf 3)
WHITE=$(tput setaf 7)
ORANGE=$(tput setaf 208)

# Forum → color mapping
forum_color() {
  case "$1" in
    EndeavourOS) echo "$CYAN" ;;
    Manjaro) echo "$GREEN" ;;
    Mabox) echo "$YELLOW" ;;
    *) echo "$WHITE" ;;
  esac
}

# ─── Icons ─────────────────────────────────────────────────────────
ICON_SEARCH=$'\uf002'
ICON_BOOKMARK=$'\uf02e'
ICON_LINK=$'\uf0c1'
ICON_CHECK=$'\uf00c'
ICON_INFO=$'\uf05a'
ICON_EXIT=$'\uf00d'

# ─── Globals ──────────────────────────────────────────────────────
RESULT_TITLES=()
RESULT_LINKS=()
RESULT_FORUMS=()
idx=0

# ─── Functions ────────────────────────────────────────────────────

notify_help() {
  notify-send -u critical -a "Forum Search" -t 0 "Forum Search Help" \
"🔹 Search
 • Type keywords → search forums

🔹 Bookmarks
 • !bs → list bookmarks !BS
 • !b N [N...] → add bookmark(s) !B
 • !d N [N...120 80 33 12 5 2] → delete bookmark(s) !D
    
🔹 Navigation
 • !m → show menu  !M
 • !h → show help  !H
 • Ctrl+C → quit"
}

show_header() {
  echo -e "${BOLD}${GREEN}
███╗   ███╗ █████╗ ██████╗  ██████╗ ██╗  ██╗
████╗ ████║██╔══██╗██╔══██╗██╔═══██╗╚██╗██╔╝
██╔████╔██║███████║██████╔╝██║   ██║ ╚███╔╝
██║╚██╔╝██║██╔══██║██╔══██╗██║   ██║ ██╔██╗
██║ ╚═╝ ██║██║  ██║██████╔╝╚██████╔╝██╔╝ ██╗
╚═╝     ╚═╝╚═╝  ╚═╝╚═════╝  ╚═════╝ ╚═╝  ╚═╝
${NORMAL}"
  echo -e "${CYAN}${BOLD}Mabox | Manjaro | EndeavourOS Search Tool${NORMAL}\n"
  echo -e "${CYAN}Type !h to view commands.${NORMAL}\n"
}

bookmark_link() {
  local forum="$1" title="$2" link="$3"
  mkdir -p "$(dirname "$BOOKMARK_FILE")"
  echo "[$forum] $title - $link" >> "$BOOKMARK_FILE"
  echo -e "${GREEN}${ICON_CHECK} Added bookmark:${NORMAL} $title"
}

delete_bookmark() {
  local num="$1"
  if [[ ! -f "$BOOKMARK_FILE" || ! -s "$BOOKMARK_FILE" ]]; then
    echo -e "${RED}${ICON_INFO} No bookmarks to delete.${NORMAL}"
    return
  fi
  total=$(wc -l < "$BOOKMARK_FILE")
  if (( num < 1 || num > total )); then
    echo -e "${RED}${ICON_INFO} Invalid bookmark number: $num${NORMAL}"
    return
  fi
  sed -i "${num}d" "$BOOKMARK_FILE"
  echo -e "${GREEN}${ICON_CHECK} Bookmark #$num deleted.${NORMAL}"
}

open_link() {
  local link="$1"
  if command -v xdg-open &>/dev/null; then
    xdg-open "$link" &>/dev/null &
    echo -e "${GREEN}${ICON_CHECK} Opened in browser:${NORMAL} $link"
  else
    echo -e "${RED}${ICON_INFO} xdg-open not found.${NORMAL}"
  fi
}

display_results() {
  for i in "${!RESULT_TITLES[@]}"; do
    forum="${RESULT_FORUMS[$i]}"
    color=$(forum_color "$forum")
    echo -e "${WHITE}$i.${NORMAL} [${color}${forum}${NORMAL}] ${BOLD}${ORANGE}${RESULT_TITLES[$i]}${NORMAL}"
    echo -e "   ${WHITE}${ICON_LINK} ${RESULT_LINKS[$i]}${NORMAL}"
  done
}

list_bookmarks() {
  if [[ -f "$BOOKMARK_FILE" && -s "$BOOKMARK_FILE" ]]; then
    nl -w2 -s". " "$BOOKMARK_FILE"
  else
    echo -e "${YELLOW}${ICON_INFO} No bookmarks yet.${NORMAL}"
  fi
}

# ─── Trap Exit ──────────────────────────────────────────────────────
trap 'echo -e "\n${RED}${ICON_EXIT} Exiting...${NORMAL}"; tput cnorm; exit' SIGINT
tput civis

# ─── Start ─────────────────────────────────────────────────────────
show_header

# ─── Main Loop ──────────────────────────────────────────────────────
while true; do
  read -rp "${CYAN}${ICON_SEARCH} Keywords or command: ${NORMAL}" input
  [[ -n "$input" ]] || continue

  case "$input" in
    "!menu"|"!m"|"!M") show_header; continue ;;
    "!help"|"!h"|"!H") notify_help; continue ;;
    "!bs"|"!BS")
    list_bookmarks
    continue
    ;;

   "!b "*|"!B "*)
  # remove command prefix (both !b and !B)
  nums=($(echo "$input" | sed -E 's/^![bB][[:space:]]+//'))
  for num in "${nums[@]}"; do
      num="${num//[^0-9]/}"   # remove anything not a number
      if [[ -n "${RESULT_LINKS[$num]}" ]]; then
          bookmark_link "${RESULT_FORUMS[$num]}" "${RESULT_TITLES[$num]}" "${RESULT_LINKS[$num]}"
      else
          echo -e "${RED}${ICON_INFO} Invalid bookmark number: $num${NORMAL}"
      fi
  done
  continue ;;


   "!d "*|"!D "*)
  nums=($(echo "$input" | sed -E 's/^![dD][[:space:]]+//'))
  for num in "${nums[@]}"; do
      num="${num//[^0-9]/}"
      delete_bookmark "$num"
  done
  continue ;;


  esac

  # ─── Perform search ──────────────────────────────────────────────
  search_terms="$input"
  echo "$(date '+%F %T') - $search_terms" >> "$HISTORY_FILE"
  encoded_keyword=$(echo "$search_terms" | sed 's/ /+/g')

  echo -e "\n${CYAN}Fetching results for: '${search_terms}'...${NORMAL}"

  RESULT_TITLES=()
  RESULT_LINKS=()
  RESULT_FORUMS=()
  idx=0

  for entry in "${FORUMS[@]}"; do
    NAME="${entry%%|*}"
    URL="${entry##*|}"
    SEARCH_URL="$URL/search.json"

    response=$(curl -s "${SEARCH_URL}?q=${encoded_keyword}")
    if [[ -z "$response" || "$response" == "null" ]]; then
      echo -e "${RED}${ICON_INFO} $NAME: Error fetching data.${NORMAL}"
      continue
    fi

    hits=$(echo "$response" | jq '.topics | length')
    echo -e "\n${CYAN}${ICON_SEARCH} ${BOLD}$NAME forum ($hits results):${NORMAL}"
    if (( hits == 0 )); then
      echo -e "${YELLOW}${ICON_INFO} No results.${NORMAL}"
      continue
    fi

    while IFS=$'\t' read -r title link; do
      ((idx++))
      RESULT_FORUMS[$idx]="$NAME"
      RESULT_TITLES[$idx]="$title"
      RESULT_LINKS[$idx]="$link"
      echo -e "${WHITE}$idx.${NORMAL} [$(forum_color "$NAME")${NAME}${NORMAL}] ${BOLD}${ORANGE}${title}${NORMAL}"
      echo -e "   ${WHITE}${ICON_LINK} ${link}${NORMAL}"
    done < <(echo "$response" | jq -r --arg BASE "$URL" '
      .topics[] | {title: .title, link: ($BASE + "/t/" + .slug + "/" + (.id|tostring))} |
      [.title, .link] | @tsv
    ')
  done
done

How to search the forums …

:small_blue_diamond: Search
• Type keywords → search forums

:small_blue_diamond: Bookmarks
• !bs → list bookmarks !BS
• !b N [N…] → add bookmark(s) !B
• !d N [N…] → delete bookmark(s) !D

:small_blue_diamond: Navigation
• !m → show menu !M
• !h → show help !H
• Ctrl+C → quit"

Edit: last updated 06-sep-2025

:bird:

2 Likes

UPDATE:

  • added history search
  • and better search handling
  • update preview
$ search-mabox-forum.sh --history

:bird:

1 Like

Update: See Usage…

:bird:

1 Like

It looks great.
When I see these scripts, I always wonder where to save them.
Is it a good idea to have a folder like “My Scripts” for everything that isn’t part of the system itself?
If so, is it better to save it directly in /home or as a subfolder somewhere else?

New update: Non functional parts. Fine tune messages with MABOX ascii.

Just put it in ~/bin.

But it is a good start to run the script first from a myscripts dir to test the script.
When you think you can use it put in the home bin.

:bird:

1 Like

Update:

  • added creation date to the list.

:bird:

Thank you very much, but unfortunately, since I’m unable to resolve the issues I’m having with Mabox, I’ve decided to abandon the distro.
I can’t find answers to my questions, so I can’t resolve them.
Wish you success.

Update:

  • added manjaro forum for hits.
  • coloring URL mabox(green), manjaro(blue).

:bird:

Update:

  • Set viewer to bat if available, otherwise fallback to cat.
  • Coloring.
  • Order of output first Manjaro | Mabox topics.
    For quicker acces of Mabox topics.

Search Mabox From Cli…Script

:bird:

Update:

  • added Endevouros forum to the hits.
  • coloring
  • green mabox
  • blue manjaro
  • orange endevouros

:bird:

UPDATED:
Stupid script to search Mabox, Endeavour and Manjaro forum for issues and topics.

Now with bookmark and search sessions, etc.

Type keywords to search
!sessions → list past sessions
!open-session N → reopen session N
!clear → clear current session results
!bookmarks → show bookmarks
!bookmark N [N …] → save result N
!delbookmark N [N …] → remove bookmark(s) by number
!open N → open result N in browser
!new [name] → start new search session
Ctrl+C to quit

:bird: