Skip to content

Instantly share code, notes, and snippets.

@SamantazFox
Last active August 20, 2020 22:23
Show Gist options
  • Save SamantazFox/ff19f80a28387351d376e4275c2abc89 to your computer and use it in GitHub Desktop.
Save SamantazFox/ff19f80a28387351d376e4275c2abc89 to your computer and use it in GitHub Desktop.
My personnalized MOTD display
#!/bin/sh
# Import color definitions
. $ZDOTDIR/colors
# Get OS details
. $ZDOTDIR/distro_specs
#
# Tux logo
#
c1="${COLOR_FG_WHITE}";
c2="${COLOR_FG_DGREY}";
c3="${COLOR_FG_YELLOW}";
tux_logo=(
"${c2} __ "
"${c2} ? ? "
"${c2} |${c1}o${c2}_${c1}o${c2} | "
"${c2} |${c3}:_/${c2} | "
"${c2} /${c1}/ \\\\${c2} \\ "
"${c2} (${c1}| |${c2} ) "
"${c3} /'\\_${c1} ${c3}_/\`\\ "
"${c3} \\___)${c2}=${c3}(___/ "
)
#
# Fox logo
#
f="${COLOR_FG_BROWN}";
w="${COLOR_FG_WHITE}";
b="${COLOR_FG_LBLUE}";
g="${COLOR_FG_GREY}";
fox_logo=(
"${w} "
"${w} /\ /\ "
"${f} //\\\\\\\\_//\\\\\\\\ ${w} ___ "
"${f} \_'''''_/ ${w} / / "
"${f} / ${b}* ${b}*${f} \ (${w}^^^${f}) "
"${f} \_\./_/ | \ "
"${f} / ^ / / "
"${g} Art by Todd Vargo "
)
#
# Text
#
bg="${STYLE_BOLD}${COLOR_FG_GREY}";
n="${COLOR_NONE}";
os_specs=(
"${bg}OS:${n} ${distro}"
"${bg}Kernel${n} ${kernel}"
"${bg}Shell:${n} ${shell}"
"${bg}Disk:${n} ${disks_used} / ${disks_total} [${disks_avail} free]"
"${bg}CPU:${n} ${cpu_name} @ ${cpu_threads}x ${cpu_freq}GHz"
"${bg}GPU:${n} ${gpu}"
"${bg}RAM:${n} ${mem_free_mb}MB / ${mem_total_mb}MB"
)
# Run MOTD, only if we're not in a SSH session
if [ -z $RAN_MOTD ] && [ -z $SSH_CONNECTION ]; then
# Display a funny formatted uptime
up=$(/usr/bin/uptime -p | sed -E 's/ weeks?/w/; s/ days?/d/; s/ hours?/h/; s/ minutes?/m/')
echo " Last time I went to bed: $(echo $up | sed -E 's/^up\s*//; s/\s*,\s*/ /g') ago..."
# Change separator to neline
IFS=$'\n'
# Retrieve data from screenfetch / neofetch / our own script
if [ -e /usr/bin/screenfetch ];
then
data=( $(screenfetch -A 'Linux' -n -d '-host,uptime,pkgs,res,de,wm,wmtheme,gtk') )
elif [ -e /usr/bin/neofetch ];
then
data=( $(neofetch --off --colors 'Linux' --disk_show '/' --disable title underline uptime packages resolution de wm theme term cols) )
else
data=( ${os_specs[@]} )
fi
# Random selection of logo to use
if $(test $(( $RANDOM % 2 )) -eq 1)
then
logo=( ${fox_logo[@]} )
else
logo=( ${tux_logo[@]} )
fi
# Display data + logo
i=0
for x in $logo; do
if [[ $i -ge 1 ]]; then str="${data[$i]}"; else str=""; fi
echo "${x}${str}"
i=$(( i+1 ))
done
# A new line after logo
echo
# Reset separator
unset IFS
# Make sure to not run it on .bashrc reload
export RAN_MOTD=true
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment