A simple inotify script to control rtorrent

A simple inotify script to control rtorrent

So, I only want rtorrent to start when a torrent is available for download. I came up with the following script:

#!/bin/bash

while inotifywait -qq -e create /path/to/torrentdir; do
  if pgrep rtorrent > /dev/null; then
     continue
  elif echo /path/to/torrentdir/* | grep torrent; then
     screen -d -m -S rtorrent rtorrent
  fi
done