Added battery script and cleaned up vim plugins and tmux.conf

This commit is contained in:
Logan 2015-04-17 00:38:59 -07:00
parent bab09eead1
commit c153cfaaa3
3 changed files with 121 additions and 4 deletions

116
scripts/battery.sh Executable file
View file

@ -0,0 +1,116 @@
#!/bin/sh
#Created by richo on GitHub
HEART_FULL=
HEART_EMPTY=
[ -z "$NUM_HEARTS" ] &&
NUM_HEARTS=5
cutinate()
{
perc=$1
inc=$(( 100 / $NUM_HEARTS))
for i in `seq $NUM_HEARTS`; do
if [ $perc -lt 100 ]; then
echo $HEART_EMPTY
else
echo $HEART_FULL
fi
perc=$(( $perc + $inc ))
done
}
linux_get_bat ()
{
bf=$(cat $BAT_FULL)
bn=$(cat $BAT_NOW)
echo $(( 100 * $bn / $bf ))
}
freebsd_get_bat ()
{
echo "$(sysctl -n hw.acpi.battery.life)"
}
# Do with grep and awk unless too hard
# TODO Identify which machine we're on from teh script.
battery_status()
{
case $(uname -s) in
"Linux")
BATPATH=/sys/class/power_supply/BAT0
STATUS=$BATPATH/status
BAT_FULL=$BATPATH/energy_full
BAT_NOW=$BATPATH/energy_now
if [ "$1" = `cat $STATUS` -o "$1" = "" ]; then
linux_get_bat
fi
;;
"FreeBSD")
STATUS=`sysctl -n hw.acpi.battery.state`
case $1 in
"Discharging")
if [ $STATUS -eq 1 ]; then
freebsd_get_bat
fi
;;
"Charging")
if [ $STATUS -eq 2 ]; then
freebsd_get_bat
fi
;;
"")
freebsd_get_bat
;;
esac
;;
"Darwin")
case $1 in
"Discharging")
ext="No";;
"Charging")
ext="Yes";;
esac
ioreg -c AppleSmartBattery -w0 | \
grep -o '"[^"]*" = [^ ]*' | \
sed -e 's/= //g' -e 's/"//g' | \
sort | \
while read key value; do
case $key in
"MaxCapacity")
export maxcap=$value;;
"CurrentCapacity")
export curcap=$value;;
"ExternalConnected")
if [ "$ext" != "$value" ]; then
exit
fi
;;
"FullyCharged")
if [ "$value" = "Yes" ]; then
exit
fi
;;
esac
if [[ -n "$maxcap" && -n $curcap ]]; then
echo $(( 100 * $curcap / $maxcap ))
break
fi
done
esac
}
BATTERY_STATUS=`battery_status $1`
[ -z "$BATTERY_STATUS" ] && exit
#if [ -n "$CUTE_BATTERY_INDICATOR" ]; then
echo `cutinate $BATTERY_STATUS`
#else
echo ${BATTERY_STATUS}%
#fi

View file

@ -30,7 +30,7 @@ setw -g window-status-activity-fg "colour150"
setw -g window-status-separator ""
setw -g window-status-bg "colour238"
set -g status-left "#[fg=colour236,bg=colour150] #S #[fg=colour150,bg=colour238,nobold,nounderscore,noitalics]"
set -g status-right "#[fg=colour237,bg=colour238,nobold,nounderscore,noitalics] #[fg=colour249,bg=colour237] #(~/.scripts/tmux_battery_charge_indicator.sh) %m/%e/%y %I:%m %p #[fg=colour150,bg=colour237,nobold,nounderscore,noitalics]#[fg=colour236,bg=colour150] #h "
setw -g window-status-format "#[fg=colour150,bg=colour238] #I #[fg=colour150,bg=colour238] #W "
setw -g window-status-current-format "#[fg=colour238,bg=colour237,nobold,nounderscore,noitalics]#[fg=colour249,bg=colour237] #I #[fg=colour249,bg=colour237] #W #[fg=colour237,bg=colour238,nobold,nounderscore,noitalics]"
set -g status-right "#[fg=colour237,bg=colour238,nobold,nounderscore,noitalics] #[fg=colour249,bg=colour237] #(~/.scripts/battery.sh) %m/%e/%y %I:%m %p #[fg=colour150,bg=colour237,nobold,nounderscore,noitalics]#[fg=colour236,bg=colour150] #h "
setw -g window-status-format "#[fg=colour150,bg=colour238] #I #[fg=colour150,bg=colour238] #W "
setw -g window-status-current-format "#[fg=colour238,bg=colour237,nobold,nounderscore,noitalics]#[fg=colour249,bg=colour237] #I #[fg=colour249,bg=colour237] #W #[fg=colour237,bg=colour238,nobold,nounderscore,noitalics]"
set -g status-utf8 on

3
vimrc
View file

@ -35,7 +35,8 @@ Plugin 'airblade/vim-gitgutter'
Plugin 'scrooloose/nerdtree'
Plugin 'bling/vim-airline'
Plugin 'Townk/vim-autoclose'
Plugin 'kchmck/vim-coffee-script'
Plugin 'godlygeek/tabular'
Plugin 'plasticboy/vim-markdown'
Bundle 'mattn/webapi-vim'
Bundle 'mattn/gist-vim'
Bundle 'vim-ruby/vim-ruby'