#!/bin/bash # logo definition LOGO=" | /\\ | / \\ | / \\ | / \\ | / ,, \\ | / | | \\ | /_-'' ''-_\\ | |" # all the info fields USER=$USER HOSTNAME=$(cat /etc/hostname) #CPU_MODELNAME=$(cat /proc/cpuinfo | awk '/model name\t:/' | awk -F ": " '{print $2}' | head -1) CPU_MODELNAME="Intel Core i5-8365U" CPU_THREADS_NUM=$(nproc) RAM_FREE=$(awk '/MemFree:/ { printf "%.1f\n", $2 / 1000000 }' /proc/meminfo) RAM_TOTAL=$(awk '/MemTotal:/ { printf "%.1f\n", $2 / 1000000 }' /proc/meminfo) RAM="${RAM_FREE}G / ${RAM_TOTAL}G" #GPU=$(cat /sys/class/drm/card1/device/{vendor,device} | tr '\n' ':' | head -c -1) #GPU="Intel(R) UHD Graphics 620" UPTIME=$(awk '{ s=int($1); printf "%dd %dh %dm\n", s/86400, (s%86400)/3600, (s%3600)/60 }' /proc/uptime) KERNEL=$(uname -r) WM="dwm" TERM=$TERM SHELL=$SHELL horizontal_n=$((${#USER} + ${#HOSTNAME} + 3)) horizontal_separator_char="-" HORIZONTAL_SEPARATOR=$(printf '%*s' "$horizontal_n" ' ' | tr ' ' "$horizontal_separator_char") # ----- # output login # convert the logo into an array of "lines" (strings) mapfile -t LOGO_LINES <<< "$LOGO" # array of strings as well for the info fields INFO_LINES=( "$USER @ $HOSTNAME" $HORIZONTAL_SEPARATOR "CPU : $CPU_MODELNAME ($CPU_THREADS_NUM threads)" "RAM : $RAM" #"GPU: $GPU" " : $UPTIME" " : $KERNEL" " : $WM" " : $TERM" " : $SHELL" ) for i in "${!LOGO_LINES[@]}"; do # 15 chars is the length of the logo printf "%-15s" "${LOGO_LINES[$i]}" # only print info if it exists for this line [ $i -lt ${#INFO_LINES[@]} ] && printf " %s" "${INFO_LINES[$i]}" printf "\n" done