0

I have written a little shell script which starts an mplayer instance for a video background in i3; Arch. Now, I want to kill that process every 15 seconds and start it again. But, since that background will run all the time, killing by name would lead to "iCantUseMplayerAnymorePlzHelp" So, how can I kill just that process?

For the bg I execute the following:

mplayer -loop 0 -rootwin -ao null -noconsolecontrols -fs VIDEOPATH
2

If you want to launch mplayer, kill it after 15 seconds and repeat until the script itself is killed, you can do something like this:

#!/bin/sh

while true; do
  ## launch mplayer in the background
  mplayer -loop 0 -rootwin -ao null -noconsolecontrols -fs VIDEOPATH &
  ## wait for 15 seconds
  sleep 15
  ## kill the 1st backgrounded job of this subshell
  kill %1
done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.