From 1b2a277a7a27082e4b75ad8ea89efd3f7aa2559e Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Wed, 17 Feb 2021 20:32:21 +0000 Subject: [PATCH] Update system-info macOS user agent Add CPU temperature to `status-info`, conditionally display battery charge percentage, and documents the commands. --- .conduit.yaml | 1 + system-info/system-info-macOS.sh | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.conduit.yaml b/.conduit.yaml index 5cf9dd0..a56b2fe 100644 --- a/.conduit.yaml +++ b/.conduit.yaml @@ -10,6 +10,7 @@ - tmux - urlview - reattach-to-user-namespace + - osx-cpu-temp - pacman: - tmux - xclip diff --git a/system-info/system-info-macOS.sh b/system-info/system-info-macOS.sh index 5a6aca4..fa43258 100755 --- a/system-info/system-info-macOS.sh +++ b/system-info/system-info-macOS.sh @@ -13,7 +13,15 @@ trap '[ -f $cache_file ] && rm $cache_file; exit' INT trap '[ -f $cache_file ] && rm $cache_file; exit' TERM while true; do - battery="`pmset -g batt | grep --color=never -Eo '\d+%'` ↯" - echo "$battery" > $cache_file + # 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