Last active
January 4, 2020 10:45
-
-
Save v6ak/5204011 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
Found this when looking for an example, and added the following to clear out finished jobs after a given time.
edit: apparently i missed that when the TS_ONFINISH hook runs, the status is still running, moved the is finished check to the at job.