-
-
Save markus2120/1db2560442d677c3c037877ccd016eea to your computer and use it in GitHub Desktop.
A handler for Task spooler
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
#!/bin/bash | |
# Copyright (C) 2012 Vít Šesták <v6ak.com> | |
# This program is free software. It comes without any warranty, to | |
# the extent permitted by applicable law. You can redistribute it | |
# and/or modify it under the terms of the Do What The Fuck You Want | |
# To Public License, Version 2, as published by Sam Hocevar. See | |
# http://www.wtfpl.net/ for more details. | |
# This utility notifies about completed messages of Task spooler (see http://viric.name/soft/ts/). | |
# Just add the path to this utility to $TS_ONFINISH. | |
# This utility is not a part of Task spooler. It is a separate project with a different author. | |
# | |
# You may want to add following line to .bashrc: | |
# export TS_ONFINISH=/usr/bin/ts-finished | |
jobid="$1" | |
error="$2" | |
outfile="$3" | |
command="$4" | |
queueSize=$(ts | (read; cat) | grep -vE '^[0-9]+ +finished' | wc -l) | |
if [ "$error" = 0 ]; then | |
icon=terminal | |
else | |
icon=error | |
fi | |
notify-send \ | |
-i "$icon" \ | |
"[TS] finished | |
[$jobid] $command returned $error | |
$(tail -n3 "$outfile") | |
(see $outfile) $queueSize" | |
if [ "$queueSize" == 1 ]; then # this is the last command in the queue | |
notify-send \ | |
--icon emblem-default \ | |
-t $((60*60*1000)) \ | |
"[TS] queue empty" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your code is amazing. Thanks.
The following sends email when the task fails.
Newer version of *linux have s-nail or mail instead of sendmail (which is default for task-spooler). Hope someone can find this useful.