mirror of
https://github.com/theniceboy/.config.git
synced 2026-07-16 22:01:21 +08:00
tmux watch notif
This commit is contained in:
parent
c56de89d3d
commit
8298371b35
3 changed files with 25 additions and 1 deletions
|
|
@ -67,7 +67,7 @@ func runTrackerCommand(args []string) error {
|
||||||
}
|
}
|
||||||
command := strings.TrimSpace(rest[0])
|
command := strings.TrimSpace(rest[0])
|
||||||
switch command {
|
switch command {
|
||||||
case "start_task", "finish_task", "update_task", "acknowledge", "delete_task":
|
case "start_task", "finish_task", "update_task", "acknowledge", "delete_task", "notify":
|
||||||
ctx, err := resolveTrackerContext(env.Session, env.SessionID, env.Window, env.WindowID, env.Pane)
|
ctx, err := resolveTrackerContext(env.Session, env.SessionID, env.Window, env.WindowID, env.Pane)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -204,6 +204,21 @@ func (s *server) handleCommand(env ipc.Envelope) error {
|
||||||
s.broadcastStateAsync()
|
s.broadcastStateAsync()
|
||||||
s.statusRefreshAsync()
|
s.statusRefreshAsync()
|
||||||
return nil
|
return nil
|
||||||
|
case "notify":
|
||||||
|
target, err := requireSessionWindow(env)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
message := firstNonEmpty(env.Summary, env.Message)
|
||||||
|
if message == "" {
|
||||||
|
return fmt.Errorf("notify requires summary")
|
||||||
|
}
|
||||||
|
if s.notificationsAreEnabled() {
|
||||||
|
if err := sendSystemNotification(notificationTitleForTarget(target), message, notificationActionForTarget(target)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
case "update_task":
|
case "update_task":
|
||||||
target, err := requireSessionWindow(env)
|
target, err := requireSessionWindow(env)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,14 @@ pane_shell=$(ps -o comm= -p "$pane_pid" 2>/dev/null | sed 's|.*/||; s/^-//')
|
||||||
current_cmd=$(tmux display-message -p -t "$pane_id" '#{pane_current_command}' 2>/dev/null || true)
|
current_cmd=$(tmux display-message -p -t "$pane_id" '#{pane_current_command}' 2>/dev/null || true)
|
||||||
[[ -z "$current_cmd" ]] && exit 0
|
[[ -z "$current_cmd" ]] && exit 0
|
||||||
|
|
||||||
|
notify_completion() {
|
||||||
|
local tracker_bin message
|
||||||
|
tracker_bin="$HOME/.config/agent-tracker/bin/agent"
|
||||||
|
[[ -x "$tracker_bin" ]] || return 0
|
||||||
|
message="${current_cmd} finished"
|
||||||
|
"$tracker_bin" tracker command -window-id "$window_id" -pane "$pane_id" -summary "$message" notify >/dev/null 2>&1 || true
|
||||||
|
}
|
||||||
|
|
||||||
if [[ "$current_cmd" == "$pane_shell" ]]; then
|
if [[ "$current_cmd" == "$pane_shell" ]]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
@ -35,3 +43,4 @@ done
|
||||||
tmux set -wu -t "$window_id" @watching 2>/dev/null || true
|
tmux set -wu -t "$window_id" @watching 2>/dev/null || true
|
||||||
tmux set -w -t "$window_id" @unread 1 2>/dev/null || true
|
tmux set -w -t "$window_id" @unread 1 2>/dev/null || true
|
||||||
tmux refresh-client -S
|
tmux refresh-client -S
|
||||||
|
notify_completion
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue