I got a cool sound from linux defender or knoppix (or something else, I dont remember which one) that says "initiating start up sequence" And I want to use it as early as I can in the boot process. Having it say that when I login wouldnt make much sense, so having it play when GRUB starts would be best. Can it be done?
How
In the file
/etc/default/grub
, set the variableGRUB_INIT_TUNE
to the tune you want.For instance:
GRUB_INIT_TUNE="2000 400 4 0 1 500 4 0 1 600 4 0 1 800 6"
Once done, apply your changes with
sudo update-grub2
.Existing tunes
(The ones I could find)
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
480 440 4 440 4 440 4 349 3 523 1 440 4 349 3 523 1 440 8 659 4 659 4 659 4 698 3 523 1 415 4 349 3 523 1 440 8
2000 400 4 0 1 500 4 0 1 600 4 0 1 800 6
480 220 1 277 1 330 1 440 1 185 1 220 1 277 1 370 1 294 1 370 1 440 1 587 1 330 1 415 1 494 1 659 1
More of them here.
Understand a tune
The syntax is:
GRUB_INIT_TUNE="
tempo [pitch1 duration1] [pitch2 duration2] ...
"
Source: the grub documentation, the grub play command documentation (same page).
Preview / test a tune
If you want to test the tune: Install
sox
and use the script from that ubuntuforum.org thread (slightly modified by me to remove warnings):grub-playtune
To make it executable
chmod +x grub-playtune
Use example:
Frequency of a note
A python3-based script to compute the frequency of a note:
pitch
Use examples:
Frequency table
One is available here. It can also be generated, using the above script like so:
According to the GRUB manual, the first note is a 'tempo', and each following pair of numbers are duration and pitch.
The pitch is in Hz, so in order to play nice-sounding notes (which are in tune), you'll need the frequencies of notes in the western equal temperament scale:
http://pastebin.com/rJY30FmM
Incidentally, here's what I came up with after writing and using the Java code I pasted:
This plays an 4-note arpeggio of A, F#m, D, E.
Edit file
/etc/default/grub
to include following line (Here is my init tune):GRUB_INIT_TUNE="2000 400 4 0 1 500 4 0 1 600 4 0 1 800 6"
Run
sudo update-grub2
to apply the change.You ask, Can it be done? The simple answer? Yes, apparently. How can it be done? You need to put more money in the slot for that answer. Just my little joke. The best that I can do is this:
The GRUB manual
Go to section 5.1 Simple Configuration Handling and look for the line, GRUB_INIT_TUNE. You will need to follow the links to Play and File name syntax. You will have manually edit a Grub file.
I created a python script that converts midi files to these init tunes:
https://gitlab.com/lukasfink1/midi2grub
It needs the mido library to run. Also note that the grub play command is only able to play monophonic melodies, so your midis might sound strange if they aren’t.