From 720db6ec0823409df1fbd30e8027b39a9a2a4268 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Sat, 15 Feb 2014 18:39:11 +0100 Subject: [PATCH] added laptop battery status --- .tmux.conf | 53 +++++++++++++++++++++++++++++++++++++++++++++++- .tmux.conf.local | 9 ++++++++ README.md | 1 + 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 .tmux.conf.local diff --git a/.tmux.conf b/.tmux.conf index 5185343..d4f063f 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -217,7 +217,7 @@ run 'for name in $(printenv | grep -Eo ^tmux_conf_[^=]+); do tmux setenv -gu $na # whoami_bg=colour160 # red # host_fg=colour16 # black # host_bg=colour254 # white -# status_right="#[fg=$time_date_fg,nobold]$right_separator %R $right_separator %d %b #[fg=$whoami_bg,bg=$time_date_bg,nobold]$right_separator_black#[fg=$whoami_fg,bg=$whoami_bg,nobold] #(whoami) $right_separator_black#[fg=$host_fg,bg=$host_bg,bold] #h " +# status_right="${tmux_conf_battery:-#(cut -c3- ~/.tmux.conf | sh -s battery ${tmux_conf_battery_symbol:-block} ${tmux_conf_battery_symbol_count:-auto})} #[fg=$time_date_fg,nobold]$right_separator %R $right_separator %d %b #[fg=$whoami_bg,bg=$time_date_bg,nobold]$right_separator_black#[fg=$whoami_fg,bg=$whoami_bg,nobold] #(whoami) $right_separator_black#[fg=$host_fg,bg=$host_bg,bold] #h " # tmux set -g status-right-length 64 \; set -g status-right "$status_right" # # # clock @@ -278,4 +278,55 @@ run 'for name in $(printenv | grep -Eo ^tmux_conf_[^=]+); do tmux setenv -gu $na # display "mouse: $new" # } # +# battery() { +# battery_symbol=$1 +# battery_symbol_count=$2 +# if [ $battery_symbol_count = auto ]; then +# columns=$(tmux display -p '#{client_width}' || echo 80) +# if [ $columns -ge 80 ]; then +# battery_symbol_count=10 +# else +# battery_symbol_count=5 +# fi +# fi +# battery_full_fg=colour160 +# battery_full_bg=colour16 +# battery_empty_fg=colour254 +# battery_empty_bg=colour16 +# +# battery_symbol_heart_full=♥ +# battery_symbol_heart_empty=♥ +# battery_symbol_block_full=◼ +# battery_symbol_block_empty=◻ +# eval battery_symbol_full='$battery_symbol_'"$battery_symbol"'_full' +# eval battery_symbol_empty='$battery_symbol_'"$battery_symbol"'_empty' +# +# uname_s=$(uname -s) +# if [ $uname_s = Darwin ]; then +# batt=$(pmset -g batt) +# percentage=$(echo $batt |egrep -o [0-9]+%) || return +# charge="${percentage%%%} / 100" +# elif [ $uname_s = Linux ]; then +# batpath=/sys/class/power_supply/BAT0 +# if [ ! -d $batpath ]; then +# batpath=/sys/class/power_supply/BAT1 +# fi +# batfull=$batpath/energy_full +# batnow=$batpath/energy_now +# if [ ! -r $batfull -o ! -r $batnow ]; then +# return +# fi +# charge="$(cat $batnow) / $(cat $batfull)" || return +# fi +# +# full=$(printf %.0f $(echo "$charge * $battery_symbol_count" | bc -l)) +# [ $full -gt 0 ] && \ +# printf '#[fg=%s,bg=%s]' $battery_full_fg $battery_full_bg && \ +# printf "%0.s$battery_symbol_full" $(seq 1 $full) +# empty=$(($battery_symbol_count - $full)) +# [ $empty -gt 0 ] && \ +# printf '#[fg=%s,bg=%s]' $battery_empty_fg $battery_empty_bg && \ +# printf "%0.s$battery_symbol_empty" $(seq 1 $empty) +# } +# # $@ diff --git a/.tmux.conf.local b/.tmux.conf.local new file mode 100644 index 0000000..e48c0e6 --- /dev/null +++ b/.tmux.conf.local @@ -0,0 +1,9 @@ +# use the powerline patched font variant of the theme +#tmux_conf_theme=powerline_patched_font + +# use 5 hearts for the battery status +#tmux_conf_battery_symbol=heart +#tmux_conf_battery_symbol_count=5 + +# or alternatively use an external tool, e.g. https://github.com/Goles/Battery +#tmux_conf_battery='#(battery -t) ' diff --git a/README.md b/README.md index 1b7bb79..e89ce9d 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ Features - [maximize any pane to a new window with `+`](http://pempek.net/articles/2013/04/14/maximizing-tmux-pane-new-window/) (tmux 1.6+) - mouse mode toggle with `m` - automatic usage of `reattach-to-user-namespace` if available + - laptop battery status Installation ------------