dotfiles

*nix config files
git clone git://git.pyratebeard.net/dotfiles.git
Log | Files | Refs | README

syscat (3274B)


      1 #!/bin/sh
      2 # ┐─┐┐ ┬┐─┐┌─┐┬─┐┌┐┐
      3 # └─┐└┌┘└─┐│  │─┤ │ 
      4 # ──┘ ┆ ──┘└─┘┘ ┆ ┆ 
      5 # syscat by pyratebeard (https://git.pyratebeard.net/dotfiles/file/bin/bin/syscat.html)
      6 #  └─ forked from info.sh by z3bra (https://pub.z3bra.org/monochromatic/misc/info.sh)
      7 
      8 gitdir=https://git.pyratebeard.net
      9 myblog=https://log.pyratebeard.net
     10 homepage=https://pyratebeard.net
     11 
     12 c00=$'\e[0;30m'
     13 c01=$'\e[0;31m'
     14 c02=$'\e[0;32m'
     15 c03=$'\e[0;33m'
     16 c04=$'\e[0;34m'
     17 c05=$'\e[0;35m'
     18 c06=$'\e[0;36m'
     19 c07=$'\e[0;37m'
     20 c08=$'\e[1;30m'
     21 c09=$'\e[1;31m'
     22 c10=$'\e[1;32m'
     23 c11=$'\e[1;33m'
     24 c12=$'\e[1;34m'
     25 c13=$'\e[1;35m'
     26 c14=$'\e[1;36m'
     27 c15=$'\e[1;37m'
     28 
     29 f0=$'\e[1;30m'
     30 f1=$'\e[1;37m'
     31 f2=$'\e[0;37m'
     32 
     33 host=$(hostname -s)
     34 up=$(uptime -p | cut -b4- | tr -d ',|eeks|ay|our|inute')
     35 kernel=`uname -r | tr '[:upper:]' '[:lower:]'`
     36 #kernel=`uname -rmo | tr '[:upper:]' '[:lower:]'`
     37 cpuspe="`sed -n '/model\ name/s/^.*:\ //p' /proc/cpuinfo | uniq | rev | cut -d' ' -f 3- | rev | tr '[:upper:]' '[:lower:]'` (x`nproc`)"
     38 cpu=$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage}')
     39 load=`printf "%.0f" $cpu`%
     40 system=`sed 's/\s*[\(\\]\+.*$//' /etc/issue | tr '[:upper:]' '[:lower:]'`
     41 ram=`free | awk '/Mem:/ {print int($3/$2 * 100.0)}'`%
     42 
     43 if [ -n "$DISPLAY" ]; then
     44     wmname=`xprop -root _NET_WM_NAME|cut -d\" -f2`
     45     #termfn=`sed -n 's/^.*\*font:\s* -\*-\([^-]*\)-.*/\1/p' ~/.Xdefaults|sed 1q`
     46 	termfn=$(grep -Ei "^urxvt\*font" ~/.Xdefaults | awk -F: '{print $3}')
     47 	fnsize=$(grep -Ei "^urxvt\*font" ~/.Xdefaults | grep -Eo '[0-9]{1,2}' | head -n1)
     48     #systfn=`sed -n 's/^.*font.*"\(.*\)".*$/\1/p' ~/.gtkrc-2.0`
     49 	termco=$(awk -F/ '/colors/{print $NF}' ~/.Xdefaults | tr -d '"')
     50 	#termco=$(sed -n '/color/s/^.*\///p' ~/.Xdefaults | tr -d '"')
     51 else
     52     wmname="none"
     53     termfn="none"
     54     #systfn="none"
     55 fi
     56 
     57 pkgnum=`pacman -Q|wc -l`
     58 birthd=`sed -n '1s/^\[\([0-9-]*\).*$/\1/p' /var/log/pacman.log | tr - .`
     59 
     60 main() {
     61 cat << EOF
     62 ${c00}▓▒  ${f0}│ ${f1}host ${f0}......... $f2$host
     63 ${c08}  ▒░${f0}│ ${f1}up ${f0}........... $f2$up
     64 ${c01}▓▒  ${f0}│ 
     65 ${c09}  ▒░${f0}│ ${f1}os ${f0}........... $f2$system
     66 ${c02}▓▒  ${f0}│ ${f1}birth ${f0}........ $f2$birthd
     67 ${c10}  ▒░${f0}│ 
     68 ${c03}▓▒  ${f0}│ ${f1}wm ${f0}........... $f2$wmname
     69 ${c11}  ▒░${f0}│ ${f1}shell ${f0}........ $f2$SHELL
     70 ${c04}▓▒  ${f0}│ ${f1}term ${f0}......... $f2$TERM
     71 ${c12}  ▒░${f0}│ ${f1}font ${f0}......... $f2$termfn $fnsize
     72 ${c05}▓▒  ${f0}│ ${f1}colors ${f0}....... $f2$termco
     73 ${c13}  ▒░${f0}│ 
     74 ${c06}▓▒  ${f0}│ ${f1}kernel ${f0}....... $f2$kernel
     75 ${c14}  ▒░${f0}│ ${f1}processor ${f0}.... $f2$cpuspe
     76 ${c07}▓▒  ${f0}│ ${f1}memory ${f0}....... $f2$ram
     77 ${c15}  ▒░${f0}│ ${f1}homepage ${f0}..... $f2$homepage
     78 EOF
     79 }
     80 
     81 mini() {
     82 cat << EOF
     83 ${f1}host ${f0}...... $f2$host
     84 ${f1}sys ${f0}....... $f2$system
     85 ${f1}wm ${f0}........ $f2$wmname
     86 ${f1}shell ${f0}..... $f2$SHELL
     87 ${f1}term ${f0}...... $f2$TERM
     88 ${f1}font ${f0}...... $f2$termfn $fnsize
     89 ${f1}colours ${f0}... $f2$termco
     90 ${f1}kernel ${f0}.... $f2$kernel
     91 ${f1}load ${f0}...... $f2$load
     92 EOF
     93 }
     94 
     95 
     96 if [ $# -eq 0 ] ; then
     97 	mini
     98 else
     99 	opt="$1"
    100 	case ${opt} in
    101 		mini) mini ;;
    102 		main) main ;;
    103 		*) mini ;;
    104 	esac
    105 fi