|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# 'Lil Fetch
|
|
|
|
# A tiny little fetch tool
|
|
|
|
# By Kat Hamer
|
|
|
|
|
|
|
|
# Get RAM used
|
|
|
|
ram_used() {
|
|
|
|
awk '/^Mem/ {print $3}' <(free -m)
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get total RAM
|
|
|
|
ram_total() {
|
|
|
|
awk '/^Mem/ {print $2}' <(free -m)
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get WM name (Requires wmctrl to be installed!)
|
|
|
|
wm_name() {
|
|
|
|
if [ -x "$(command -v wmctrl)" ]
|
|
|
|
then
|
|
|
|
awk '/Name:/ {print $2}' <(wmctrl -m)
|
|
|
|
else
|
|
|
|
echo "Unknown (Is wmctrl installed?)"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Store OS info (DOES NOT WORK ON ALL SYSTEMS!)
|
|
|
|
os_info() {
|
|
|
|
source /etc/os-release
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get shell version
|
|
|
|
shell_version() {
|
|
|
|
case $(basename "$SHELL") in
|
|
|
|
"bash")
|
|
|
|
echo "Bash $BASH_VERSION"
|
|
|
|
;;
|
|
|
|
"zsh")
|
|
|
|
zsh --version
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "$SHELL"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get uptime
|
|
|
|
uptime() {
|
|
|
|
uptime | gawk '{ printf $1 }'
|
|
|
|
}
|
|
|
|
|
|
|
|
display_bar() {
|
|
|
|
echo -e "\e[41m \e[42m \e[43m \e[44m \e[45m \e[46m \e[47m \e[0m"
|
|
|
|
}
|
|
|
|
|
|
|
|
output_color() {
|
|
|
|
os_info
|
|
|
|
accent_ansi="\e[0;36m"
|
|
|
|
reset_ansi="\e[0m"
|
|
|
|
|
|
|
|
echo -e "$accent_ansi$(whoami)$reset_ansi@$accent_ansi$(hostname)$reset_ansi in $accent_ansi$(pwd)$reset_ansi"
|
|
|
|
echo -e "OS: $accent_ansi$NAME$reset_ansi"
|
|
|
|
echo -e "RAM: $accent_ansi$(ram_used) MB$reset_ansi/$accent_ansi$(ram_total)$reset_ansi MB"
|
|
|
|
echo -e "Shell: $accent_ansi$(shell_version)$reset_ansi"
|
|
|
|
echo -e "WM: $accent_ansi$(wm_name)$reset_ansi"
|
|
|
|
echo
|
|
|
|
display_bar
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
output_plain() {
|
|
|
|
os_info
|
|
|
|
|
|
|
|
echo -e "$(whoami)@$(hostname) in $(pwd)$"
|
|
|
|
echo -e "OS: $NAME"
|
|
|
|
echo -e "RAM: $(ram_used) MB/$(ram_total) MB"
|
|
|
|
echo -e "Shell: $(shell_version)"
|
|
|
|
echo -e "WM: $(wm_name)"
|
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
|
|
|
output_color
|
|
|
|
}
|
|
|
|
|
|
|
|
# Call main function
|
|
|
|
export LANG=c # Force locale
|
|
|
|
main
|
|
|
|
|