A hack to rescue Super+P from gnome-settings-daemon
I like using tabbed terminals, and I like using Super+N ("next") and Super+P ("previous") to switch between the tabs. These bindings have worked well for years, but recently Super+P stopped working for me. Google helped me find two related bug reports:
- Ubuntu bug #539477: Video out hot key sends super + p + return on many upcoming Dell & HP systems
- Ubuntu bug #694910: Regression: patch to bug 539477 breaks Super+P keybindings
The nutshell: Recent gnome-settings-daemon unconditionally binds Super+P to rescan the video outputs and possibly reconfigure them. (If you're wondering, "Super" is the Win key, usually located between Ctrl and Alt.) The reason gnome-settings-daemon creates this binding is that newer PC BIOSes send this keystroke when they detect a monitor being plugged into, or unplugged from, the computer. And why do they do that? Because that's the keystroke in Windows 7 to bring up the display configuration dialog! So gnome-settings-daemon is simultaneously catching the BIOS announcement of changes to the attached displays, and also protecting your applications from a stray keystroke (that would most likely result in a "p" being inserted into the blog post you're writing).
I can't blame the authors of gnome-settings-daemon — this situation is really Microsoft's fault — but in any case, I'd rather handle video configuration changes without the extra help (I can launch the dialog on my own, thanks) and I can tolerate the tiny risk of a "p" turning up somewhere I didn't expect. I just want to be allowed to bind Super+P to change terminal tabs as I have in the past.
So here's a hack that gets the job done. The trick is to create a keybinding before gnome-settings-daemon starts, thereby blocking gnome-settings-daemon from grabbing it. After gnome-settings-daemon starts, release the binding so it's available to other programs, in my case the terminal emulator. To accomplish this I'm using xbindkeys, which is available in Fedora and Ubuntu.
Most of the time the distribution starts GNOME directly; i.e. gdm launches gnome-session for you. In that case you have no opportunity to run xbindkeys before gnome-settings-daemon runs. However you can customize the startup of your X applications by creating an $HOME/.xsession script and configuring your distro to use it. For Ubuntu instructions, see help.ubuntu.com; on Fedora you need to yum install xorg-x11-xinit-session then choose "User Script" at the login screen.
The minimal .xsession to rescue Super+P from gnome-settings-daemon is:
#!/bin/sh xbindkeys -f $HOME/.xbindkeysrc-super+p exec gnome-session
with the accompanying configuration:
# $HOME/.xbindkeysrc-super+p "pkill xbindkeys" mod4 + p
So xbindkeys grabs Super+P before gnome-settings-daemon runs, then goes away the first time you press the combo, leaving the key available to your programs.