Add CPU temperature to `status-info`, conditionally display battery charge percentage, and documents the commands.
28 lines
755 B
Bash
Executable File
28 lines
755 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
cache_dir=~/.cache/tmux
|
|
cache_file=$cache_dir/system-info
|
|
|
|
# Make sure the output directory exists.
|
|
if [ ! -d $cache_dir ]; then
|
|
mkdir -p $cache_dir
|
|
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
|
|
# Get the current CPU temperature.
|
|
cpu_temp="`/usr/local/bin/osx-cpu-temp`"
|
|
# Check if a battery is installed.
|
|
if ioreg -w0 -l|grep BatteryInstalled &> /dev/null; then
|
|
# Parse the current battery charge percentage.
|
|
battery=" `pmset -g batt | grep --color=never -Eo '\d+%'` ↯"
|
|
fi
|
|
# Write to the cache file.
|
|
echo "$cpu_temp$battery" > $cache_file
|
|
# Don't spin, sleep instead.
|
|
sleep 2
|
|
done
|