Skip to Content

Nostromo boot noise

Posted on

some-image

Add sound effects to the Linux boot sequence.

Let’s go!

Alien (1979) is one of my favourite movies. At the beginning of the movie, the spaceship Nostromo’s computer boots up in a burst of blinks and noise. Inspired by this Alien-themed Linux greeting card, I create a short clip of that boot noise that plays when sound becomes available during the Linux boot sequence!

Steps:

0. Use youtube-dl to extract audio (requires ffmpeg for WAV conversion) from this sound effects clip on YouTube.

$ youtube-dl --extract-audio --audio-format wav --audio-quality 0 --restrict-filenames https://youtu.be/2ywWFvjE-yU

1. Copy the first 25 seconds from the original WAV file (example: input.wav) to make a new sound clip (example: bootsound.wav) …

$ ffmpeg -i input.wav -ss 00:00:01 -to 00:00:25 -c copy bootsound.wav

Save bootsound.wav to /usr/local/share.

2. Identify the sound card(s). In this instance, my laptop shows two sound card interfaces …

$ cat /proc/asound/cards
 0 [HDMI           ]: HDA-Intel - HDA Intel HDMI
                      HDA Intel HDMI at 0xe0510000 irq 45
 1 [PCH            ]: HDA-Intel - HDA Intel PCH
                      HDA Intel PCH at 0xe0514000 irq 43

I am configuring the internal speakers (card1 - PCH). Output the systemd device unit for this sound card …

$ systemctl list-units | awk '/sound-card1/{print $1}'
sys-devices-pci0000:00-0000:00:1b.0-sound-card1.device

3. Create a shell script (example: bootsound) that plays the clip …

#!/bin/sh
#
# bootsound - play sound at boot via bootsound.service

# card1 is '-c 1'
amixer -c 1 sset Master unmute
amixer -c 1 sset Master playback 100%
# card1 is 'plughw:1,0
/usr/bin/aplay -D plughw:1,0 /usr/local/share/bootsound.wav

Make the script executable, and save to /usr/local/bin.

4. Create a systemd unit file (example: /etc/systemd/system/bootsound.service) to run the shell script as soon as the sound card becomes available

[Unit]
Description=Boot Sound
Requires=sys-devices-pci0000:00-0000:00:1b.0-sound-card1.device
After=sys-devices-pci0000:00-0000:00:1b.0-sound-card1.device

[Service]
Type=oneshot
RemainAfterExit=no
ExecStart=/usr/local/bin/bootsound

[Install]
WantedBy=default.target

Enable unit file …

$ sudo systemctl enable bootsound.service

Reboot and hear the glorious cacophony of a Nostromo boot!

Happy hacking! 🐧