How can I programatically show/hide my app window with global shortcut key?

The Keybinder library does exactly this. If you check pull requests there are requests in for examples using pygi, one of which is me for py3k.


I realize this is an external setting, not in app, but I thought I'd write how to do this since I couldn't find documentation online.

I needed to read some compiz settings recently for my program, so figuring out how to change them was fairly straightforward. You can programatically set compiz settings in python using python-compizconfig. I've played with it a little bit and you can set values like so:

import compizconfig
context=compizconfig.Context()
commandplugin=context.Plugins['commands']
c0=commandplugin.Screen['command0']
c0.Value='xeyes'
key0=commandplugin.Screen['run_command0_key']
key0.Value='<Control><Primary>g'
context.Write()   #Note that sometimes you have to pass False to get it to update settings

The above sets the commands plugin of compiz to run xeyes using control-g keycombination. You'd probably have to do a check to make sure that the plugin was running (mine was off in ccsm by default). Note that to get many of the settings you can use the keys() function to list them (i.e.) context.Plugins.keys()

Here's a link to code that helped me figure out how this works, since I can't find any documentation: http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/precise/compizconfig-python/precise/view/head:/src/compizconfig.pyx