Skip to content

Commit 98d1bb9

Browse files
Updated battery indicator
1 parent 91d8954 commit 98d1bb9

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

battery.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

shellscripts/battery.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
11
#! /bin/bash
2-
echo "$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1)"
2+
3+
battery_percentage=$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1)
4+
battery_state=$(pmset -g ps|sed -nE "s|.*'(.*) Power.*|\1|p")
5+
6+
if [ "$battery_state" == "AC" ]; then
7+
battery_state_icon="󱊦"
8+
else
9+
battery_state_icon="󱊣"
10+
fi
11+
12+
if [ -z "$battery_percentage" ]; then
13+
echo "100% $battery_state_icon"
14+
else
15+
echo "$battery_percentage% $battery_state_icon"
16+
fi

tmux-colors/cg-theme.tmux

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,11 @@ set -g status-right-style NONE
2727

2828
tm_session="#[fg=$tm_black,bg=$tm_fg,bold]  #S "
2929
tm_datetime="%A %D  %r  "
30-
tm_battery_status='#(bash -c ~/bashrc-cg/shellscripts/battery.sh)'
31-
tm_battery_enabled="$tm_battery_status 󰊘"
32-
tm_battery_disabled="100% 󱐉"
33-
tm_battery='#{?$tm_battery_status,#{tm_battery_enabled},#{tm_battery_disabled}} '
30+
tm_battery_status='#(bash -c ~/bashrc-cg/shellscripts/battery.sh)'
3431
tm_host="#[fg=$tm_black,bg=$tm_fg,nobold] 󱩊 #h "
3532

3633
tm_left_section="$tm_session"
37-
tm_right_section="#[fg=$tm_fg,bg=$tm_bg]$tm_battery$tm_datetime"
34+
tm_right_section="#[fg=$tm_fg,bg=$tm_bg]$tm_battery_status $tm_datetime"
3835

3936
set -g status-left "$tm_left_section"
4037
set -g status-right "$tm_right_section"

0 commit comments

Comments
 (0)