2021-02-12 23:20:57 +01:00
|
|
|
#!/usr/bin/env sh
|
2020-05-15 15:06:43 +02:00
|
|
|
|
2020-05-20 18:34:34 +02:00
|
|
|
######################################################################
|
2021-02-14 19:07:45 +01:00
|
|
|
# @author : swytch (adapated from github.com/jschx/ufetch)
|
|
|
|
# @file : fetch
|
2021-02-15 00:37:34 +01:00
|
|
|
# @license : GPLv3
|
2021-02-14 19:07:45 +01:00
|
|
|
# @created : Wednesday May 20, 2020 18:16:09 CEST
|
2020-05-20 18:34:34 +02:00
|
|
|
#
|
2021-02-14 19:07:45 +01:00
|
|
|
# @description : display system infos
|
2020-05-20 18:34:34 +02:00
|
|
|
######################################################################
|
|
|
|
|
2020-05-15 15:06:43 +02:00
|
|
|
|
|
|
|
## INFO
|
|
|
|
|
|
|
|
# $USER is already defined
|
2021-09-08 19:10:38 +02:00
|
|
|
host="$(cat /etc/conf.d/hostname | awk -F'"' '{ printf $2 }')"
|
|
|
|
machine="$(cat /sys/devices/virtual/dmi/id/product_version)"
|
|
|
|
os='Gentoo'
|
2020-05-15 15:06:43 +02:00
|
|
|
kernel="$(uname -sr)"
|
|
|
|
uptime="$(uptime -p | sed 's/up //')"
|
2021-09-08 19:10:38 +02:00
|
|
|
packages="$(printf '%s\n' /var/db/pkg/*/* | wc -l)"
|
2021-09-23 23:27:19 +02:00
|
|
|
shell="$($SHELL --version | sed -e 's/(.*)//')"
|
2021-03-16 00:17:32 +01:00
|
|
|
wm="$(tail -n 1 "$XDG_CONFIG_HOME/X11/xinitrc" | cut -d ' ' -f 2)"
|
2020-05-15 15:06:43 +02:00
|
|
|
|
2020-05-24 02:20:32 +02:00
|
|
|
# parse the '/proc/meminfo' file splitting on ':' and 'k'.
|
|
|
|
# the format of the file is 'key: 000kB' and an additional
|
|
|
|
# split is used on 'k' to filter out 'kB'.
|
|
|
|
while IFS=':k ' read -r key val _; do
|
|
|
|
case $key in
|
|
|
|
# MemUsed = MemTotal + Shmem - MemFree - Buffers - Cached - SReclaimable
|
|
|
|
MemTotal)
|
|
|
|
mem_used=$((mem_used + val))
|
|
|
|
mem_total=$val
|
|
|
|
;;
|
|
|
|
|
|
|
|
Shmem)
|
|
|
|
mem_used=$((mem_used + val))
|
|
|
|
;;
|
|
|
|
|
|
|
|
MemFree|Buffers|Cached|SReclaimable)
|
|
|
|
mem_used=$((mem_used - val))
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done < /proc/meminfo
|
|
|
|
|
|
|
|
mem_used=$((mem_used / 1024))
|
|
|
|
mem_total=$((mem_total / 1024))
|
2020-05-15 15:06:43 +02:00
|
|
|
|
|
|
|
# set colors
|
|
|
|
if [ -x "$(command -v tput)" ]; then
|
|
|
|
bold="$(tput bold)"
|
|
|
|
black="$(tput setaf 0)"
|
|
|
|
red="$(tput setaf 1)"
|
|
|
|
green="$(tput setaf 2)"
|
2020-05-28 10:52:13 +02:00
|
|
|
orange="$(tput setaf 3)"
|
|
|
|
yellow="$(tput setaf 11)"
|
2020-05-15 15:06:43 +02:00
|
|
|
blue="$(tput setaf 4)"
|
|
|
|
magenta="$(tput setaf 5)"
|
|
|
|
cyan="$(tput setaf 6)"
|
2021-04-13 09:12:28 +02:00
|
|
|
white="$(tput setaf 15)"
|
2020-05-15 15:06:43 +02:00
|
|
|
reset="$(tput sgr0)"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# you can change these
|
2021-09-08 19:10:38 +02:00
|
|
|
lc="${reset}${magenta}" # labels
|
|
|
|
nc="${bold}${magenta}" # user and hostname
|
|
|
|
ic="${reset}${white}" # info
|
|
|
|
a0="${bold}${magenta}" # first arch color
|
|
|
|
a1="${bold}${white}" # second arch color
|
2020-05-15 15:06:43 +02:00
|
|
|
|
|
|
|
cat <<EOF
|
2021-09-08 19:10:38 +02:00
|
|
|
${a0} ${nc}${USER}${ic}@${nc}${host}
|
|
|
|
${a0} _-----_ ${lc}machine: ${ic}${machine}
|
|
|
|
${a0} ( \\ ${lc}os: ${ic}${os}
|
|
|
|
${a0} \\ 0 \\ ${lc}kernel: ${ic}${kernel}
|
|
|
|
${a1} \\ ) ${lc}shell: ${ic}${shell}
|
|
|
|
${a1} / _/ ${lc}wm: ${ic}${wm}
|
|
|
|
${a1} ( _- ${lc}uptime: ${ic}${uptime}
|
2021-09-19 12:38:58 +02:00
|
|
|
${a1} \\____- ${lc}packages: ${ic}${packages} (portage)
|
2021-09-08 19:10:38 +02:00
|
|
|
${lc}memory: ${ic}${mem_used}MiB/${mem_total}MiB
|
2020-05-15 15:06:43 +02:00
|
|
|
|
|
|
|
EOF
|