I am writing a simple typing break / anti-RSI programme on Linux (Ubuntu) in Python. I asked similar questions about locking the keyboard ( How do I 'lock the keyboard' to prevent any more keypresses being sent on X11/Linux/Gnome? and Releasing all keys after disabling the keyboard in X11/Linux using xinput? ) and someone suggested ( https://stackoverflow.com/a/10769704/161922 ) that grabbing the keyboard focus would be the best way. However I'm new to X11 programming. How would I do that in Python? (Presume I have python-xlib or whatever installed, I can also install anything from pypi or apt).
How do you make a simple X11 application that will grab the keyboard focus (even if another window is currently focussed). It should not be possible for the user to alt-tab or alt-f4 away from this (i.e. there is no escape). However it should be possible to 'release' this 'grabbing' later or at any time.