diff options
author | Joshua Ismael Haase Hernández <hahj87@gmail.com> | 2011-06-26 15:13:41 -0500 |
---|---|---|
committer | Joshua Ismael Haase Hernández <hahj87@gmail.com> | 2011-06-26 15:13:41 -0500 |
commit | d26fb8dc20ba3b0e6ef535761b3ac5fd8e7b7c70 (patch) | |
tree | ae84713aa59e8e2eaa4a2a19db89294ea0b4c1cf /community/scrotwm/baraction.sh | |
parent | 2095d71af1b9e0c1dff405c178a9481d1020ca3e (diff) | |
parent | 8999fa1750304fb2367fb7743e49e013405e88be (diff) |
Merge branch 'master' of vparabola:~/abslibre-pre-mips64el
Conflicts:
community/distcc/PKGBUILD
community/lxtask/PKGBUILD
community/ushare/PKGBUILD
extra/catdoc/PKGBUILD
extra/curl/PKGBUILD
extra/ethstatus/PKGBUILD
extra/ffcall/PKGBUILD
extra/gimp-dbp/PKGBUILD
extra/gimp-refocus/PKGBUILD
extra/gstreamer0.10-ugly/PKGBUILD
extra/metacity/PKGBUILD
extra/pulseaudio/PKGBUILD
extra/x2x/PKGBUILD
libre/kernel26-libre/PKGBUILD
multilib/lib32-libpulse/PKGBUILD
multilib/wine/PKGBUILD
testing/alex/PKGBUILD
testing/ghc/PKGBUILD
testing/haskell-cgi/PKGBUILD
testing/haskell-deepseq/PKGBUILD
testing/haskell-fgl/PKGBUILD
testing/haskell-glut/PKGBUILD
testing/haskell-haskell-src/PKGBUILD
testing/haskell-html/PKGBUILD
testing/haskell-http/PKGBUILD
testing/haskell-hunit/PKGBUILD
testing/haskell-mtl/PKGBUILD
testing/haskell-network/PKGBUILD
testing/haskell-opengl/PKGBUILD
testing/haskell-parallel/PKGBUILD
testing/haskell-parsec/PKGBUILD
testing/haskell-platform/PKGBUILD
testing/haskell-quickcheck/PKGBUILD
testing/haskell-regex-base/PKGBUILD
testing/haskell-regex-compat/PKGBUILD
testing/haskell-regex-posix/PKGBUILD
testing/haskell-stm/PKGBUILD
testing/haskell-syb/PKGBUILD
testing/haskell-text/PKGBUILD
testing/haskell-transformers/PKGBUILD
testing/haskell-xhtml/PKGBUILD
testing/haskell-zlib/PKGBUILD
testing/perl/ChangeLog
testing/perl/PKGBUILD
testing/perl/perlbin.sh
testing/pidgin/PKGBUILD
testing/spamassassin/PKGBUILD
Diffstat (limited to 'community/scrotwm/baraction.sh')
-rwxr-xr-x | community/scrotwm/baraction.sh | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/community/scrotwm/baraction.sh b/community/scrotwm/baraction.sh new file mode 100755 index 000000000..9c4600adc --- /dev/null +++ b/community/scrotwm/baraction.sh @@ -0,0 +1,82 @@ +#!/bin/bash +# baraction.sh for scrotwm status bar +# From http://wiki.archlinux.org/index.php/Scrotwm + +SLEEP_SEC=5 +#loops forever outputting a line every SLEEP_SEC secs +while :; do + + eval $(cat /proc/acpi/battery/BAT0/state | awk '/charging state/ {printf "BAT_CHGSTATE=%s;", $3}; /remaining capacity/ {printf "BAT_REMNG=%s;",$3}; /present rate/ {printf "BAT_RATE=%s;",$3};' -) + eval $(cat /proc/acpi/battery/BAT0/info | awk '/present/ {printf "BAT_PRESENT=%s;", $2}; /last full capacity/ {printf "BAT_LASTFULL=%s;",$4};' -) + + BAT_REMNG_WH=`echo "scale=1; a=($BAT_REMNG+50)/1000; print a" | bc -l` + BAT_RATE_W=`echo "scale=1; a=($BAT_RATE+50)/1000; print a" | bc -l` + BCSCRIPT="scale=0; a=(100*$BAT_REMNG / $BAT_LASTFULL); print a" + BAT_PCT=`echo $BCSCRIPT | bc -l`% + + case $BAT_PRESENT in + no) + POWER_STR="AC, NO BATTERY" + ;; + yes) + + case $BAT_CHGSTATE in + charged) + #on ac + AC_STATUS="ON AC" + TIME_REMNG="N/A" + POWER_STR="$AC_STATUS $BAT_CHGSTATE $BAT_PCT" + ;; + charging) + #on ac + AC_STATUS="ON AC" + BCSCRIPT="scale=1; a=(60*($BAT_LASTFULL - $BAT_REMNG) / $BAT_RATE); print a" + TIMETOFULL_MIN=`echo $BCSCRIPT | bc -l` + POWER_STR="$AC_STATUS $BAT_CHGSTATE $BAT_PCT C="$BAT_REMNG_WH"Wh Rate="$BAT_RATE_W"W TTF="$TIMETOFULL_MIN"min" + ;; + discharging) + AC_STATUS="ON BATT" + TIME_REMNG_MIN=`echo "scale=0; a=(60*$BAT_REMNG / $BAT_RATE); print a" | bc -l` + TIME_REMNG_HH=`echo "scale=0; a=($BAT_REMNG / $BAT_RATE); if (a<10) {print "0"; print a} else {print a}" | bc -l` + + TIME_REMNG_MM=`echo "scale=0; a=($TIME_REMNG_MIN-60*$TIME_REMNG_HH); if (a<10) {print "0"; print a} else {print a}" | bc -l` + POWER_STR="$AC_STATUS $BAT_PCT C="$BAT_REMNG_WH"Wh P="$BAT_RATE_W"W R="$TIME_REMNG_HH":"$TIME_REMNG_MM + ;; + *) + POWER_STR=$BAT_CHGSTATE + ;; + esac + + ;; + *) + POWER_STR="error" + ;; + esac + + #scrotwm bar_print can't handle UTF-8 characters, such as degree symbol + #Core 0: +67.0°C (crit = +100.0°C) + eval $(sensors 2>/dev/null | sed s/[°+]//g | awk '/^Core 0/ {printf "CORE0TEMP=%s;", $3}; /^Core 1/ {printf "CORE1TEMP=%s;",$3}; /^fan1/ {printf "FANSPD=%s;",$2};' -) + TEMP_STR="Tcpu=$CORE0TEMP,$CORE1TEMP F=$FANSPD" + + WLAN_ESSID=$(iwconfig wlan0 | awk -F "\"" '/wlan0/ { print $2 }') + eval $(cat /proc/net/wireless | sed s/[.]//g | awk '/wlan0/ {printf "WLAN_QULTY=%s; WLAN_SIGNL=%s; WLAN_NOISE=%s", $3,$4,$5};' -) + BCSCRIPT="scale=0;a=100*$WLAN_QULTY/70;print a" + WLAN_QPCT=`echo $BCSCRIPT | bc -l` + WLAN_POWER=`iwconfig 2>/dev/null| grep "Tx-Power"| awk {'print $4'}|sed s/Tx-Power=//` + WLAN_STR="$WLAN_ESSID: Q=$WLAN_QPCT% S/N="$WLAN_SIGNL"/"$WLAN_NOISE"dBm T="$WLAN_POWER"dBm" + + CPUFREQ_STR=`echo "Freq:"$(cat /proc/cpuinfo | grep 'cpu MHz' | sed 's/.*: //g; s/\..*//g;')` + CPULOAD_STR="Load:$(uptime | sed 's/.*://; s/,//g')" + + eval $(awk '/^MemTotal/ {printf "MTOT=%s;", $2}; /^MemFree/ {printf "MFREE=%s;",$2}' /proc/meminfo) + MUSED=$(( $MTOT - $MFREE )) + MUSEDPT=$(( ($MUSED * 100) / $MTOT )) + MEM_STR="Mem:${MUSEDPT}%" + + echo -e "$POWER_STR $TEMP_STR $CPUFREQ_STR $CPULOAD_STR $MEM_STR $WLAN_STR" + #alternatively if you prefer a different date format + #DATE_STR=`date +"%H:%M %a %d %b` + #echo -e "$DATE_STR $POWER_STR $TEMP_STR $CPUFREQ_STR $CPULOAD_STR $MEM_STR $WLAN_STR" + + sleep $SLEEP_SEC +done |