File: notify

package info (click to toggle)
fonts-inter 4.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 55,840 kB
  • sloc: python: 9,184; ansic: 3,776; javascript: 762; makefile: 637; sh: 466; xml: 22
file content (41 lines) | stat: -rwxr-xr-x 1,007 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
#
# Shows macOS desktop notifications when a command completes.
# Depending on exit status of the command, a different notification message is shown.
#
# Examples:
#   misc/nofify make -j 8 >/dev/null
#     Make all font styles in all formats without printing detailed messages
#
#   misc/notify make Regular
#     Make the regular style in all formats
#

HAS_NOTIFIER=true
if ! (which terminal-notifier >/dev/null); then
  HAS_NOTIFIER=false
  echo "$0: terminal-notifier not found in PATH (will not notify)" >&2
  echo "$0: You can install through: brew install terminal-notifier"
fi

CMDS="$@"
"$@"
STATUS=$?

if $HAS_NOTIFIER; then
  if [[ $STATUS -eq 0 ]]; then
    terminal-notifier \
      -title "$1 ✅" \
      -message "$CMDS" \
      -activate com.apple.Terminal \
      -timeout 8 >/dev/null &
  else
    terminal-notifier \
      -title "$1 failed ❌" \
      -message "$CMDS => $STATUS" \
      -activate com.apple.Terminal \
      -timeout 20 >/dev/null &
  fi
fi

exit $STATUS