I know that sounds like a weird idea, but I kinda want to experiment with this.
Over the past few months, I've kinda turned Ubuntu into my own little Frankenstein's monster, but whatever you tell me should still work.
I know that sounds like a weird idea, but I kinda want to experiment with this.
Over the past few months, I've kinda turned Ubuntu into my own little Frankenstein's monster, but whatever you tell me should still work.
Hm, quite a hacky solution, but it works! First of all install the following things:
sudo apt-get install xmacro expect mpg321
xmacro
is the program that will detect your mouse clicks.
expect
is the program that will listen to the output of xmacro
for your mouse clicks so as to execute mpg321
, which is a command line player!
So, run this script from inside a terminal:
#!/usr/bin/expect -f
spawn xmacrorec2
while { 1 } {
expect "ButtonRelease 1"
system mpg321 /home/alex/Music/notification/notification.mp3&
}
When you execute the above script (I repeat, through a terminal) you will be asked for an input key. Give an unusual key (e.g. F7), this will be the key that, no matter when you press it, it will stop this process from going on.
So, just, inside the above script, set mpg321 to a valid mp3 file of yours and test it :)
It works just fine under Ubuntu 12.04 but I have used all of these 3 tools under Oneiric without a problem!
xmacrorec2
may take as argument the expected key (-k argument) as a kei code. This helps you a lot if you want to put the above script to your startup applications, because it will not ask for an input key each time. In order to find the appropriate key code that you want to use, you have to install the tiny program xbindkeys
:
sudo apt-get install xbindkeys
Then do:
touch ~/.xbindkeysrc
xbindkeys -k
After the last command, a small window will appear, without doing anything to it, give it a keyboard input, let's say F7. You will see something like this:
You can use one of the two lines after "NoCommand"
in $HOME/.xbindkeysrc to bind a key.
"(Scheme function)"
m:0x0 + c:73
F7
Notice the line:
m:0x0 + c:73
The code 73
is the one expected by xmacrorec2. So, you can add to the above script a -k argument, like this: spawn xmacrorec2 -k 73
and it will automatically start. After you have finished editing the script, save it to a stable directory (I mean a directory you will not delete/move to the close future), like ~/Documents and give it executable permissions (right click on it->Properties->Permissions->Allow executing file as program, or, through the terminal, chmod +x script_name.sh
). Then, simply add your script to your Startup Applications. Of course, whenever you want this sound to stop, you will have to give the corresponding keyboard input, like F7
.
PS: If you don't want to install an extra command line mp3 player (like mpg321
), then you may use the pre-installed player canberra-gtk-play
, which is used as
canberra-gtk-play -f music.wav
The disadvantage of it is that it can only play certain ogg and wav files.
-f
in the beginning and thespawn
command? – Lucio Aug 19 '12 at 00:38man expect
) guided me so as what to be my 1st line of the script. Another pre-installed command line player iscanberra-gtk-play
and can be called ascanberra-gtk-play -f file.ogg
. The con of this program is that it can only play certain ogg and wav files only. – hytromo Aug 19 '12 at 08:37mpg321
) and copy your code into a bash file. It works provided that I run it on the terminal. There is somethings like run on any boot and add a GUI but it's for testing purposes. Thank you! – Lucio Aug 20 '12 at 00:15