I found a cool keyboard shortcut utility today for Fedora. For some reason the mute shortcut of CTRL + T on the Gnome volume applet wasn’t working. I like to stream news or music sometimes outside of my usual Amarok music collection, but I wasn’t able to mute the volume when I received a phone call or someone popped in the office. I found xbindkeys to do the trick.
As root:
# yum install xbindkeys
As your user:
# xbindkeys --defaults > $HOME/.xbindkeys
You can then open up the default file and read all the fun stuff in there. To add something custom, just put the lines in like below. I’ll show you adding my command to use amixer to mute the sound.
# vim $HOME/.xbindkeysrc
“amixer set Master mute”
Control + m
“amixer set Master unmute”
Control + n
Next, you’ll need to save the file and then actually start xbindkeys in the background for it to run. Check to make sure it’s running then.
# xbindkeys
# ps uxa | grep xbindkeys
500 16610 0.0 0.2 5720 2080 ? S 15:21 0:00 xbindkeys
Whenever you make a change to the configuration file, you’ll have to kill this process and restart it.
# killall xbindkeys
# xbindkeys
Lastly, it’s a pain to have to start it from the command line every time you log into your session, so add it to the Gnome (find your KDE instructions if you use KDE) session manager.
Menu -> System -> Preferences -> Personal -> Sessions
Go to the Startup Programs tab and click Add.
Name: xbindkeys
Command: /usr/bin/xbindkeys
Comment: Custom key commands utility
Click OK and you’re ready to go.
In this example, when I hit CTRL + M it will mute my sound and when I hit CTRL + N it will unmute my sound. You can add whatever you want, it’s pretty cool. You can even add mouse click commands.
If you want to install on RHEL or CentOS, just download the source.
Xbindkeys
If you don’t know what the key code is for adding something like a number, from the command line do the following.
# xbindkeys -k
You’ll see a box popup asking you to press a key. Go ahead and hit something, I’ll hit the number 8 key and you can see what the output is.
# xbindkeys -k
Press combination of keys or/and click under the window.
You can use one of the two lines after "NoCommand"
in $HOME/.xbindkeysrc to bind a key.
"(Scheme function)"
m:0x10 + c:17
Mode2 + 8