Skip to content

Commit

Permalink
motds: fix and update dynamic motd.sh
Browse files Browse the repository at this point in the history
- The logo added in new dynamic motd would break due to word wrap if terminal columns were less than max line length. This fixes the issue by not drawing a logo if terminal columns are too few at draw time. Note that logo will still break if terminal size is changed after drawing.

- Use TERMUX_APP_PACKAGE_MANAGER instead of TERMUX_MAIN_PACKAGE_FORMAT

- Add donate link instead of gitter which should already exist in community link, including matrix rooms link.

Related pull requests termux/termux-packages#11250 and termux/termux-packages#11250
  • Loading branch information
agnostic-apollo committed Aug 13, 2022
1 parent 8114730 commit 9ae171e
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 25 deletions.
4 changes: 3 additions & 1 deletion motds/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ sysconf_DATA = motd.sh motd-playstore
CLEANFILES = motd.sh


do_subst = sed -e "s%[@]TERMUX_PREFIX[@]%$(termux_prefix)%g"

define process-rule
$1: $1.in Makefile
@echo "Creating $1"
@cat $(srcdir)/$1.in > $1
@$$(do_subst) < $(srcdir)/$1.in > $1
endef

$(eval $(call process-rule,motd.sh))
84 changes: 60 additions & 24 deletions motds/motd.sh.in
Original file line number Diff line number Diff line change
@@ -1,25 +1,61 @@
echo ""
echo -e " \e[47m \e[0m \e[1mWelcome to Termux!\e[0m"
echo -e " \e[47m \e[0m \e[0;37m\e[47m .\e[0m"
echo -e " \e[47m \e[0m \e[47m \e[0m \e[47m \e[0m \e[1mDocs:\e[0m \e[4mtermux.dev/docs\e[0m"
echo -e " \e[47m \e[0m \e[47m \e[0m \e[47m \e[0m \e[1mGitter:\e[0m \e[4mgitter.im/termux/termux\e[0m"
echo -e " \e[47m \e[0m \e[47m \e[0m \e[1mCommunity:\e[0m \e[4mtermux.dev/community\e[0m"
echo -e " \e[47m \e[0m \e[0;37m\e[47m .\e[0m"
echo -e " \e[47m \e[0m \e[1mTermux version:\e[0m ${TERMUX_VERSION-Unknown}"
echo ""
echo -e " \e[1mWorking with packages:\e[0m"
echo -e " \e[1mSearch:\e[0m pkg search <query>"
echo -e " \e[1mInstall:\e[0m pkg install <package>"
echo -e " \e[1mUpdate:\e[0m pkg update"
echo ""
if [ "$TERMUX_MAIN_PACKAGE_FORMAT" = "debian" ]; then
echo -e " \e[1mSubscribing to additional repos:\e[0m"
echo -e " \e[1mRoot:\e[0m pkg install root-repo"
echo -e " \e[1mX11: \e[0m pkg install x11-repo"
echo ""
echo " For fixing any repository issues,"
echo " try 'termux-change-repo' command."
echo ""
#!@TERMUX_PREFIX@/bin/bash

# Setup TERMUX_APP_PACKAGE_MANAGER
source "@TERMUX_PREFIX@/bin/termux-setup-package-manager" || exit 1

terminal_width="$(stty size | cut -d" " -f2)"
if [[ "$terminal_width" =~ ^[0-9]+$ ]] && [ "$terminal_width" -gt 60 ]; then

motd="
\e[47m \e[0m \e[1mWelcome to Termux!\e[0m
\e[47m \e[0m \e[0;37m\e[47m .\e[0m
\e[47m \e[0m \e[47m \e[0m \e[47m \e[0m \e[1mDocs:\e[0m \e[4mhttps://termux.dev/docs\e[0m
\e[47m \e[0m \e[47m \e[0m \e[47m \e[0m \e[1mDonate:\e[0m \e[4mhttps://termux.dev/donate\e[0m
\e[47m \e[0m \e[47m \e[0m \e[1mCommunity:\e[0m \e[4mhttps://termux.dev/community\e[0m
\e[47m \e[0m \e[0;37m\e[47m .\e[0m
\e[47m \e[0m \e[1mTermux version:\e[0m ${TERMUX_VERSION-Unknown}
"

motd_indent=" "

else

motd="
\e[1mWelcome to Termux!\e[0m
\e[1mDocs:\e[0m \e[4mhttps://termux.dev/docs\e[0m
\e[1mDonate:\e[0m \e[4mhttps://termux.dev/donate\e[0m
\e[1mCommunity:\e[0m \e[4mhttps://termux.dev/community\e[0m
\e[1mTermux version:\e[0m ${TERMUX_VERSION-Unknown}
"

motd_indent=""
fi
echo -e " Report issues at \e[4mtermux.dev/issues\e[0m"
echo ""

motd+="
${motd_indent}\e[1mWorking with packages:\e[0m
${motd_indent}\e[1mSearch:\e[0m pkg search <query>
${motd_indent}\e[1mInstall:\e[0m pkg install <package>
${motd_indent}\e[1mUpgrade:\e[0m pkg upgrade
"


if [ "$TERMUX_APP_PACKAGE_MANAGER" = "apt" ]; then

motd+="
${motd_indent}\e[1mSubscribing to additional repos:\e[0m
${motd_indent}\e[1mRoot:\e[0m pkg install root-repo
${motd_indent}\e[1mX11:\e[0m pkg install x11-repo
${motd_indent}For fixing any repository issues,
${motd_indent}try 'termux-change-repo' command.
"

fi

motd+="
${motd_indent}Report issues at \e[4mhttps://termux.dev/issues\e[0m
"

echo -e "$motd"

0 comments on commit 9ae171e

Please sign in to comment.