October 2008 Archives
Tue Oct 21 01:11:21 UTC 2008
Dedicate an Ubuntu console to music playback
My good speakers are hooked up to an old server machine, which presents through a nice small 15" LCD monitor on the desk.
The server doesn't run a GUI of course, so I do music playback from the commandline with programs like mpg123 and mp3blaster.
I decided to dedicate the first text console to playback, so I needed to replace the login prompt with the mp3blaster program. I hadn't noticed that Ubuntu no longer has an /etc/inittab file, because it has switched to the more flexible Upstart system, so it took a few minuted to find out how to get this set up.
Hacking on Upstart
The first port of call is the /etc/event.d/tty1 file, which by default is running getty for us. I'm keeping getty (although other tty programs are out there and may do the job in a nicer way), so I need to ask it to run different “login” program, using the -n and -l options. Just for luck, I also set the TERM type explicitly.
getty doesn't like to send arguments to the login program, so I had to set up a small script to do the hard work. Make sure that the filesystem this script lives in is available when Upstart is started … however I suspect that Upstart is actually smart enough to figure this out :-)
/etc/event.d/tty1
# tty1 - getty # # This service maintains a getty on tty1 from the point the system is # started until it is shut down again. start on stopped rc2 start on stopped rc3 start on stopped rc4 start on stopped rc5 stop on runlevel 0 stop on runlevel 1 stop on runlevel 6 respawn #exec /sbin/getty 38400 tty1 exec /sbin/getty -n -l /usr/local/bin/jimp3 38400 tty1 linux
Next, the helper script; I need to invoke mp3blaster autostarting a playlist, but I also want it to run as my user, rather than root. Good old su is a simple way of achieving this.
/usr/local/bin/jimp3
#!/bin/sh /bin/su -c '/usr/bin/mp3blaster -a /home/jim/allmusic.lst' -- jim
Do NOT reboot!
No need to reboot the server to get this all running! Use the initctl command to find the ‘tty1’ job that is currently running a login shell, stop it and then restart it.
# initctl list control-alt-delete (stop) waiting logd (stop) waiting rc-default (stop) waiting rc0 (stop) waiting rc1 (stop) waiting rc2 (stop) waiting rc3 (stop) waiting rc4 (stop) waiting rc5 (stop) waiting rc6 (stop) waiting rcS (stop) waiting rcS-sulogin (stop) waiting sulogin (stop) waiting tty1 (start) running, process 5622 tty2 (start) running, process 4235 tty3 (start) running, process 4236 tty4 (start) running, process 4230 tty5 (start) running, process 4231 tty6 (start) running, process 4238
# initctl stop tty1 tty1 (stop) running, process 5622 tty1 (stop) pre-stop, (main) process 5622 tty1 (stop) stopping, process 5622 tty1 (stop) killed, process 5622 tty1 (stop) post-stop tty1 (stop) waiting
# initctl start tty1 tty1 (start) waiting tty1 (start) starting tty1 (start) pre-start tty1 (start) spawned, process 6469 tty1 (start) post-start, (main) process 6469 tty1 (start) running, process 6469
Job done! You should now have a copy of mp3blaster running on the first virtual console, playing your playlist for you, as your userid … and if you quit the program, it'll restart straight away.
Wed Oct 1 21:05:43 UTC 2008
The WindFire Cursor kite ...
Tim Elverston's latest kite appeals to the computer geek …
http://www.windfiredesigns.com/timbofolio_pages/PointerKite.html

He promises more to come in the OS series of kites …. probably Windows :-(