Refactored X keyboard scripts