Changed the asciiart a bit

I moved the "fetch" asciiart to the script folder, as I did not like it showing up when the terminal started because it was big and would be broken when displayed in a small terminal window
This commit is contained in:
lkarch
2024-04-07 12:40:41 -04:00
parent 640bac40fe
commit 02c0e3e5a7

147
misc/bin/lkfetch Executable file
View File

@@ -0,0 +1,147 @@
#!/usr/bin/env bash
# I don't remember if I made this script or not.
#colors
#bold="(tput bold)"
magenta="\033[1;35m"
green="\033[1;32m"
white="\033[1;37m"
blue="\033[1;34m"
red="\033[1;31m"
black="\033[1;40;30m"
yellow="\033[1;33m"
cyan="\033[1;36m"
reset="\033[0m"
bgyellow="\033[1;43;33m"
bgwhite="\033[1;47;37m"
c0=${reset}
c1=${magenta}
c2=${green}
c3=${white}
c4=${blue}
c5=${red}
c6=${yellow}
c7=${cyan}
c8=${black}
c9=${bgyellow}
c10=${bgwhite}
# Get the kernel
# This will decide the further actionsvand command usages as bsd and gnu tools even with same name are DIFFERENT.
kernel=$(uname -o)
# Get the init
get_init() {
if pidof -q systemd; then
echo 'systemd'
elif [ -f '/sbin/openrc' ]; then
echo 'openrc'
elif [ -f '/sbin/dinit' ]; then
echo 'dinit'
else
cut -d ' ' -f 1 /proc/1/comm
fi
}
# Get count of packages installed
get_pkg_count() {
package_managers=('xbps-install' 'apk' 'port' 'apt' 'pacman' 'nix' 'dnf' 'rpm' 'emerge' 'eopkg')
for package_manager in "${package_managers[@]}"; do
if command -v "$package_manager" 2>/dev/null >&2; then
case "$package_manager" in
xbps-install) xbps-query -l | wc -l ;;
apk) apk search | wc -l ;;
apt) if [ "$kernel" != "Darwin" ]; then
echo $(($(apt list --installed 2>/dev/null | wc -l) - 1))
else
echo 0
fi
;;
pacman) pacman -Q | wc -l ;;
nix) nix-env -qa --installed '*' | wc -l ;;
dnf) dnf list installed | wc -l ;;
rpm) rpm -qa | wc -l ;;
emerge) qlist -I | wc -l ;;
port) port installed 2>/dev/null | wc -l | awk 'NR==1{print $1}' ;;
eopkg) eopkg li | wc -l ;;
esac
# if a package manager is found return from the function
return
fi
done
echo 0
}
# Get package information formatted
get_package_info() {
pkg_count=$(get_pkg_count)
if [ "$pkg_count" -ne 0 ]; then
echo -n "$pkg_count"
else
echo "Unknown"
fi
}
# Get distro name
distro() {
awk -F '"' '/PRETTY_NAME/ { print $2 }' /etc/os-release
}
# Get root partition space used
storage() {
df -h --output=used,size / | awk 'NR == 2 { print $1" / "$2 }'
}
# Get Memory usage
mem() {
free --mega | awk 'NR == 2 { print $3" / "$2" MB" }'
}
# Get uptime
get_uptime() {
uptime -p | sed 's/up//'
}
# Get DE/WM
# Reference: https://github.com/unixporn/robbb/blob/master/fetcher.sh
get_de_wm() {
wm="${XDG_CURRENT_DESKTOP#*:}"
[ "$wm" ] || wm="$DESKTOP_SESSION"
# for most WMs
[ ! "$wm" ] && [ "$DISPLAY" ] && command -v xprop >/dev/null && {
id=$(xprop -root -notype _NET_SUPPORTING_WM_CHECK 2>/dev/null)
id=${id##* }
wm=$(xprop -id "$id" -notype -len 100 -f _NET_WM_NAME 8t 2>/dev/null | grep '^_NET_WM_NAME' | cut -d\" -f 2)
}
# for non-EWMH WMs
[ ! "$wm" ] || [ "$wm" = "LG3D" ] && {
wms=('sway' 'kiwmi' 'wayfire' 'sowm' 'catwm' 'fvwm' 'dwm' '2bwm' 'monsterwm' 'tinywm' 'xmonad')
for current_wm in "${wms[@]}"; do
if pgrep -x "$current_wm" 2>/dev/null >&2; then
wm="${current_wm}";
break
fi
done
}
echo "${wm:-unknown}"
}
echo -e " ┏━━━━━━━━━━━━━━━━━━━━━━┓"
echo -e " ┃ ${c7}f${c4}e${c5}t${c6}${c7}c${c1}h${c0} ${c6}${c0} ${c7}${c0} ${c5}${c0} ┃"
echo -e " ┣━━━━━━━━━━━━━━━━━━━━━━┫ ${c1}━━━${c2}━━━${c3}━━━${c4}━━━${c5}━━━${c6}━━━${c7}━━━"
echo -e " ${c0} ┃ ┃ ${c1}os${c3} $(distro)"
echo -e " ┃ ${c3}•${c8}_${c3}•${c0} ┃ ${c2}ker${c3} $(uname -r)"
echo -e " ┃ ${c8}${c0}${c9}oo${c0}${c8}|${c0} ┃ ${c7}pkgs${c3} $(get_package_info)"
echo -e " ┃ ${c8}/${c0}${c10}${c0}${c8}'\'${c0} ┃ ${c5}sh${c3} ${SHELL##*/} ${c6}󰮯 ${c6}${c2}󰊠 ${c2}${c4}󰊠 ${c4}${c5}󰊠 ${c5}${c7}󰊠 ${c7}"
echo -e " ${c0} ┃ ${c9}(${c0}${c8}\_;/${c0}${c9})${c0} ┃ ${c1}ram${c3} $(mem)"
echo -e " ┃ ${c0}┃ ${c2}init${c3} $(get_init)"
echo -e " ┃ I ${c1}${c0} Arch ┃ ${c7}de/wm${c3} $(get_de_wm)"
echo -e " ┃ ┃ ${c5}up${c3} $(get_uptime)"
echo -e " ┃ ┃ ${c1}disk${c3} $(storage)"
echo -e " ┗━━━━━━━━━━━━━━━━━━━━━━┛ ${c1}━━━${c2}━━━${c3}━━━${c4}━━━${c5}━━━${c6}━━━${c7}━━━"
echo -e " "