This looks like a far better solution...

console.set_idle_timer_disabled(flag)

Disable or enable the idle timer (which puts the device to sleep after a certain period of inactivity).