I found this kind of solution. While loop waits until omxplayer or fbi process has ended and then next image or video can be shown. while ps ax | grep -v grep | grep -E "omxplayer|fbi" > /dev/null; do sleep 0.1 done