This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/.local/bin/fetch
David JULIEN 9d06a61780 legal: change license to GPLv3 in script headers
Kept wondering wether I should keep the MIT (because I highly value
freedom of act) or embrace the GPL (because I don't want this work to
become close-source).

I do understand that this commit (and the next one that is actually
changing the LICENSE) is a defeat for freedom. I guess freedom has been
defeated long time ago, when people and companies figured that was
"free" (as in gratis) was also "free" (as in disposable).

This is not how I think free (as in "libre") works but hey, that surely
is how Intel and other corporations see it (ec: Intel Management Engine
is entirely based on Minix, is close-source, and *maybe* used as a
backdoor by anybody).

It boils down to the Paradox of Tolerance, and I surely won't tolerate
shit going their way. If you want to take open source stuff, be my
guest ; but you have to play by the rules.
2021-02-16 01:09:56 +01:00

81 lines
2.2 KiB
Bash
Executable File

#!/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/hostname)"
os='Arch Linux'
kernel="$(uname -sr)"
uptime="$(uptime -p | sed 's/up //')"
packages="$(pacman -Q | wc -l)"
shell="$(basename "$SHELL")"
wm="$(tail -n 1 "${HOME}/.xinitrc" | cut -d ' ' -f 2)"
# 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 7)"
reset="$(tput sgr0)"
fi
# you can change these
lc="${bold}${green}" # labels
nc="${bold}${red}" # user and hostname
ic="${reset}${yellow}" # info
a0="${reset}${blue}" # first arch color
a1="${reset}${cyan}" # second arch color
cat <<EOF
${a0} ${nc}${USER}${ic}@${nc}${host}
${a0} /\\ ${lc}OS: ${ic}${os}
${a0} / \\ ${lc}KERNEL: ${ic}${kernel}
${a0} /\\ \\ ${lc}SHELL: ${ic}${shell}
${a1} / \\ ${lc}WM: ${ic}${wm}
${a1} / ,, \\ ${lc}UPTIME: ${ic}${uptime}
${a1} / | | -\\ ${lc}PACKAGES: ${ic}${packages}
${a1} /_-'' ''-_\\ ${lc}MEMORY: ${ic}${mem_used}MiB/${mem_total}MiB
EOF