Eclectic Media Git toast-with_toast_when_complete / 7bf08ed
Added toast_when_complete script, updated Readme Ariana Giroux 8 months ago
2 changed file(s) with 50 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
00 Quickstart guide for toast
11 ==========================
22
3 ``toast`` provides an ease of access layer to BurntToast_ native Windows
4 notifications.
3 ``toast`` provides an ease of access layer to BurntToast_ native Windows notifications.
4
5 This fork adds an ease of use script, written in Bash called `toast_when_complete`. This script provides a wrapper around toast, and auto-formats a toast notification based on the execution of a user specified oneliner.
6
7 For example:
8 ::
9
10 toast_when_complete python3 -m venv venv # or some other long running oneliner
11
12 ``toast`` will then format the title and body of the toast notification to be as useful as possible, placing the command passed as the title, and the exit status in the body.
13
14 .. note:: the script is located at ``scripts/toast_when_complete``
515
616 Installing from Source
717 ======================
0 #! /bin/bash
1 #
2 # Note: Requires git@eclecticmedia.hopto.org:arianagiroux/toast.git
3 #
4 # Provides a utility to output a toast notification after a command has completed,
5 # notify the user about the exit status.
6 #
7 # Exists under the MIT license
8 #
9 # To install, simply add this script anywhere on your path.
10
11 if ! whereis toast | sed "s/toast: //" | egrep "toast" &> /dev/null; then
12 echo "Failed to find toast!" 2>1
13 exit 1
14 fi
15
16 if echo "$@" | egrep '\-h'; then
17 echo "toast_on_complete COMMAND"
18 echo ""
19 echo " COMMAND - The command to run. All arguments placed in order at runtime."
20 echo ""
21 echo "Spawns toast notification confirming exit status of specified command."
22 fi
23
24 "$@"
25 exit_status="$?"
26
27 if echo "$@" | awk "length>70" | grep ".*" &> /dev/null; then
28 truncated_command="$(echo "$@" | cut -c -32)..."
29 else
30 truncated_command="$@"
31 fi
32
33 if [ "$exit_status" == "0" ]; then
34 toast -t "$truncated_command" "Completed okay! ($?)"
35 else
36 toast -t "$truncated_command" "Failed! ($?)"
37 fi