-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔀 Merge pull request #14 from rickstaa/fix_multi_call_#7
Fixes bug #7 which allowed for multiple simultaneous pane monitoring
- Loading branch information
Showing
6 changed files
with
115 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,34 @@ | ||
#!/usr/bin/env bash | ||
## -- Cancel monitoring script | ||
# Used to cancel the current pane monitor job | ||
|
||
# get id of the current active pane | ||
PANEID=$(tmux list-panes | grep "active" | awk -F\] '{print $3}' | awk '{print $1}') | ||
PID_DIR=~/.tmux/notify | ||
# Get current directory | ||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
# Cancel monitor process if active | ||
{ # Try | ||
# Source helpers and variables | ||
source "$CURRENT_DIR/helpers.sh" | ||
source "$CURRENT_DIR/variables.sh" | ||
|
||
# consult pid file for the pid | ||
PID=$(cat "$PID_DIR/$PANEID".pid) | ||
# Get pane id | ||
SESSION_NR=$(tmux list-sessions | grep "(attached)" | awk '{print $1}' | tr -d :) | ||
WINDOW_NR=$(tmux list-windows | grep "(active)" | awk '{print $1}' | tr -d :) | ||
PANE_NR=$(tmux list-panes | grep "active" | awk -F\] '{print $3}' | awk '{print $1}' | tr -d %) | ||
PANE_ID=$(detox_file_name "s_${SESSION_NR}_w${WINDOW_NR}_p${PANE_NR}") | ||
PID_FILE_PATH="${PID_DIR}/${PANE_ID}.pid" | ||
|
||
# job done - kill process and remove pid file | ||
kill $PID | ||
rm "$PID_DIR/$PANEID".pid | ||
# Cancel pane monitoring if active | ||
if [[ -f "$PID_FILE_PATH" ]]; then | ||
|
||
} || { # Catch | ||
# Retrieve monitor process PID | ||
PID=$(cat "$PID_FILE_PATH") | ||
|
||
# Kill process and remove pid file | ||
kill "$PID" | ||
rm "${PID_DIR}/${PANE_ID}.pid" | ||
|
||
# Display success message | ||
tmux display-message "Pane monitoring canceled..." | ||
else | ||
tmux display-message "Pane not monitored..." | ||
exit 0 | ||
} | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
#!/usr/bin/env bash | ||
## -- Add tmux plugin variables | ||
SUPPORTED_VERSION="1.9" | ||
|
||
## Main variables | ||
export SUPPORTED_VERSION="1.9" | ||
export PID_DIR=~/.tmux/notify | ||
|
||
## Tnotify tmux options | ||
|
||
# Notification verbosity settings | ||
verbose_option="@tnotify-verbose" | ||
verbose_default="off" | ||
verbose_msg_option="@tnotify-verbose-msg" | ||
verbose_msg_default="(#S, #I:#P) Tmux pane task completed!" | ||
export verbose_option="@tnotify-verbose" | ||
export verbose_default="off" | ||
export verbose_msg_option="@tnotify-verbose-msg" | ||
export verbose_msg_default="(#S, #I:#P) Tmux pane task completed!" | ||
|
||
# Monitor checker interval | ||
monitor_sleep_duration="@tnotify-sleep-duration" | ||
monitor_sleep_duration_default=10 | ||
export monitor_sleep_duration="@tnotify-sleep-duration" | ||
export monitor_sleep_duration_default=10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters