Skip to content

Instantly share code, notes, and snippets.

@MaxLaumeister
Last active November 3, 2024 16:21
Show Gist options
  • Save MaxLaumeister/f93717e91c8bd9d435a5 to your computer and use it in GitHub Desktop.
Save MaxLaumeister/f93717e91c8bd9d435a5 to your computer and use it in GitHub Desktop.
Grub Init Tune: Mario Bros. Mushroom Powerup

Grub Init Tune - Mario Bros. Mushroom Powerup

This Grub Init Tune will make your computer sound like a Super Mushroom every time you turn it on! This only works for the Grub bootloader - this generally means you need to have Linux (or other Grub-based OS) installed.

Here's the code, which goes in your /etc/default/grub file:

GRUB_INIT_TUNE="1750 523 1 392 1 523 1 659 1 784 1 1047 1 784 1 415 1 523 1 622 1 831 1 622 1 831 1 1046 1 1244 1 1661 1 1244 1 466 1 587 1 698 1 932 1 1195 1 1397 1 1865 1 1397 1"

Installation Instructions

Instructions adapted from https://web.archive.org/web/20150115050225/http://www.iavit.org/~john/debian/grub.html:

  1. Edit the file /etc/default/grub. At the end there are lines like the following:
    # Uncomment to get a beep at grub start
    # GRUB_INIT_TUNE="480 440 1"

  2. Replace the # GRUB_INIT_TUNE="480 440 1" line with the new GRUB_INIT_TUNE line at the top of this document (make sure to remove the "#" from the beginning of the line, as well). Save the file and exit your text editor. Open a terminal window and issue the following command: sudo update-grub

  3. Reboot. You should hear the init tune when the grub menu appears.

LICENSES

CC0 1.0 Universal; Public Domain

@smokey5787
Copy link

This is cool

@spitemim
Copy link

the link you posted now goes to a chinese porn site. consider replacing with https://web.archive.org/web/20150115050225/http://www.iavit.org/~john/debian/grub.html ;)

@MaxLaumeister
Copy link
Author

the link you posted now goes to a chinese porn site. consider replacing with https://web.archive.org/web/20150115050225/http://www.iavit.org/~john/debian/grub.html ;)

Very much appreciated.

@hasecilu
Copy link

hasecilu commented Feb 5, 2023

Here is a command ready to copy paste, (could be used in a post-install script): sudo sed -i 's/# GRUB_INIT_TUNE="480 440 1"/GRUB_INIT_TUNE="1750 523 1 392 1 523 1 659 1 784 1 1047 1 784 1 415 1 523 1 622 1 831 1 622 1 831 1 1046 1 1244 1 1661 1 1244 1 466 1 587 1 698 1 932 1 1195 1 1397 1 1865 1 1397 1"/g' /etc/default/grub && sudo update-grub
Note: some distros have #GRUB_INIT_TUNE (whithout space) instead of # GRUB_INIT_TUNE, in that case remove it from the command.

@wavapps
Copy link

wavapps commented Feb 17, 2024

If GRUB_INIT_TUNE=" is for power up, What is the code for playing a sound when shutting down?

@smonff
Copy link

smonff commented Feb 17, 2024

If GRUB_INIT_TUNE=" is for power up, What is the code for playing a sound when shutting down?

Grub is a bootloader. I am not sure that there is any equivalent as shutting down the computer won’t involve grub at all.

You should better search another way.

e.g running a script with systemd Before=shutdown.target

@linkstat
Copy link

linkstat commented Jun 7, 2024

If GRUB_INIT_TUNE=" is for power up, What is the code for playing a sound when shutting down?

Grub is a bootloader. I am not sure that there is any equivalent as shutting down the computer won’t involve grub at all.

You should better search another way.

e.g running a script with systemd Before=shutdown.target

You must create an script that "play" the tune, and the a systemd unit that trigger the script. For example, create a file /usr/local/bin/playtune.sh (and set eXecutable attributes), like this:

#!/bin/dash

if [ $# -lt 3 ]; then
    echo "Usage: $0 tempo freq dur [freq dur freq dur...]" >&2
    exit 1
fi

tempo=$1; shift

tmpdir=$(mktemp -d)

while [ -n "$*" ]; do
    freq=$1; shift
    dur=$1;  shift
    dur=$(echo "$dur*(60/$tempo)"|bc -l)
    sox -e mu-law -r 8000 -n -t raw - synth $dur sine $freq >>$tmpdir/grubtune.ul 2> /dev/null
done

play -q -c1 -r 8000 $tmpdir/grubtune.ul

rm -r $tmpdir

and then, create a systemd unit that run at system shutdown:

[Unit]
Description=Play shutdown tune

[Service]
Type=oneshot
RemainAfterExit=true
Environment="SHUTDOWNTUNE=1750 523 1 392 1 523 1 659 1 784 1 1047 1 784 1 415 1 523 1 622 1 831 1 622 1 831 1 1046 1 1244 1 1661 1 1244 1 466 1 587 1 698 1 932 1 1195 1 1397 1 1865 1 1397 1"
ExecStop=/usr/local/bin/playtune.sh $SHUTDOWNTUNE

[Install]
WantedBy=multi-user.target

Regards!

--
More tunes (and source of script) here: https://forums.linuxmint.com/viewtopic.php?t=174854.

@linkstat
Copy link

linkstat commented Jun 7, 2024

ah... by the way: you need the sox package, for the script to work.
On systems that use apt:
apt -y install sox

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment