Tuesday, April 28, 2009

Keyboard Shortcuts in Gnome, KDE, wmii, or whatever

Ubuntu Jaunty Jackelope put keyboard shortcuts in their proper place (disabling those in metacity and putting them in 'Keyboard Shortcuts'). However, when opening a gnome terminal from this shortcut, you have to explicitly tell it to start in your home directory or it will start in '/'

System->Preferences->KeyboardShortcuts  then [+Add]

gnome-terminal --geometry 80x52 --working-directory $HOME

I like to set up my keyboard shortcuts with a script since I like to use them on whatever computer I'm on. I did this before with gconftool2 and that worked fine, but now a person has to set them in a different location in a different way... which got me thinking that it would be nice to set keyboard shortcuts in a cross-desktop (KDE, Gnome, wmii, whatever) kind of way.

Solution: xbindkeys

sudo apt-get install xbindkeys

Make a file called '.xbindkeysrc' in your home directory with something like this in it:

control+alt + g
control+alt + n
"firefox -new-window http://gmail.com"
control+alt + e
control+alt + h
control+alt + f
"gnome-terminal --geometry 80x40"
control+alt + t
control+alt + m

now you can turn on the shortcuts with the simple command 'xbindkeys', but we'd really like for them to be turned on once when we login. Turns out cross-desktop startup is not very uniform but I think the proper way to do this (cross-desktop) is to do this:

Make sure you have a directory called '.config/autostart'. Then add a file to it called 'xbindkeys.desktop' with content along these lines:

[Desktop Entry]

This is what happens in Gnome when you add an entry in System->Preferences->StartupApplications.

No comments: