From 99bd17d5eac2bf66f56d6a0583adfdee337e7444 Mon Sep 17 00:00:00 2001 From: Odweta Date: Sat, 20 Dec 2025 19:58:14 +0100 Subject: [PATCH] initial commit with black and white info --- fetch.sh | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 fetch.sh diff --git a/fetch.sh b/fetch.sh new file mode 100755 index 0000000..7f0e567 --- /dev/null +++ b/fetch.sh @@ -0,0 +1,62 @@ +#!/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