Would be better in a separate script file (it could probably be reused in the desktop resource manager too)