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

1 Answer 1


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:


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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .