diff options
| author | Mitchell Riedstra <mitch@riedstra.dev> | 2021-03-07 11:38:57 -0500 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@riedstra.dev> | 2021-03-07 11:38:57 -0500 |
| commit | 3d0f794513199e07c354a452920f90f7b5365eae (patch) | |
| tree | 7cfa8e711da0cb5980ce8c5d1eedac251ca4f50a /bin/status-bar | |
| parent | cee85ee94fbcd38b2cd506f51e4308f81c622247 (diff) | |
| download | dotfiles-3d0f794513199e07c354a452920f90f7b5365eae.tar.gz dotfiles-3d0f794513199e07c354a452920f90f7b5365eae.tar.xz | |
Add charging status to the bar.
Diffstat (limited to 'bin/status-bar')
| -rwxr-xr-x | bin/status-bar | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/bin/status-bar b/bin/status-bar index 5a5eba1..f73879a 100755 --- a/bin/status-bar +++ b/bin/status-bar @@ -1,5 +1,5 @@ #!/bin/sh -timeout=61 +timeout=10 _sys_memory() { free -m | awk '/^Mem/{print $6;exit 0;}' @@ -52,7 +52,19 @@ pine_batt_status() { batt_status() { # sudo tlp-stat -b | awk 'BEGIN{ORS=" "} /\/status/{print $3}/^Charge/{print $3}'; - cat /sys/class/power_supply/BAT0/capacity + printf "%s %s" \ + "$(cat /sys/class/power_supply/BAT0/capacity)" \ + "$(charging_status)" +} + +charging_status() { + if [ "$(cat /sys/class/power_supply/AC/online)" = "1" ] ; then + printf "Charging" + elif [ "$(cat /sys/class/power_supply/AC/online)" = "0" ] ; then + printf "Discharging" + else + printf "Unknown charging status" + fi } cpu_freq() { @@ -97,7 +109,7 @@ sensors | sed -n '/^k10/,/^$/p' | awk '/^Tctl/{print $2}' \ } pine_Temp() { - sensors | sed -n -e 's/^temp1[ \t:]*//p' | sed 1q + sensors | sed -n -e 's/^temp1[ \t:]*//p' | sed 1q } pine_status_line() { @@ -148,5 +160,6 @@ echo \ _type="$1"; shift while true ; do xsetroot -name "$("${_type}_status_line" "$@")" +# echo "$("${_type}_status_line" "$@")" sleep "$timeout" done |
