Mes dotfiles, qui regroupent tout ce dont j'ai besoin pour utiliser ma machine, à savoir mes fichiers de config et mes scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dotfiles/.local/bin/fetch

82 lines
2.4 KiB

#!/usr/bin/env sh
######################################################################
# @author : swytch (adapated from github.com/jschx/ufetch)
# @file : fetch
# @license : GPLv3
# @created : Wednesday May 20, 2020 18:16:09 CEST
#
# @description : display system infos
######################################################################
## INFO
# $USER is already defined
host="$(cat /etc/conf.d/hostname | awk -F'"' '{ printf $2 }')"
machine="$(cat /sys/devices/virtual/dmi/id/product_version)"
os='Gentoo'
kernel="$(uname -sr)"
uptime="$(uptime -p | sed 's/up //')"
packages="$(printf '%s\n' /var/db/pkg/*/* | wc -l)"
shell="$($SHELL --version | sed -e 's/(.*)//')"
wm="$(tail -n 1 "$XDG_CONFIG_HOME/X11/xinitrc" | rev | cut -d ' ' -f 1 | rev)"
# 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))
# set colors
if [ -x "$(command -v tput)" ]; then
bold="$(tput bold)"
black="$(tput setaf 0)"
red="$(tput setaf 1)"
green="$(tput setaf 2)"
orange="$(tput setaf 3)"
yellow="$(tput setaf 11)"
blue="$(tput setaf 4)"
magenta="$(tput setaf 5)"
cyan="$(tput setaf 6)"
white="$(tput setaf 15)"
reset="$(tput sgr0)"
fi
# you can change these
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
cat <<EOF
${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}
${a1} \\____- ${lc}packages: ${ic}${packages} (portage)
${lc}memory: ${ic}${mem_used}MiB/${mem_total}MiB
EOF