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:
parent
1d2a5f249d
commit
d96a1b7438
@ -27,3 +27,6 @@
|
|||||||
dst: ~/.local/share/tmux/layouts/window-wide-left
|
dst: ~/.local/share/tmux/layouts/window-wide-left
|
||||||
- src: layouts/window-wide-right
|
- src: layouts/window-wide-right
|
||||||
dst: ~/.local/share/tmux/layouts/window-wide-right
|
dst: ~/.local/share/tmux/layouts/window-wide-right
|
||||||
|
- command:
|
||||||
|
- install: system-info/install.sh
|
||||||
|
- remove: system-info/remove.sh
|
||||||
|
8
system-info/install.sh
Executable file
8
system-info/install.sh
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
script_dir=`dirname $0`
|
||||||
|
|
||||||
|
if [ `uname` = Darwin ]; then
|
||||||
|
cp $script_dir/system-info.plist ~/Library/LaunchAgents/system-info.plist
|
||||||
|
launchctl load -w ~/Library/LaunchAgents/system-info.plist
|
||||||
|
fi
|
6
system-info/remove.sh
Executable file
6
system-info/remove.sh
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [ `uname` = Darwin ]; then
|
||||||
|
launchctl unload ~/Library/LaunchAgents/system-info.plist
|
||||||
|
rm ~/Library/LaunchAgents/system-info.plist
|
||||||
|
fi
|
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
|
14
system-info/system-info.plist
Normal file
14
system-info/system-info.plist
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>Label</key>
|
||||||
|
<string>system-info</string>
|
||||||
|
<key>ProgramArguments</key>
|
||||||
|
<array>
|
||||||
|
<string>/Users/benie/.config/tmux/system-info/system-info-macOS.sh</string>
|
||||||
|
</array>
|
||||||
|
<key>KeepAlive</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
@ -124,11 +124,8 @@ setw -g status-left-style fg=colour240,bg=colour233
|
|||||||
# Centre status style
|
# Centre status style
|
||||||
setw -g status-style fg=colour240,bg=colour233
|
setw -g status-style fg=colour240,bg=colour233
|
||||||
|
|
||||||
# Right status style, show data and time (and battery percentage on macOS).
|
# Right status style shows system info, date, and time.
|
||||||
if '[ "`uname`" = "Darwin" ]' \
|
setw -g status-right "#(cat ~/.cache/tmux/system-info) %a %d-%m-%y %H:%M "
|
||||||
'setw -g status-right "#(pmset -g batt | grep --color=never -Eo \"\\d+%%\")\
|
|
||||||
↯ %a %d-%m-%y %H:%M "' \
|
|
||||||
'setw -g status-right "%a %d-%m-%y %H:%M "'
|
|
||||||
setw -g status-right-style fg=white,bg=colour233
|
setw -g status-right-style fg=white,bg=colour233
|
||||||
|
|
||||||
# Active window status style
|
# Active window status style
|
||||||
|
Loading…
x
Reference in New Issue
Block a user