You can achieve the initial goal with numlockx
command. First, make sure it is installed:
sudo apt-get install numlockx
Then follow Adding Program To Session Startup instructions to add the following command:
date +%H|grep -Eq '^(09|1[0-8])$' && numlockx off || numlockx on