Show battery in tmux status
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
b7d5017ced
commit
addb61367c
2 changed files with 22 additions and 1 deletions
|
@ -34,7 +34,7 @@ set -g status-justify left
|
||||||
set -g status-left-length 40
|
set -g status-left-length 40
|
||||||
set -g status-right-length 140
|
set -g status-right-length 140
|
||||||
set -g status-left '#[fg=green]#H#[default] '
|
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
|
# C-b is not acceptable -- Vim uses it
|
||||||
set-option -g prefix C-a
|
set-option -g prefix C-a
|
||||||
|
|
21
bin/tmux-battery
Executable file
21
bin/tmux-battery
Executable file
|
@ -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}%"
|
Loading…
Reference in a new issue