Sunday, January 29, 2006

Taming Ubuntu (MPlayer and simple SMTP sender)

I did it. Today I reistalled my computer and "upgraded" from Debian to Ubuntu. It was partly because of the fact that after pressing shift-U for "update" in aptitude, it suggested to download and install 7 gigabytes of packages, most of which I never intended to use! Also, I wanted to try something different. So, instead of investigating why aptitude went crazy, I installed Ubuntu. The installation went without a hitch (I only backed up my /home/fuxoft/ directory), there were no serious problems with supporting my US Robotics WiFi card, SoundBlaster Live and NVidia hardware acceleration. However I had to tweak a few config files here and there and an absolute beginner probably wouldn't have 3D acceleration and volume control working without outside help (more about this later).

So far, everything I used before (in Debian) works well in Ubuntu (which really shouldn't be any surprise). The only problem was with getting MPlayer to work correctly and integrate it with Mozilla Firefox. But it's really simple once you know what you are doing.

First, install the standard Ubuntu MPlayer and "MPlayer fonts" package. Then, try playing some movies (and change the default application for the video file types to mplayer, the original default player is something called "Totem" which really didn't impress me). You will notice that quite a few movies cannot be played using MPlayer (especially Windows Media or Quicktime). But we can sort it out. Now, visit MPlayer homepage, download "essential codecs package" (or, "all codecs", just to be sure) and unpack all the files from it into /usr/local/lib/win32/ directory (you'll probably have to create it). Then, try playing the "problematic" videos again. If they still don't work, try renaming the "win32" directory to "codecs".

And now, for the Firefox integration. Close Firefox, install Ubuntu package "mozilla-mplayer", restart Firefox and try if embedded videos (for example on are played back by MPlayer. If they are, great, you are done. If they aren't, and Totem still wants to play them, go to /usr/lib/mozilla-firefox/plugins/ directory and erase all files that have "totem" in their name (two in my case). Also, there should be bunch of mplayer files in here at this stage. If they are not, you forgot to install "mozilla-mplayer" package. And that's all.

This was so far the biggest Ubuntu hurdle I had to overcome. The reason why this isn't simpler is probably because of legal reasons - you simply cannot distribute proprietary Windows codecs through the official Ubuntu distribution mechanism. I figured all of this out without much problems but it just shows that, as much as I love Linux, it still isn't quite ready for the "average Joe" users, unless someone with more expertise helps them with the basic configuration.

However, I have one small problem: I know there are several Linux apps to send photos to but I preferred my own simple script which took all the JPGs in given directory and sent them, one after another, as e-mail attachments to my flickr uploader e-mail address. However, I had to install exim4 mail transfer system and configure this monumental beast just for this simple script to work. I'd like to use some really simple tool to turn JPGs into mail attachments and to send them as e-mails, but is has to be done one after another, i.e. the script must wait until the first e-mail is completely sent and only then start sending the second e-mail. This is necessary to prevent traffic congestion (my upload is not very fast) and to keep the uploaded pictures in the right order. Does anyone have any suggestions about this? Otherwise, I'll probably have to either install and configure exim4 or to write a script using Ruby and its SMTP library...

UPDATE: Solved beautifully using ssmtp and mutt. Thanks to anonymous tip. After you install them (and configure ssmtp, which is trivial), you can use the following simple script to send all files from the current dir to Flickr. Note that the script in its current form deletes the files as it sends them! Also note I am not very good with Bash...

#cd /home/fuxoft/upload
du -h
echo "ENTER to send all"
read DUMMY
echo "" > $BODY
for PIC in *
ls "$PIC" -sh
mutt -s "$PIC" $EMAIL -a "$PIC" < $BODY && rm "$PIC"
echo `ls|wc -l` remaining


Anonymous said...

Replace exim with ssmtp ( -- it's just a simple forwarded that pretends to be an MTA on your system but all it does is that it sends the mails to upstream SMTP server.

Anonymous said...

For some basic yet quite useful tips on Ubuntu, check (if you haven't done so already). For example the trouble with codecs is mentioned there, with a solution, as well as many other basic things. It's a little outdated now, based on 5.04 instead of 5.10, but mostly it's just a matter of repositories being different for Breezy Badger (which at least in the case of the official ones just means replacing 'hoary' with 'breezy'). Definitely well worth a look, this guide.

And of course, there are great official forums at

Anonymous said...

Just one tip for the "average Joe" who I am, I'm afraid :-).

Automatix is the right word - this system (automated script) will do all the fuzz you'd need taming Ubuntu for you. mp3 and other formats, new Firefox 1.5, mplayer with everything and many more. Uses apt and ftp only I guess.

The only "problem" you can have, it replaces your own apt sources list (makes backup of course). If problem, don't forget to replace with your previous to get your individual repositories to work.

Versions for Ubuntu, Kubuntu and Edubuntu available - search for detailed info.

Anonymous said...

Lyrically speaking, touch $BODY instead of echo "" > $BODY. :-)

František Fuka said...

jirka pech: But "touch" only changes the timestamp so it won't work as expected if the file already exists and is not empty. Or not?

Anonymous said...

Franta: You're right. But it's the script's responsibility to remove all temporary files (the $BODY in your case) before it ends. :-)

Anonymous said...