Unrar and Handbrake questions

So this is what I want to accomplish:
1. If a directory has a rar file in it then unrar it with command line version of The Unarchiver
2. Once the file has been unrared I want to use Handbrake CLI to convert it to mv4.
So I have setup two rules: one to unrar and one to convert. I have a couple questions:
1. In my HandbrakeCLI rule I have this script:
NAME=$(basename "$1")
NAME=${NAME%.*}
/Users/scott/bin/HandBrakeCLI -i "$1" -o "/Users/scott/Desktop/$NAME.m4v" --preset='Apple TV3'
However I seem to have to hard code the path to my home directory. If I do something like ~/Desktop in the output directory the command doesn't run. Is there a way to specify my home directory in the script (I'm using an embedded script). Can I use shell variables such as $HOME?
2. Is there a way to tell Hazel to not process a file until another rule has finished? In other words how does Hazel know that my unrar command is done? I don't want it to try to handbrake the rar file if the unrar process hasn't finished.
Thanks in advance, Scott
1. If a directory has a rar file in it then unrar it with command line version of The Unarchiver
2. Once the file has been unrared I want to use Handbrake CLI to convert it to mv4.
So I have setup two rules: one to unrar and one to convert. I have a couple questions:
1. In my HandbrakeCLI rule I have this script:
NAME=$(basename "$1")
NAME=${NAME%.*}
/Users/scott/bin/HandBrakeCLI -i "$1" -o "/Users/scott/Desktop/$NAME.m4v" --preset='Apple TV3'
However I seem to have to hard code the path to my home directory. If I do something like ~/Desktop in the output directory the command doesn't run. Is there a way to specify my home directory in the script (I'm using an embedded script). Can I use shell variables such as $HOME?
2. Is there a way to tell Hazel to not process a file until another rule has finished? In other words how does Hazel know that my unrar command is done? I don't want it to try to handbrake the rar file if the unrar process hasn't finished.
Thanks in advance, Scott