Contents
Have you ever thought to yourself, “Hey, wouldn’t it be awesome to add really annoying sound to my Linux application launchers?” Yeah, this happened to me the other day. But rather than keep this to myself, I decided to show you how to do the add fun sound effects to application launches and even demonstrate to make each keypress sound like a real electric typewriter.
It’s time for typewriter-sounds
I hunted high and low for a duplicable way to make my typing feel a bit more…retro. As luck would have it, there was a Github project that fit the bill perfectly. The project is accurately named typewriter-sounds and it’s fantastic!
One of the first big takeaways I loved about it was that it seemed to work with my currently-installed python libraries. Nothing ticks me off faster than playing musical libraries – this app gets it right and just works with what you have. The one thing you will need to make sure you have installed, however, is PyGame. Ubuntu-based distros can install this easily:
sudo apt install python-pygame
(Nope, this isn’t a typo)
With this installed, the next step is to get the typewriter software downloaded from Github. You can do this one of two ways. I recommend using the following method.
First, let’s install git.
sudo apt install git
Now let’s clone this bad-boy. This approach will provide you with a working directory to run your program with a single command.
git clone https://github.com/aizquier/typewriter-sounds.git
Now, let’s run the program in the background. Adding ‘&’ will allow us to close the terminal without killing the program.
python typewriter_sounds.py &
Now, simply type exit to safely close the terminal without killing the program.
Uh, great…now make it STOP!
Stopping this program is super simple. You can either restart your PC or simply stop the process in its place. This can be done visually using the System Monitor or instead, via htop.
First, let’s make sure you have htop installed.
sudo apt install htop
Now type the htop command into a terminal:
htop
This will bring up your processes just like System Monitor would. Here’s where htop makes itself really stand out – filtering and killing processes. Back in the terminal, press F4 for filtering. Next, type out typewriter and hit enter.
Now the fun part. Let’s kill this process where it stands. With either of the two processes highlighted (there will likely be two), press the F9 key then hit enter. Done. You killed it. That’s right, it’s dead Jim.
Let’s make annoying sounds for your application launchers
See those icons on your desktop? Odds are, most of those are icons designed to launch specifically-assigned applications. The good news is most modern installations have all of the software components needed needed to add sound effects to specific application launchers.
What you’ll need:
- A text editor.
- Knowledge of where your application’s executable is located; ie, /usr/bin/blah or /opt/blah.
- Familiarity with the cd command in the terminal (cd /whatever).
Now in my case, I’m running audio effects for Vivaldi, Firefox and Google Play Music Desktop Player.
Because the process is all the same regardless of the launcher or the app, I’m only going to break this down for a single application. For my example, I’ll be using Vivaldi.
Crack up your text editor, and follow along closely.
#!/bin/bash /usr/bin/aplay /home/matt/Warp.wav & AUDIO=$! /usr/bin/vivaldi-beta & CHROMEWANNABE=$! wait $AUDIO wait $CHROMEWANNABE
Did you know: A few things to note here. First, we’re setting this up so the audio plays at the same time as the launch of the application. Normally, processes within a script like this run in order. So without adding “wait”, we’d have audio playing using the aplay command…then Vivialdi would run. Pretty weak, right? So by using the above approach, your audio will run in unison with Vivialdi’s launch. The terms AUDIO and CHROMEWANNABE can be whatever you like. I chose these just for fun. Also, the caps are just for visability. Lower case letters are fine. Just make sure the commands match from the first line to the “wait” line with each example.
First step is to make sure your have your application path set as you want it. You’ll want to do the same for your sound file.
Note: Use a wav file and not an mp3. Even with the right codecs installed, wavs simply work better. Now save the file, naming it something like Vivialdiscript or whatever. You will not need to add a dot sh to it. This is a dated misconception and while it won’t hurt, it serves no purpose here.
Now we’re ready to make it executable. The easiest way is from the command line. Change into the directory storing the file and…
chmod +x Vivialdiscript
Awesome – now the script is ready and we’re ready to annoy any poor souls who have the misfortune of sharing office space with us. Test the file like this.
After making sure you’ve changed directory to the script directory:
sh Vivialdiscript
This will play your path-assigned audio file while launching the assigned application. And by testing this in the terminal, we’re able to see any path issues or related errors.
Let there be application launchers!
Now that we have a working script, let’s create a working launcher for said script. Remember, ideally we’re trying to create a launcher that feels native to our desktops.
Let’s open up our text editor again, new document. For Vivialdi, my launcher is going to look like this.
#!/usr/bin/env xdg-open [Desktop Entry] Type=Application Terminal=false Exec=/home/user/Vivialdiscript Name=Vivialdi Icon=vivaldi-beta
Did you know:You can use this method to create any desktop launcher you like! The only stuff you need to make sure are correct are the Type, Exec path, and Icon. With regard to icon, you can also use the icon path if you don’t know the actual reference for it otherwise. So if the icon you wanted was in your home, your might do Icon=/home/user/icon.png or you can browse through other available icons in /usr/share/icons instead.
The next step is to save the file as a .desktop file and its executable. Name it whatever you like. Do this by changing into the proper directory in your terminal:
chmod +x Vivialdi-sound.desktop
Now the file is executable – double click it and be amazed! Congrats, you now know how to make annoying sound effects for your Linux desktop application launchers.
Pro tip: There is nothing stopping you from taking this to the next level.
Pranks on friends? Audio alert for browser, “Come over here everyone! Philbert is about to open up his creepy browser stash!” This is a huge hit at most offices.
Complete an existing desktop theme? Add various sound effects for different applications that match your wallpaper and icons. The possibilities are endless. Firefly, Marvel, Star Wars, Star Trek – the list is endless.
Auto-start the typewriter effects!
I avoided mentioning this previously because for most people, this will be something you want to manually run. That said, if you “must” have the typewriter sounds enable on each boot, you only need run python typewriter_sounds.py & as a startup option.
On any worthwhile distro, you’ll have a Startup Applications Preferences like option. Simply create and add this script:
#!/bin/bash sleep 25 cd ~/typewriter-sounds python typewriter_sounds.py &
Save it as something like typewriter. Then make it executable. Yes, you MUST cd to the directory…otherwise it will not run correctly.
chmod +x typewriter
Add the full path to the script in your startup tool (assuming something like Startup Applications Preferences). You could also use a launcher (sans audio effects) to make it easier to run python typewriter_sounds.py &, but that’s up to you. Since this is path-dependent, it might be best to script this too and then add it to your system’s start up.
Save and you’re all set!
Troubleshooting
Won’t launch? Test the script in a terminal first, as described above.
If it’s the launcher, not the script that won’t launch, make sure your desktop file is executable as described above.
The audio sound won’t play. First, test out the audio file using aplay in the terminal.
aplay /path/to/audio.wav
This should provide Playing WAVE ‘/path/to/audio.wav’ ending in a return to a normal command script. If you still hear no audio, then do the following.
sudo apt install pavucontrol
Once installed, run pavucontrol, open up the Playback tab.
Back in a terminal, with pavucontrol still visible.
aplay /path/to/audio.wav
Did you see the ALSA plugin for aplay appear? Did you make sure it was using the right audio device? If the audio was too short for you to see it, aplay a longer wav file and adjust the playback device pulldown option accordingly.
Awesome to hear! 🙂