On the computer upstairs we have an option to make the computer make a sound when we press Caps Lock, Number Lock and Scroll Lock. Is there a way to do this on Ubuntu 12.04?
-
1Yes this is possible, I quite forgot how. Let me get back to this.– Dr_BunsenDec 29, 2012 at 12:19
-
Cool. Hope u can work it out!– horIzoNDec 29, 2012 at 12:26
-
1This is kinda the answer you want. I will keep looking: webupd8.org/2011/01/…– Dr_BunsenDec 29, 2012 at 12:29
-
1I think you have to use terminal. But this looks even easier: ubuntuforums.org/showpost.php?p=11575559&postcount=2 What is the problem with terminal?– Dr_BunsenDec 29, 2012 at 12:32
-
2let us continue this discussion in chat– horIzoNDec 29, 2012 at 12:36
1 Answer
Ok, so I got this to work with xbindkeys.
We will use Beep as notification sound.
To install Beep:
sudo apt-get install beep
It is necessary to enable the speaker in recent versions.
modprobe pcspkr
Ok, now for the notification script:
First make a new file, and save it as notification.sh.
Insert this piece of script(smallest script ever?):
beep
and save it.
Place it somewhere safe, for this little "tut" I will place it in /home/notification/
Now we need xbindkeys:
sudo apt-get install xbindkeys
Once it is installed, go to your home folder, and make a new file named:".xbindkeysrc".
This file is required for xbindkeys, without, it doesn't function.
Open this file with a text editor.
Now we do need the keynumbers xbindkeys requires.
To get those, open terminal, and enter:
xbindkeys -k
A windows will popup, and then you are to press the key you want the code from, eg. Capslock.
You will see something like:
in $HOME/.xbindkeysrc to bind a key. "NoCommand"
m:0x2 + c:66
Caps_Lock
Now, we only need the m:0x2 + c:66
part(might be different for you).
Write those down(in a text editor or something) and repeat the process until you got all your keys.
Now, remember the xbindkeysrc we opened in the texteditor? We are going to add the following:
"bash /home/notification/notification.sh"
This line will tell what the xbindkeys has to do when certain keys are pressed. The next line we will add is the keycode(s), like this:
m:0x2 + c:66
if you want the same thing to happen with multiple keys, you must separate the keys, like this:
m:0x2 + c:66 || m:0x3 + c:67
The ||
means OR, this is not relevant for you.
A logout/login could be necessary to map the beep to the Caps Lock (for example).
I hope that this guide was useful for you and others.
-
1I use xbindkeys, and by installing
xbindkeys-config
as well asxbindkeys
there is no need forxbindkeysrc
...xbindkeysrc
provides an easy to use GUI interface. Setting up the shortcut keys is particularly easy; there is no need to deal directly with all the ` m:0x3 + c:67` stuff.xbindkeys
is also useful in that you have more control over the modifier keys than does the default Keyboard Shortcuts app, though that app is quite good enough unless you are a keyboard shortcuts junkie (like me).– Peter.ODec 29, 2012 at 15:03 -
O, I didn't know that, but I do prefer knowing that code is actually used. I will update my answer, thanks. Dec 29, 2012 at 15:37