GRUB
From ThorxWiki
(Difference between revisions)
(SESO) |
(+script) |
||
Line 26: | Line 26: | ||
− | TODO: I'd like to be able to convert a GRUB_INIT_TUNE line into a /usr/bin/beep commandline. Till then, there is this tip which converts via sox. |
+ | This tip which converts a GRUB_INIT_TUNE to a audio file which sox will play through the soundcard... |
− | |||
http://ubuntuforums.org/showthread.php?t=1739495 |
http://ubuntuforums.org/showthread.php?t=1739495 |
||
+ | |||
+ | Based on this script, I've concoted the following, which converts a GRUB_INIT_TUNE into a beep(1) command, to play it through the PC speaker - as grub intended. |
||
+ | |||
+ | <pre> |
||
+ | $ cat bin/grubtune2beep |
||
+ | #!/bin/bash |
||
+ | |||
+ | if [ $# -lt 3 ]; then |
||
+ | echo "Usage: $0 tempo freq dur [freq dur freq dur...]" >&2 |
||
+ | exit 1 |
||
+ | fi |
||
+ | |||
+ | tempo=$1; shift |
||
+ | |||
+ | while [ -n "$*" ]; do |
||
+ | freq=$1; shift |
||
+ | dur=$1; shift |
||
+ | dur=$((60000*$dur/$tempo)) |
||
+ | # ie, 60 (bpm) * 1000 (for milliseconds) * duration / tempo |
||
+ | BEEPOPTS="$BEEPOPTS $NEXT -f $freq -l $dur" |
||
+ | NEXT="-n" |
||
+ | done |
||
+ | |||
+ | beep $BEEPOPTS |
||
+ | </pre> |
Revision as of 17:09, 21 May 2012
Some GRUB_INIT_TUNE themes I've found online in various places... this is a fragment from my debian:/etc/default/grub file
# Uncomment to get a beep at grub start # The format unless a file is named is: "tempo [pitch1 duration1] [pitch2 duration2] ..." # Warning: The menu will not be displayed until the tone is finished #GRUB_INIT_TUNE="480 440 1" # Close Encounters/5 Tone: #GRUB_INIT_TUNE="480 900 2 1000 2 800 2 400 2 600 3" # Fur Elise (note long): #GRUB_INIT_TUNE="480 420 1 400 1 420 1 400 1 420 1 315 1 370 1 335 1 282 3 180 1 215 1 282 1 315 3 213 1 262 1 315 1 335 3 213 1 420 1 400 1 420 1 400 1 420 1 315 1 370 1 335 1 282 3 180 1 215 1 282 1 315 3 213 1 330 1 315 1 282 3" # Super Mario #GRUB_INIT_TUNE="1000 334 1 334 1 0 1 334 1 0 1 261 1 334 1 0 1 392 2 0 4 196 2" # Star Wars Imperial Death March: #GRUB_INIT_TUNE="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" # Wolfenstein 3D GRUB_INIT_TUNE="300 131 1 196 1 196 1 196 1 294 1 196 1 294 1 196 1 131 1"
This tip which converts a GRUB_INIT_TUNE to a audio file which sox will play through the soundcard...
http://ubuntuforums.org/showthread.php?t=1739495
Based on this script, I've concoted the following, which converts a GRUB_INIT_TUNE into a beep(1) command, to play it through the PC speaker - as grub intended.
$ cat bin/grubtune2beep #!/bin/bash if [ $# -lt 3 ]; then echo "Usage: $0 tempo freq dur [freq dur freq dur...]" >&2 exit 1 fi tempo=$1; shift while [ -n "$*" ]; do freq=$1; shift dur=$1; shift dur=$((60000*$dur/$tempo)) # ie, 60 (bpm) * 1000 (for milliseconds) * duration / tempo BEEPOPTS="$BEEPOPTS $NEXT -f $freq -l $dur" NEXT="-n" done beep $BEEPOPTS