#!/usr/bin/env perl # perl implementation of ding # https://github.com/globau/ding/ # globau licensed his MIT, so this is too # requires mpg321 for audio playback. # to install on Ubuntu, # sudo apt install mpg321 use feature qw{ say state } ; use strict ; use warnings ; use utf8 ; use DateTime ; use DateTime::Duration ; my $sound = join '/', $ENV{HOME}, 'sounds' ; my $ding = join '/', $sound, 'ding.mp3' ; my $error = join '/', $sound, 'error.mp3' ; if ( scalar @ARGV ) { my $start = DateTime->now() ; if ( system(@ARGV) == 0 ) { qx{mpg123 -q $ding} ; } else { qx{mpg123 -q $error} ; } my $end = DateTime->now() ; my $duration = $end->subtract_datetime_absolute($start) ; my $seconds = $duration->delta_seconds(); say qq{process took $seconds seconds}; } else { qx{mpg123 -q $ding} ; } __DATA__ As I understand ding if there's something in ARGV get starting timestamp try sound = error syscall ARGV sound = ding catch if error, print error get ending timestamp find duration between both if duration > 1 seconds print elaptsed time else play ding MIT License Copyright (c) 2017 Dave Jacoby Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.