-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplaybook
More file actions
executable file
·23 lines (18 loc) · 832 Bytes
/
Copy pathplaybook
File metadata and controls
executable file
·23 lines (18 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env bash
# Wrapper around ansible-playbook that sets the terminal's title and shows notifications
tit='Ansible Playbook'
ico=~/Documents/Pictures/ansible.png
pb="$(basename "${@: -1}")"
# Initial notification
notid="$(dunstify --printid -t 0 -I "${ico}" --appname "${tit}" "${pb}" 'Starting')"
ANSIBLE_FORCE_COLOR=true stdbuf -i0 -o0 -e0 ansible-playbook "${@}" | tee /proc/$$/fd/1 | while IFS='' read -r line; do
if [[ "${line}" =~ ^TASK\ \[ ]]; then
title="$(echo "${line}" | cut -d'[' -f2 | cut -d']' -f1)"
if [[ "${title}" == *" : "* ]]; then
title="$(echo "${title}" | awk -F' : ' '{print $2}')"
fi
echo -ne "\\033k[${title}]\\033\\"
dunstify -r "${notid}" -t 0 -I "${ico}" --appname "${tit}" "${pb}" "${title}"
fi
done
dunstify -r "${notid}" -t 10000 -I "${ico}" --appname "${tit}" "${pb}" Done