Global GTK+ hotkey

2

Ideally, I'd like to bind a hotkey across all apps using gtk.

I have Ctrl+Shift+p bound to paste from the selection buffer in urxvt, which generally means I can do everything without moving my hands from the keyboard (vim is X buffer aware, and I have a tmux hook to place copied text into that buffer) however, when I go to firefox et al, I have to move my hand to the mouse to middle click.

Is it possible to bind global behaviour like this in the context of the gtk textentry widget?

richo

Posted 2011-12-19T02:24:18.607

Reputation: 359

Answers

2

GTK+ 2 allows customization of keyboard bindings (among other things) via gtkrc files, such as ~/.gtkrc-2.0. (There does not seem to be any equivalent for GTK+ 3 programs.)

Unfortunately, I couldn't find any way to paste from the PRIMARY selection, only from CLIPBOARD selection (which already has CtrlV assigned by default, so this customization will be useless):

binding "custom-text-entry"
{
    bind "<ctrl><shift>p" { "paste-clipboard" () }
}
class "GtkEntry" binding "custom-text-entry"

However, real GTK+ programs already have a keyboard shortcut ShiftIns for pasting from the PRIMARY selection, while Firefox is not pure GTK+ – many controls it uses are reimplemented in Firefox itself. You might need to edit some internal files to change its shortcuts.

user1686

Posted 2011-12-19T02:24:18.607

Reputation: 283 655

Thanks! I realised that firefox may be tricky but I use a stack of GTK apps so just having it work in them is a lot better than nothing! – richo – 2011-12-20T01:44:36.280