From 237358425b1ba9ca6a6ff175c2b7bfa33b028695 Mon Sep 17 00:00:00 2001 From: Andreas Kohlbecker Date: Wed, 15 Feb 2023 22:57:33 +0100 Subject: [PATCH] fix #7 Most parameters of this plugin are configurable --- README.md | 11 +++++++++++ scripts/monitor-session-activity.sh | 19 ++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2eff73e..7b71df1 100644 --- a/README.md +++ b/README.md @@ -40,3 +40,14 @@ Once the aw-watcher-tmux plugin is installed it monitors for user activity in al aw-watcher-tmux creates a new bucket. The existence of this bucket can be checked with [http://localhost:5600/api/0/buckets/aw-watcher-tmux](http://localhost:5600/api/0/buckets/aw-watcher-tmux). All activity recorded in this bucket can be seen on [http://localhost:5600/#/timeline](http://localhost:5600/#/timeline) + +## Configuration + +Many parameters of this plugin are configurable. For example to use `my.aw-server.test` as alternative aw host, add the following line to your `~/.tmux.conf`: + +~~~tmux +set -g @aw-watcher-tmux-host 'my.aw-server.test' +~~~ + +For more options, please see `./scripts/monitor-session-activity.sh` + diff --git a/scripts/monitor-session-activity.sh b/scripts/monitor-session-activity.sh index cb2be8f..7cd692b 100755 --- a/scripts/monitor-session-activity.sh +++ b/scripts/monitor-session-activity.sh @@ -1,19 +1,28 @@ #!/usr/bin/env bash -POLL_INTERVAL=10 # seconds +get_tmux_option() { + local option_value=$(tmux show-option -gqv "$1"); + echo ${option_value:-$2} +} + +###### +# Configurable options +# +# Usage examle: +# set -g @aw-watcher-tmux-host 'my.aw-server.test' +POLL_INTERVAL=$(get_tmux_option "@aw-watcher-tmux-poll-interval" 10) # seconds +HOST=$(get_tmux_option "@aw-watcher-tmux-host" "localhost") +PORT=$(get_tmux_option "@aw-watcher-tmux-port" "5600") +PULSETIME=$(get_tmux_option "@aw-watcher-tmux-pulsetime" "120.0") BUCKET_ID="aw-watcher-tmux" -HOST="localhost" -PORT="5600" API_URL="http://$HOST:$PORT/api" -PULSETIME="120.0" ###### # Related documentation: # * https://github.com/tmux/tmux/wiki/Formats # * https://github.com/tmux/tmux/wiki/Advanced-Use#user-content-getting-information # -# ### FUNCTIONS