Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking to create a global hotkey in Python 3.2 for Ubuntu 12.10. That is, my script will run in the background and whenever I press Shift+F4 (for example), no matter what the active window is, the script will do something.

Some resources I have looked at:

Maybe I am too much of a newb (I am a beginner) or I have been looking in the wrong places or for the wrong things, but, I haven't been able to utilize the resources above.

How can I create a global hotkey with Python 3.2 in Ubuntu 12.10. Thanks!

share|improve this question
This seems like it'd fit better in a place like stackoverflow. – Kupiakos Dec 14 '12 at 23:49
Suggestion acted on: I wont be offended if moderators delete this thread. Thank you Kupiakos for the heads up. – onBootQuestioner Dec 14 '12 at 23:58
up vote 4 down vote accepted

You can do this at X11/Xlib level. See this question for how to handle global hotkeys correctly in C: Global Hotkey with X11/Xlib

Now you only need some Python Xlib library; python-xlib looks like a reasonable choice.

share|improve this answer
Through these links I eventually arrived at It took some compiling to get it going, but I just ran one of the examples, and it worked! Thank You! very neat! – onBootQuestioner Dec 15 '12 at 0:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.