Last Updated on Dec 26, 2022
Random Boot Sound Using Notification SoundsPreboot requires init.d. See the OP for enabling it if you are on a stock rooted ROM and requires the file to be readable and executable (“chmod 755” works fine).
Postboot requires an app such as Scripter (ROM Toolbox) or Script Manager to execute the script at boot.
Requires the variable $RANDOM. You can make sure it’s available from the command line (“echo $RANDOM”).
Use this script at your own risk. I provide no warranties or guarantees.
What does this script do?
- Check for carrier boot up sounds (sub folders in the “/system/media/audio/ui” folder) and copies them to “/system/media/audio/notifications” renaming them as needed.
- Create symlinks in the above folders to “/system/media/audio/ui/PowerOn.ogg”.
- Check if “/system/media/audio/notifications/PowerOn.ogg” is present and copies “/system/media/audio/ui/PowerOn.ogg” there if it’s not.
- Count the number of files in “/system/media/audio/notifications”.
- Grab a random number between 1 and the number of files found inclusive (math notation: “[1, numFiles]”).
- Go through “/system/media/audio/notifications” and copy the file at index random to “/system/media/audio/ui/PowerOn.ogg”.
Notes:
- The stock file is included. If you want a different sound in its place, you can either comment out that line in the script and delete the “/system/media/audio/notifications/_PowerOn.ogg” files from “/system/media/audio/notifications” or just replace “/system/media/audio/notifications/PowerOn.ogg” with some other sound file and still delete the “/system/media/audio/notifications/_PowerOn.ogg” files from “/system/media/audio/notifications”.
- If you want more sounds, just copy them to “/system/media/audio/notifications” (OGG files only).
- The script does not check for valid files and blindly renames the destination file to “PowerOn.ogg”.
- It does not look in “/sdcard/media/audio/notifications” or anywhere else for audio files.
- I do not recommend using alarms or ringtones files as they are usually looped which can cause the media scanner to get stuck and overheat your phone or tablet – those files may continue to play even if you can’t hear them.
- If you can’t hear a sound on boot, it is likely that the file is either invalid or has no audio (ex: my /system/media/audio/ui/BST/PowerOn.ogg has no audio).
- It was tested and works on a Samsung Galaxy S2 (stock JB 4.1.2) and a Samsung Galaxy S4 (stock JB 4.2.2) both from Sprint and using stock kernels.
- There’s no obvious reason it won’t work on other phones and tablets with other ROMs from other carriers.
#!/system/bin/sh mount -o remount,rw /system cd /system/media/audio/ui for X in "BST" "SPR" "VMU" "XAS"; do if [ $(realpath "/system/media/audio/ui/$X/PowerOn.ogg") = "/system/media/audio/ui/$X/PowerOn.ogg" ]; then mv "/system/media/audio/ui/$X/PowerOn.ogg" "/system/media/audio/notifications/${X}_PowerOn.ogg" ln -s "/system/media/audio/ui/PowerOn.ogg" "/system/media/audio/ui/$X/PowerOn.ogg" fi done if [ ! -f "/system/media/audio/notifications/PowerOn.ogg" ]; then cp "/system/media/audio/ui/PowerOn.ogg" "/system/media/audio/notifications/PowerOn.ogg"; chmod 644 "/system/media/audio/notifications/PowerOn.ogg" fi cd /system/media/audio/notifications FILES=0 for Y in *; do let FILES=$FILES+1; done let X=$RANDOM%$FILES let X=$X+1 FILES=0 for Y in *; do let FILES=$FILES+1; if [ $FILES = $X ]; then cp "/system/media/audio/notifications/$Y" "/system/media/audio/ui/PowerOn.ogg"; chmod 644 "/system/media/audio/ui/PowerOn.ogg" fi done mount -o remount,ro /system