Can I make my Ubuntu make sounds when I press Caps Lock etc.?
Solution 1:
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.