Add system-info macOS user agent
The `system-info` directory contains scripts and configuration files to install and remove a `launchd` user agent on macOS which collects information about the system and outputs it to the file `~/.cache/tmux/system-info`. This file is then read periodically by `tmux` and the contents displayed in the status line.
This commit is contained in:
19
system-info/system-info-macOS.sh
Executable file
19
system-info/system-info-macOS.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/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
|
||||
battery="`pmset -g batt | grep --color=never -Eo '\d+%'` ↯"
|
||||
echo "$battery" > $cache_file
|
||||
sleep 2
|
||||
done
|
||||
Reference in New Issue
Block a user