Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- # extremely simple system info script.
- # originally written by Nathaniel Maia, 2017-2018. Destroyed by Matthew Dobson, March 2020.
- # fallback
- FB="unknown"
- # colours
- RESET=$'\e[0m'
- for n in {0..7}; do
- printf -v FG${n} "%b" "\e[3${n}m"
- printf -v BG${n} "%b" "\e[4${n}m"
- done
- # source whichever distro release file is available
- if [[ -e /etc/os-release ]] && . /etc/os-release 2>/dev/null; then
- DIST="${ID,,}"
- elif [[ -e /etc/lsb-release ]] && . /etc/lsb-release 2>/dev/null; then
- DIST="${DISTRIB_ID,,}"
- fi
- # system uptime
- UPT="$(uptime -p)"
- UPT="${UPT/up /}"
- UPT="${UPT/ day?/d}"
- UPT="${UPT/ hour?/h}"
- UPT="${UPT/ minute?/m}"
- # check if root user
- (( UID == 0 )) && USR="${FG1}root" || USR="${FG4}${USER}"
- # install date
- if [[ -e /var/log/pacman.log ]]; then
- INST="$(head -n1 /var/log/pacman.log)"
- INST="${INST/ */}"
- INST="${INST/\[/}"
- INST="${INST//\-/ }"
- fi
- # gtk settings
- if [[ -e ~/.config/gtk-3.0/settings.ini ]]; then
- THEME="$(awk -F'=' '/gtk-theme-name/ {print $2}' ~/.config/gtk-3.0/settings.ini)"
- ICONS="$(awk -F'=' '/gtk-icon-theme-name/ {print $2}' ~/.config/gtk-3.0/settings.ini)"
- elif [[ -e ~/.gtkrc-2.0 ]]; then
- THEME="$(awk -F'"' '/gtk-theme-name/ {print $2}' ~/.gtkrc-2.0)"
- ICONS="$(awk -F'"' '/gtk-icon-theme-name/ {print $2}' ~/.gtkrc-2.0)"
- fi
- # login shell
- SHLL="${SHELL##*/}"
- # terminal name
- TRM="${TERM/-256color/}" # many terminals use a -256color suffix, remove it
- TRM="${TRM/-unicode/}" # rxvt can be rxvt-unicode, remove the -unicode suffix
- TRM="${TRM/*-termite*/termite}" # termite is xterm-termite, truncate to just termite
- # hostname
- HOST="${HOST:-$(cat /etc/hostname 2>/dev/null)}"
- HOST="${HOST:-$FB}"
- # fortune
- #fortune -a /home/dobbie/.oh-my-zsh/plugins/chucknorris/fortunes/chucknorris
- # kernel version
- KERN="${KERN:-$(uname -sr)}"
- KERN="${KERN/-*/}"
- KERN="${KERN,,}"
- # MEM = used / total
- FREE="$(free --mega)"
- MB=$(awk 'NR==2 {print $3}' <<< "$FREE")
- GB=$(awk 'NR==2 {printf "%.2f", $3 / 1000}' <<< "$FREE")
- TOT=$(awk 'NR==2 {printf "%.2f", $2 / 1000}' <<< "$FREE")
- if (( MB > 1000 )); then # show in GB
- MEM="${GB:0:5}gb / ${TOT/\.*}gb"
- else # show in MB
- MEM="${MB}mb / ${TOT/\.*}gb"
- fi
- # CPU threads and cores
- THREADS=$(grep -c '^processor' /proc/cpuinfo)
- THREADS=${THREADS:-1}
- CORES=$(grep '^core' /proc/cpuinfo | sort | uniq | wc -l)
- CORES=${CORES:-1}
- # CPU usage needs to be divided by number of threads to get an average percentage
- USAGE=$(ps aux | awk -v i="$THREADS" 'BEGIN{sum = 0} {sum += $3} END{printf "%.2f", sum / i}')
- CPU="${CORES}c/${THREADS}t @ $USAGE% avg"
- rep_char() {
- local char="${1:-=}"
- local num="${2:-$((${#USR} + 3 + ${#HOST}))}"
- local str="$(printf "%${num}s")"
- echo "${str// /$char}"
- }
- pkg_count() {
- pacman -Qq 2>/dev/null | wc -l || echo "$FB"
- }
- cur_wm() {
- if [[ -z $WM && $DISPLAY ]] && hash xprop >/dev/null 2>&1; then
- ID="$(xprop -root -notype _NET_SUPPORTING_WM_CHECK)"
- WM="$(xprop -id "${ID##* }" -notype -len 100 -f _NET_WM_NAME 8t)"
- WM="${WM/*WM_NAME = }" WM="${WM/\"}" WM="${WM/\"*}" WM="${WM,,}"
- echo "${WM:-$FB}"
- else
- echo "${WM:-tty$XDG_VTNR}"
- fi
- }
- # Get the init
- get_init() {
- os=$(uname -o)
- if [ "$os" = "Android" ]; then
- echo 'init.rc'
- elif pidof -q systemd; then
- echo 'systemd'
- elif [ -f '/sbin/openrc' ]; then
- echo 'openrc'
- else
- cut -d ' ' -f 1 /proc/1/comm
- fi
- }
- updates=$(checkupdates | wc -l)
- BLOCKS="$BG1 $BG2 $BG3 $BG4 $BG5 $BG6 $BG7 ${RESET}"
- red="\e[31m"
- grn="\e[32m"
- ylw="\e[33m"
- cyn="\e[36m"
- blu="\e[34m"
- prp="\e[35m"
- bprp="\e[35;1m"
- reset="\033[0m"
- c0=${reset}
- c1=${magenta}
- c2=${green}
- c3=${white}
- c4=${blue}
- c5=${red}
- c6=${yellow}
- c7=${cyan}
- c8=${black}
- c9=${bgyellow}
- c10=${bgwhite}
- echo
- echo
- echo -e " \e[H\e[2J "
- echo -e " \e[0;31m."
- echo -e " \e[0;31m/ \ "
- echo -e " \e[0;31m/ \ \e[0;34m # \e[0;32m| * "
- echo -e " \e[0;31m/^. \ \e[0;34maa##e #%@ a#@e 6##% \e[0;32m| | |-^-. | | \ / "
- echo -e " \e[0;31m/ .-. \ \e[0;34m.oOo# # # # # \e[0;32m| | | | | | X "
- echo -e " \e[0;31m/ ( ) _\ \e[0;34m%OoO# # %#ee # # \e[0;32m| | | | ^._.| / \ "
- echo -e " \e[1;31m/ _.~ ~._^\ "
- echo -e "\e[1;31m/.^ ^.\ "
- echo
- #echo " $BLOCKS"
- #echo -e "${cyn} user ${reset}" " ${USR}${red} ${grn}${HOST}"
- #echo -e "${grn} distro ${reset}" " ${DIST:-$FB}"
- #echo -e "${red} shell ${reset}" " ${SHLL:-$FB}"
- #echo -e "${prp} wm ${reset}" " $(cur_wm)"
- #echo -e "${blu} term ${reset}" " ${TRM:-$FB}"
- #echo -e "${ylw} uptime ${reset}" " ${UPT:-$FB}"
- #echo -e "${cyn} kernel ${reset}" " ${KERN:-$FB}"
- #echo -e "${grn} pkgs ${reset}" " $(pkg_count)"
- #echo -e "${red} init ${reset}" " $(get_init)"
- #echo -e "${prp} cpu ${reset}" " $(grep "model name" /proc/cpuinfo | head -n 1 | awk -F ': ' '{print $2}')"
- #echo -e "${blu} gpu ${reset}" " $(lspci | grep -i vga | sed 's/.*\[\([^]]*\)\].*/\1/')"
- #echo -e "${ylw} birth ${reset}" "$(sed -n '1s/^\[\([0-9-]*\).*$/\1/p' /var/log/pacman.log | tr - .)"
- #echo -e "${cyn} update ${reset}" "\e[0m$updates"
- #echo -e "${grn} music ${reset}" "$(mpc current)"
- #echo
- #echo "$BLOCKS"
- #echo
- #echo
- echo " $BLOCKS"
- echo
- echo -e "${cyn} user ${reset}" " ${USR}${red} ${grn}${HOST}"
- echo -e "${grn} distro ${reset}" " ${DIST:-$FB}"
- echo -e "${red} shell ${reset}" " ${SHLL:-$FB}"
- echo -e "${prp} wm ${reset}" " $(cur_wm)"
- echo -e "${blu} term ${reset}" " ${TRM:-$FB}"
- echo -e "${ylw} uptime ${reset}" " ${UPT:-$FB}"
- echo -e "${cyn} kernel ${reset}" " ${KERN:-$FB}"
- echo -e "${grn} pkgs ${reset}" " $(pkg_count)"
- echo -e "${red} init ${reset}" " $(get_init)"
- echo -e "${prp} cpu ${reset}" " $(grep "model name" /proc/cpuinfo | head -n 1 | awk -F ': ' '{print $2}')"
- echo -e "${blu} gpu ${reset}" " $(lspci | grep -i vga | sed 's/.*\[\([^]]*\)\].*/\1/')"
- echo -e "${ylw} birth ${reset}" "$(sed -n '1s/^\[\([0-9-]*\).*$/\1/p' /var/log/pacman.log | tr - .)"
- echo -e "${cyn} update ${reset}" "\e[0m$updates"
- echo -e "${grn} music ${reset}" "$(mpc current)"
- echo
- echo " $BLOCKS"
- echo
- #echo
- #echo -e " ${cyn}ram ${rst}" " ${MEM:-$FB}"
- #echo -e " ${grn}cpu ${rst}" " ${CPU:-$FB}"
- #echo
- #echo " $BLOCKS"
- #echo
- ##echo -e " $(fortune -a /home/dobbie/.oh-my-zsh/plugins/chucknorris/fortunes/chucknorris)"
- #echo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement