diff --git a/.tmux.conf b/.tmux.conf index f554da1..c8ad47c 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -34,7 +34,7 @@ set -g status-justify left set -g status-left-length 40 set -g status-right-length 140 set -g status-left '#[fg=green]#H#[default] ' -set -g status-right '#[fg=red,bg=default]#(check_config)#[default] #[fg=red,bg=default]#(tmux-chrony-timediff)#[default] #[fg=white,bg=red]#(tmux-reboot-required)#[default] #[fg=red,dim,bg=default]#(uptime | cut -f 4-5 -d " " | cut -f 1 -d ",") #[fg=white,bg=default]%a, %H:%M:%S#[default] #[fg=blue,bright]%Y-%m-%d (KW %V) ' +set -g status-right '#[fg=red,bg=default]#(check_config)#[default] #[fg=red,bg=default]#(tmux-chrony-timediff)#[default] #[fg=white,bg=red]#(tmux-reboot-required)#[default] #[fg=white,bg=default]#(tmux-battery)#[default] #[fg=green,bg=default]#(uptime | cut -f 4-5 -d " " | cut -f 1 -d ",") #[fg=white,bg=default]%a, %H:%M:%S#[default] #[fg=blue,bright]%Y-%m-%d (KW %V) ' # C-b is not acceptable -- Vim uses it set-option -g prefix C-a diff --git a/bin/tmux-battery b/bin/tmux-battery new file mode 100755 index 0000000..41d9c91 --- /dev/null +++ b/bin/tmux-battery @@ -0,0 +1,21 @@ +#!/bin/bash +set -euo pipefail + +SYM_ADAPTER="⚡️" +SYM_BATTERY="🔋" +BATTERY=/sys/class/power_supply/BAT0 +AC=/sys/class/power_supply/AC + +[ -e ${BATTERY} ] || { echo "No battery" >&2; exit 0; } +[ -e ${AC} ] || { echo "No ac" >&2; exit 0; } + +CAPACITY=$(cat ${BATTERY}/capacity) +AC_CONNECT=$(cat ${AC}/online) + +if [ ${AC_CONNECT} -eq 0 ]; then + SYM=${SYM_BATTERY} +else + SYM=${SYM_ADAPTER} +fi + +echo "${SYM} ${CAPACITY}%"