Skip to content

Commit

Permalink
motds: add static motd back and use it as default instead of dynamic …
Browse files Browse the repository at this point in the history
…motd and add support for custom motd

The dynamic motd has issues with logo word wrap as discussed in 5956876 and so can't be used as default. Users who want to use it or a custom one can create a motd file/symlink at `~/.termux/motd.sh` to load a custom motd. To use the dynamic motd provided by termux-tools package, run `ln -sf $PREFIX/etc/motd.sh ~/.termux/motd.sh`

Also directly execute motd.sd and rely on interpreter instead of executing with bash in case its not available or user does not want a bash script as motd.sh
  • Loading branch information
agnostic-apollo committed Aug 15, 2022
1 parent 5956876 commit 6a0f5cc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
35 changes: 33 additions & 2 deletions motds/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

# The motd-playstore is an additional motd that will only be displayed
# if the termux-app version is very old (like the version found on playstore)
sysconf_DATA = motd.sh motd-playstore
sysconf_DATA = motd.sh motd motd-playstore

CLEANFILES = motd.sh
CLEANFILES = motd.sh motd


do_subst = sed -e "s%[@]TERMUX_PREFIX[@]%$(termux_prefix)%g"
Expand All @@ -38,3 +38,34 @@ $1: $1.in Makefile
endef

$(eval $(call process-rule,motd.sh))


motd:
@echo "Creating motd file"

@echo "Welcome to Termux!" > motd
@echo "" >> motd
@echo "Docs: https://termux.dev/docs" >> motd
@echo "Donate: https://termux.dev/donate" >> motd
@echo "Community: https://termux.dev/community" >> motd

@echo "" >> motd
@echo "Working with packages:" >> motd
@echo "" >> motd
@echo " - Search: pkg search <query>" >> motd
@echo " - Install: pkg install <package>" >> motd
@echo " - Upgrade: pkg upgrade" >> motd

ifeq ($(TERMUX_PACKAGE_MANAGER),apt)
@echo "" >> motd
@echo "Subscribing to additional repositories:" >> motd
@echo "" >> motd
@echo " - Root: pkg install root-repo" >> motd
@echo " - X11: pkg install x11-repo" >> motd
@echo "" >> motd
@echo "For fixing any repository issues," >> motd
@echo "try 'termux-change-repo' command." >> motd
endif

@echo "" >> motd
@echo "Report issues at https://termux.dev/issues" >> motd
8 changes: 5 additions & 3 deletions scripts/login.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/sh

if tty >/dev/null 2>&1 && [ $# = 0 ] && [ ! -f ~/.hushlogin ] && [ -z "$TERMUX_HUSHLOGIN" ]; then
if [ -f @TERMUX_PREFIX@/etc/motd.sh ]; then
# Dynamic motd is preferred over plain-text.
bash @TERMUX_PREFIX@/etc/motd.sh
# Use user defined dynamic motd file if it exists
if [ -f ~/.termux/motd.sh ]; then
[ ! -x ~/.termux/motd.sh ] && chmod u+x ~/.termux/motd.sh
~/.termux/motd.sh
# Default to termux-tools package provided static motd file if it exists
elif [ -f @TERMUX_PREFIX@/etc/motd ]; then
cat @TERMUX_PREFIX@/etc/motd
fi
Expand Down

0 comments on commit 6a0f5cc

Please sign in to comment.