Would it be possible for my PC to play music while it boots?
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Would it be possible for my PC to play music while it boots?
Just wondering. I thought it would be a cool feature to get a small chip-tune sounding song (think early video games) when my PC boots. How would I go about doing that?
Is there any way I can edit the order in which everything boots so that the first thing it does is start mpd, anything mpd needs to run, and start a song?
Theoretically maybe something could be done through the BIOS when it boots up, and have it output to the PC-Speaker only. It would probably too complicated and maybe not even feasible to output direct to the sound card itself, because each soundcard is different, and holding instructions for every single soundcard on a BIOS just doesn't seem like a good idea. Still, even if it were done, you most likely would have to wait until the song is finished before the rest of the boot process is started. When a computer starts up, it goes throw each piece of hardware at a time: Checking for CPU, memory, keyboard, etc. It would probably just end up in really long booting times.
I don't see any real feasible way of doing this at all.
[edit]
I think this thread should be in General. Nothing really to do with Slackware.
how about at the log-in prompt? Would it be possible to run a command right before asking for a log-in?
And I when I use mpd after typing in the command to play the song there is a second delay while it starts the song before I get another command prompt waiting for a command. So I don't think it will wait until the song is done.
Possibly. At that point the drivers for the soundcard would have been loaded, its just a matter of having a script executed at that point, probably after a user has logged in though.
hm, so there is no way to add commands to the boot script before the log in? What if I wanted it to execute a clear command or something like that, so that the login prompt appears at the top of the screen, instead of under the boot texts. would that be possible?
You can add scripts before the login, thats how a lot of things get loaded before a user even logs in, say like a printer server, the volume settings, permissions, etc. You can execute a simple clear command. If you are booting in user runlevel 3, edit the rc.S file, and issue a simple 'clear' command somewhere near the end of that file.
Can't help with the music, but I can with the clear command. I modified /etc/issue so at the login prompt the screen is first cleared. Using nano it looks like this:
Code:
^[[H^[[2J
Welcome to \s \r (\l)
^[[01;34mSlackware 12^[[00m
but the "^[" are special characters; you can't just type them in like that (sadly, I forgot how I input them). The stuff around "Slackware 12" makes the text blue, and then resets the color to white. If you're willing to create the file in a hex editor here it is:
Putting a command in rc.local would be easy enough and non-intrusive. You could have something running a little while before that, but it would require hacking the init scripts and would slow things down. rc.locala is the last thing run just before login, so it wouldn't slow things down. Playing something at that point would be a handy way of letting you know its' time to login if you are off in another room (making coffee?) while your computer starts up.
I have tried this and it didn't work on my copy of 10.2, why not I have no clue, it is bash correct but oddly it doesn't work.
Code:
#!/bin/sh
#
# /etc/rc.d/rc.local: Local system initialization script.
#
# Put any local setup commands in here:
# Start APC UPS daemon:
if [ -x /etc/rc.d/rc.apcupsd ]; then
. /etc/rc.d/rc.apcupsd start
fi
# Play Power on noise:
echo "Playing power on noise"
. /usr/bin/amp -q /usr/share/apcupsd/please_login.mp3 & >/dev/null
I've tried with the '.' and without the '.' and I've tried with and without the '>/dev/null' I've tried amp and mpg321 (yes, I even set output to alsa) to no avail.
an odd side note is that the echo command right before doesn't show up either, but acpupsd starts... so it isn't like rc.local isn't being run.
Maybe some one could shine some light on this.
nekkutta
Last edited by nekkutta; 03-06-2008 at 08:52 AM.
Reason: add'l info
thanks for the help, tried your suggestion and it still didn't work, so I really started looking at what was happening, moved the amp command before my UPS script and it worked fine, for some reason the UPS script had an exit 0 at the end of it. grrr.... so I commented it out and it works perfectly now
I've been doing this sort of thing for years. I keep all my custom System sounds at /opt/SysSounds. To play a quick diddy at the end of boot up I call up an audio player in /etc/rc.d/rc.local (as already has been mentioned). However, I also add a line to restore the sound device volume settings just before doing this. I do this because I've seen rc.alsa not do its job correctly before. So, I always add a alsactl restore or a aumix -L just to make sure the volume is up. It doesn't slow down the boot really, so there's not any real cost.
This is a simplified version, but you can also check for errors before attempting to play the sound, and you can also check to see if the alsa settings are up instead of just restoring them (possibly a second time). If you omit a quiet option (-q for amp) then you might want to catch output in /dev/null as shown previously.
Code:
/usr/sbin/alsactl restore
if [ -r /opt/SysSounds/firstblood.mp3 ]
then
/usr/bin/amp -q /opt/SysSounds/firstblood.mp3 &
fi
I also have a sound played when my user logs out of a shell. Just add an executable script like this to your home directory
.bash_logout
Code:
echo "See ya later!"
if [ -r /opt/SysSounds/byebye.mp3 ]
then
/usr/bin/amp -q /opt/SysSounds/byebye.mp3 &
fi
By the way, in case anyone is wondering what mp3's those are, I made them from some of the sounds samples in Worms Armageddon. Those particular two are from the "Soul man" voice.
As far as modifying init scripts for listening to music during the boot: You can pretty much do this as soon as your sound device is configured, but unless you have some slow start up times for things like MySQL, Apache, Samba, etc then it isn't really worth it. One thing that might be useful is to start a music daemon that you can control from the command line. Supposedly audacious's headless mode is supposed to do this, but in my experience you cannot start it until after X is started. You could just use the find command and amp to play a bunch of music daemon style, but it wouldn't give you the control that something like xmms/audacious's headless mode has.
Another related application that can involve modifying init scripts is having a music mode for your computer. I have also done this for a very long time and it works great. I created special boot variables that makes the computer boot into single user mode and skips a lot of unnecessary stuff and then starts herrie (an ncurses audio/playlist player) in chroot mode. Once you quit herrie the login prompt shows. A quick telinit and you can be back at the normal runlevel, or you can give the three finger salute to shutdown. It's quite simple and allows me to listen to music on my computer from boot to music in only a few seconds.
I've been meaning to start a thread on this but just haven't done so yet. I'll have to get on that...I guess part of the reason I haven't is that I have not seen much interest for it. Most people just use a dedicated mp3 player nowadays.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.