Created
February 1, 2017 16:51
-
-
Save samirfor/a99c7a9bcf692caee2264a8d220ccb46 to your computer and use it in GitHub Desktop.
Bash script to play a song when a process ends.
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 | |
# Bash script to play a song when a process ends. | |
# License MIT <https://opensource.org/licenses/MIT> | |
# Author: @samirfor | |
PID=$1 | |
SONGFILE=$2 | |
if [ "${PID}x" = "x" ] || [ ! -r "${SONGFILE}" ]; then | |
echo "usage: $0 <pid> <songfile>" && exit 1 | |
fi | |
ps --pid $PID &>/dev/null | |
[ $? -ne 0 ] && echo "PID does not exist." && exit 2 | |
while sleep 1; do ps --pid $PID &>/dev/null; [ $? -eq 0 ] || break; done | |
mpg123 "$SONGFILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment