dotfiles

custom dotfiles
git clone git://git.pyratebeard.net/dotfiles.git
Log | Files | Refs | README

sysinfo (3299B)


      1 #!/bin/sh
      2 ## author: pyratebeard <root@pyratebeard.net>
      3 ## original author: xero <x@xero.nu>
      4 #\\ vars
      5 #FULL=▓
      6 #EMPTY=░
      7 #FULL=━
      8 #EMPTY=┄
      9 
     10 #EMPTY=━
     11 EMPTY=─
     12 FULL=┅
     13 
     14 name=$USER
     15 host=$(hostname)
     16 uptime=$(uptime -p | cut -b4- | tr -d ',|eeks|ay|our|inute')
     17 battery=/sys/class/power_supply/BAT1
     18 distro=$(grep -E "^ID=" /etc/os-release | awk -F= '{print $2}')
     19 pkgs=$(pacman -Qqs | wc -l)
     20 #upgrade=$(sudo pacman -Sy >/dev/null ; pacman -Qu | wc -l)
     21 kernel=$(uname -r)
     22 shell=$(echo $SHELL | awk -F/ '{print $NF}')
     23 #term=$TERM
     24 term="urxvt"
     25 colors=$(grep urxvt-colors ~/.Xdefaults | awk -F\/ '{print $NF}' | tr -d '"')
     26 font=$(grep -Ei "^urxvt\*font" ~/.Xdefaults | awk -F: '{print $3}')
     27 font_size=$(grep -Ei "^urxvt\*font" ~/.Xdefaults | grep -Eo '[0-9]{1,2}')
     28 #wm=$XDG_SESSION_DESKTOP
     29 wm='2bwm'
     30 
     31 #\\ progress bar
     32 draw()
     33 {
     34   perc=$1
     35   size=$2
     36   inc=$(( perc * size / 100 ))
     37   out=
     38   if [ -z $3 ]
     39   then
     40     color="36"
     41   else
     42     color="$3"
     43   fi 
     44   for v in `seq 0 $(( size - 1 ))`; do
     45     test "$v" -le "$inc"   \
     46     && out="${out}\e[0;34m${FULL}" \
     47     || out="${out}\e[38;5;236m${EMPTY}"
     48   done
     49   printf $out
     50 }
     51 
     52 #\\ colors
     53 ~/bin/blocks
     54 
     55 
     56 #\\ greets
     57 printf " \e[1;33m    user \e[0;34m┄┬┄ \e[0;33m$name\n"
     58 printf " \e[1;33m    host \e[0;34m┄┼┄ \e[1;35m$host\e[0m\n"
     59 printf " \e[1;33m      up \e[0;34m┄┴┄ \e[1;37m$uptime\n"
     60 printf " \e[0m\n"
     61 
     62 #\\ environment
     63 printf " \e[1;33m  distro \e[0;34m┄┬┄ \e[0m$distro\n"
     64 printf " \e[1;33m  kernel \e[0;34m┄┼┄ \e[0m$kernel\n"
     65 printf " \e[1;33mpackages \e[0;34m┄┼┄ \e[0m$pkgs\n"
     66 #printf " \e[1;35m upgrade \e[38;5;236m▓▒ \e[0m$upgrade\n"
     67 printf " \e[1;33m      wm \e[0;34m┄┼┄ \e[0m$wm\n"
     68 printf " \e[1;33m   shell \e[0;34m┄┼┄ \e[0m$shell\n"
     69 printf " \e[1;33m    term \e[0;34m┄┼┄ \e[0m$term\n"
     70 printf " \e[1;33m    font \e[0;34m┄┼┄ \e[0m$font $font_size\n"
     71 printf " \e[1;33m  colors \e[0;34m┄┴┄ \e[0m$colors\n"
     72 printf " \e[0m\n"
     73 
     74 #\\ cpu
     75 cpu=$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage}')
     76 c_lvl=`printf "%.0f" $cpu`
     77 printf " \e[1;35m%-4s \e[1;37m%-5s %-25s \n" " cpu" "$c_lvl%" " "`draw $c_lvl 15` 
     78 
     79 #\\ ram
     80 ram=`free | awk '/Mem:/ {print int($3/$2 * 100.0)}'`
     81 printf " \e[1;35m%-4s \e[1;37m%-5s %-25s \n" " ram" "$ram%" " "`draw $ram 15` 
     82 
     83 #\\ battery
     84 if [ -f $battery/charge_full ] ; then
     85   b_full=$battery/charge_full
     86   b_now=$battery/charge_now
     87   bf=`cat $b_full`
     88   bn=`cat $b_now`
     89   charge=`printf $(( 100 * $bn / $bf ))`
     90 
     91   case 1 in
     92     $(($charge <= 15)))
     93       color='31'
     94       ;;
     95     *)
     96       color='34'
     97       ;;
     98   esac
     99   printf "  \e[0;${color}m%-4s \e[1;${color}m%-5s %-25s \n" " bat" "$charge%" `draw $charge 15 $color`
    100 fi
    101 
    102 #\\ volume
    103 vol=`amixer get Master | awk '$0~/%/{print $5}' | head -n1 | tr -d '[]%'`
    104 if amixer get Master | grep -q '\[off\]' 
    105 then
    106   color='31'
    107 else
    108   color='34'
    109 fi
    110 printf " \e[1;35m%-4s \e[1;37m%-5s %-25s \n" " vol" "$vol%" " "`draw $vol 15 $color` 
    111 
    112 #\\ temperature
    113 #temp=`sensors | awk '/Core\ 0/ {gsub(/\+/,"",$3); gsub(/\..+/,"",$3)    ; print $3}'`
    114 #case 1 in
    115 #  $(($temp <= 50)))
    116 #    color='34'
    117 #    ;;
    118 #  $(($temp >= 75)))
    119 #    color='31'
    120 #    ;;
    121 #  *)
    122 #    color='36'
    123 #    ;;
    124 #esac
    125 #printf "   \e[0;${color}m%-4s \e[1;${color}m%-5s %-25s \n\n" "temp" "$temp°c " `draw $temp 15 $color`
    126 printf " \e[0m\n"