diff --git a/system-info/system-info-Linux.sh b/system-info/system-info-Linux.sh index f696302..f4eebc5 100755 --- a/system-info/system-info-Linux.sh +++ b/system-info/system-info-Linux.sh @@ -22,17 +22,36 @@ else } fi +if [ "`acpi -b`" != "No support for device type: power_supply" ]; then + function get_battery { + acpi -b | \ + awk '{ print $4 }' | \ + awk '$battery ~ /.*/ { + printf "%3d%% %s\n", $battery, substr("󰁹󰂂󰂁󰂀󰁿󰁾󰁽󰁼󰁻󰁺󰂎", int($battery / 9), 1) + }' + } +else + function get_battery { + echo '' + } +fi + # Cleanup cache file when interrupted. trap '[ -f $cache_file ] && rm $cache_file; exit' INT trap '[ -f $cache_file ] && rm $cache_file; exit' TERM while true; do # Parse the current CPU load on all cores/threads. - cpu_load=`mpstat -P ALL -n 1 -u 1 -o JSON | \ + cpu_load=" `mpstat -P ALL -n 1 -u 1 -o JSON | \ jq '.sysstat.hosts[0].statistics[0]["cpu-load"][1:]|.[].idle' | \ - awk '$idle ~ /[-.0-9]*/ { printf "%s", substr("█▇▆▅▄▃▂▁ ", int($idle / 11), 1) }'` + awk '$idle ~ /[-.0-9]*/ { printf "%s", substr("█▇▆▅▄▃▂▁ ", int($idle / 11), 1) }'`" + # Parse the current CPU package temperature. cpu_temp=$(get_cpu_temp) + + # Get the battery status if present. + battery=$(get_battery) + # Write to the cache file. - echo "$cpu_temp $cpu_load" > $cache_file + echo "$cpu_temp$cpu_load$battery" > $cache_file done diff --git a/tmux.conf b/tmux.conf index 7d28f6a..b2ecc6f 100644 --- a/tmux.conf +++ b/tmux.conf @@ -138,7 +138,7 @@ setw -g status-style fg=colour240,bg=colour233 setw -g status-right "#[fg=colour240]#(cat ~/.cache/tmux/system-info)#[fg=white] %a %d-%m-%y %H:%M " setw -g status-right-style fg=white,bg=colour233 if -b '[ "`uname`" != "Darwin" ]' \ - 'run "tmux setw -g status-right-length $((`nproc --all` + 32))"' + 'run "tmux setw -g status-right-length $((`nproc --all` + 48))"' # Active window status style setw -g window-status-current-format " #{window_index}: #{window_name}"