diff --git a/.conduit.yaml b/.conduit.yaml index 69dc731..fbfae16 100644 --- a/.conduit.yaml +++ b/.conduit.yaml @@ -27,3 +27,6 @@ dst: ~/.local/share/tmux/layouts/window-wide-left - src: layouts/window-wide-right dst: ~/.local/share/tmux/layouts/window-wide-right +- command: + - install: system-info/install.sh + - remove: system-info/remove.sh diff --git a/system-info/install.sh b/system-info/install.sh new file mode 100755 index 0000000..8fc19e4 --- /dev/null +++ b/system-info/install.sh @@ -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 diff --git a/system-info/remove.sh b/system-info/remove.sh new file mode 100755 index 0000000..cfacc33 --- /dev/null +++ b/system-info/remove.sh @@ -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 diff --git a/system-info/system-info-macOS.sh b/system-info/system-info-macOS.sh new file mode 100755 index 0000000..5a6aca4 --- /dev/null +++ b/system-info/system-info-macOS.sh @@ -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 diff --git a/system-info/system-info.plist b/system-info/system-info.plist new file mode 100644 index 0000000..e41ecfd --- /dev/null +++ b/system-info/system-info.plist @@ -0,0 +1,14 @@ + + + + + Label + system-info + ProgramArguments + + /Users/benie/.config/tmux/system-info/system-info-macOS.sh + + KeepAlive + + + diff --git a/tmux.conf b/tmux.conf index 6140079..76ef522 100644 --- a/tmux.conf +++ b/tmux.conf @@ -124,11 +124,8 @@ setw -g status-left-style fg=colour240,bg=colour233 # Centre status style setw -g status-style fg=colour240,bg=colour233 -# Right status style, show data and time (and battery percentage on macOS). -if '[ "`uname`" = "Darwin" ]' \ - '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 "' +# Right status style shows system info, date, and time. +setw -g status-right "#(cat ~/.cache/tmux/system-info) %a %d-%m-%y %H:%M " setw -g status-right-style fg=white,bg=colour233 # Active window status style