Translate

Saturday 19 November 2011

Creating m3u playlists on the Sansa clip+ player in Linux

The Sansa clip+ player is an excellent audio player which works very well under Linux. m3u playlists can easily be created and this blog post describes some simple  ways of doing this. All that's required is to create a list of audio files which is saved to the Clip's MUSIC directory in a file with an .m3u extension.  

The first technique uses a custom action in the Thunar file manager. The player needs to be in MSC mode which is set on the player itself:  Settings => System settings => USB mode => MSC). Now you need to configure a custom action in Thunar. From the Edit menu in Thunar select Configure custom actions... Click on the + icon to add a new action and in the Name field enter Create a Sansa clip playlist. Don't worry about the Description field but in the command field enter:

ls %N > playlist.m3u

Now select the Appearance conditions tab, make sure there is an asterisk (*) in the File pattern field and that Audio files is checked. 

To create a playlist, the player needs to be mounted in Linux. Under Gnome this happens automatically on my system (currently OpenSuse 11.4) but I prefer the Fluxbox window manager and use the wmvolman dockapp to mount the player manually. In Thunar, navigate to the MUSIC directory (on my system for the Sansa clip's internal memory this is /media/0123-4567/MUSIC) and CTRL+Click to select the files which will make up the playlist. Next, right click and you should see an option to use your custom action: Create a Sansa clip playlist. Select this menu, and a file called playlist.m3u will appear in the same directory. This is an m3u playlist which should be usable on your Sansa Clip+. It's useful to rename the file, since it will be overwritten next time you run the script.

I ran into problems when I tried to delete playlists in Thunar, because it places the files in a Trash folder which I couldn't delete permanently. I therefore delete the playlists from the command line but Nautilus works as well.   

Another (and more flexible) way to create playlists on the Sansa Clip+ is to use the kid3 KDE ID3 tag editor. Under Suse, install the package using: sudo zypper install kid3-qt. With the Sansa clip mounted, open the MUSIC directory on the player in kid3 (File => open directory) and CNTRL+click to select multiple files. Now click on the Create playlist item. In the Format field you can use any name for the playlist as well as ID3 tags.  Make sure you use the following options:    
  • Create in: current directory
  • Format: m3u
  • Include only the selected files
  • Use relative path for files in playlist
  • Write only list of files
One advantage of kid3 is that you can create playlists based on strings in the filename or in the ID3 tags. First, in kid3 open the MUSIC directory on the Sansa Clip.  Now Select the menu option Tools then Filter... Now set up a custom filter. All the variables you can use (filename, duration etc.) are displayed if you hover over the dialog box for the filter itself. As an example, the following filter selects filenames which contain the string "Elgar":

%{file} contains "Elgar"

You can now create a playlist which contains only those files.            

    Sunday 15 May 2011

    Relacing a bootable disk which has a root partition (Suse Linux)

    This weekend I replace an old IDE bootable hard disk containing a Suse Linux partition with a new Sata disk.

    First stage was to clone the old disk using dd:

    dd if=/dev/sdb of=/dev/sda

    Where /dev/sdb is my old hard disk (the input file) and /dev/sda (the output file) is the new hard disk.  This took a few hours on a 120GB disk but is reported to be faster if you specify the block size in the dd options. However, the clone operation worked fine.

    Having rebooted, I didn't initially realise that the Grub bootloader configuration would now be out of date and that the machine would continue to boot from the old hard disk. It is not possible to reassign the root partition in Yast, but there are some useful instructions on this site on how to do a fresh install of Grub onto a new disk.

    Following these instructions, I first created a directory where the cloned root partition on the new disk could be mounted:

    mkdir /mnt/new

    Next I mounted the cloned root partition:

    /mount /dev/sda6 /mnt/new

    Next, to bind /dev to the cloned partition:

    mount --bind /dev /mnt/new/dev

    and then chroot into the new partition:

    chroot /mnt/new

    Now for a fresh install of Grub onto the cloned disk:

    grub-install.unsupported /dev/sda    

    The grub-install.unsupported command has to be used (rather than just grub-install) because Suse prefers you to use Yast for bootloader configuration. However, when I tried this, neither yast2 (the graphical interface) or yast (the character-based interface) worked within the chroot jail.

    A reboot still gave the original result (i.e. the machine booted from the old disk) so the next stage was to edit the Grub bootloader configuration files.

    First (and working within the chroot jail on the cloned partition), the new disk has to be entered into the /boot/grub/device.map file. Since I had two old IDE disks in the PC, there were two existing lines in the device.map file:

    (hd0)  /dev/disk/by-id/ata-[device_ID of first hard disk]
    (hd1)  /dev/disk/by-id/ata-[device_ID of second hard disk]

    I added a third line for the next hard disk starting (hd2). If you don't know the disk ID, you can check it in the Yast2 bootloader configuration to copy the disk ID from there.

    A reboot confirmed that Grub was happy with the new disk in the device.map file, so I created a new menu entry in the /boot/grub/menu.lst file. My original menu.lst file looked like this:

    # Modified by YaST2. Last modification on Tue Mar  1 15:19:29\
    # GMT 2011
    # THIS FILE WILL BE PARTIALLY OVERWRITTEN by perl-Bootloader
    # Configure custom boot parameters for updated kernels in
    # /etc/sysconfig/bootloader

    default 0
    timeout 8
    ##YaST - generic_mbr
    gfxmenu (hd0,5)/boot/message
    ##YaST - activate

    ###Don't change this comment - YaST2 identifier: Original
    ###name: linux
    title Desktop -- openSUSE 11.3 - 2.6.34.7-0.7
        root (hd0,5)
        kernel /boot/vmlinuz-2.6.34.7-0.7-desktop \
    root=/dev/disk/by-id/ata-[old disk_ID]-part[partition no.]\
    resume=/dev/disk/by-id/ata-[old disk_ID-part[partition no.]\
    splash=silent quiet showopts vga=0x31a
        initrd /boot/initrd-2.6.34.7-0.7-desktop

    ###Don't change this comment - YaST2 identifier: Original
    ###name: failsafe
    title Failsafe -- openSUSE 11.3 - 2.6.34.7-0.7
        root (hd0,5)
        kernel /boot/vmlinuz-2.6.34.7-0.7-desktop \
    root=/dev/disk/by-id/ata-[old disk_ID]-part[partition no.]\ showopts apm=off noresume nosmp maxcpus=0 edd=off \
    powersaved=off nohz=off highres=off \
    processor.max_cstate=1 nomodeset x11failsafe vga=0x31a
        initrd /boot/initrd-2.6.34.7-0.7-desktop


    Using the first menu option as a model, I created a new menu option to boot from the new hard disk:

    ###New menu option###
    title Suse linux 11.3
        root (hd2,5)
    # Note: hd1 was still the 2nd old hard disk at this stage
        kernel /boot/vmlinuz-2.6.34.7-0.7-desktop \
    root=/dev/disk/by-id/ata-[new disk_ID]-part[partition no.]\ resume=/dev/disk/by-id/ata-[new disk_ID]_ID-part\
    [partition no.]splash=silent quiet showopts vga=0x31a
        initrd /boot/initrd-2.6.34.7-0.7-desktop

    A reboot confirmed that this new option worked fine.

    Th final stage was to comment out the lines in the /boot/grub/device.map file for the old disks, and assign(hd 0) to the new hard disk. Next, I edited the /boot/menu.lst file, commenting out the menu options for the old hard disk and retaining the menu option for the new hard disk, ensuring that the line beginning root now pointed to (hd0,5) since this hd0 was now the hard disk number for the new disk in device.map.      

    I disconnected the old disks, rebooted and then selected the new menu option, but for some reason/etc/fstab now had a line for a root partition on one of the old drives (the drive which didn't actually have a root partition...) so the reboot failed. Changing /etc/fstab fixed this.

    Monday 2 May 2011

    Building a silent PC for MythTV

    I started using MythTV a few years ago as an experiment. My main intention was to access foreign-language TV and radio broadcasts on my lounge TV but I was amazed at the power and flexibility of this open-source PVR when I gave it a trial run.

    My original MythTV PC recently hit the buffers, so I've built a new box with the following components:
    • Antec Fusion NSK-2480 case
    • Scythe mini-ninja (eBay) 
    • AMD Athlon II X3 400E Triple Core CPU
    • LiteOn IHOS104-32 4x Internal Blu-Ray BD-ROM
    • Seasonic X-460FL 460W ATX Fanless PSU
    • CORSAIR 4GB 1333MHz CL9 DDR3 Memory Kit
    • ASUS M4A78LT-M LE motherboard
    • 2 x Western Digital WD10EARS 1TB Hard Drive SATAII 5400rpm 64MB 
    • Noctua NF-S12B 120mm case fan
    • Sparkle GT220 coolpipe graphics card (passively cooled) 
    This setup works well for a media centre PC because it is effectively silent. You might just pick up a feint whine from the hard disks if you are close to the PC but otherwise you can't hear it. The Noctua fan is completely silent at around 600rpm and is sufficient to cool the heatsink on the now-discontinued Scythe mini-ninja, so there is no need for a dedicated CPU fan. Likewise, the Seasonic PSU, although pricey, is also silent. Seasonic in the Netherlands told me the Antec Fusion NSK-2480 case and this PSU are a good match because of the "headroom" in this case.

    I am currently running MythTV 0.24 under Suse Linux. A few Mythtv users have reported that the video runs in "slow motion" under this version, something which I managed to fix (on the basis of a forum post) by setting the audio output to ALSA:pulse.

    High-definition Freeview has just arrived in my area. This is progressively being rolled out across the UK and uses the DVB-T2 standard. PC hardware to decode this signal is very new although the PCTV systems nanoStick T2 290e DVB-T2 USB tuner is available which I am currently running under Windows 7.  This works fine under PCTV's own software but under Windows Media Center the audio drifts out of sync with the video. This seems be a common problem with Windows Media Center (which doesn't occur with MythTV) and there doesn't seem to be a solution. The use of Windows 7 for high definition Freeview is a stopgap as far as I am concerned so I am watching with interest the development of a Linux driver.

    Update: driver for the nanoStick T2 now built into the Linux Kernel.

    BT Infinity on Linux

    I recently upgraded to BT infinity and being a Linux user didn't know whether the new BT Home Hub 3 router would offer the same flexibility as my previous router, a Linksys Wireless-G ADSL Home Gateway.

    Fortunately the functionality I required under Linux from the Linksys router is largely replicated on the BT Home Hub 3. You don't need a Windows or Mac disk to install anything, everything can be configured under a Linux-enabled browser such as Opera.

    Dynamic DNS is supported, currently the router offers DynDNS, NoIP and DtDNS.

    The Infinity router also allows port forwarding, although the way it is implemented is a bit awkward. You can't assign the same port to more than one device. Say, for instance, you exchange files with a smartphone using FTP on port 21, you can't assign 21 to another device (e.g. the PC from which you access the router). If you try, the Home Hub 3 will throw up an error. Fortunately there is a workaround. The router has a number of pre-configured port settings for games and applications including FTP and SSH. Under the "supported applications" tab within "port forwarding" (all under "advanced settings") you can Add a new game or application, so for the smartphone example you could add an entry for "FTP smartphone" and assign a port such as 2121 to the device. This can create additional work on Linux because you may have to change configuration files in order to associate a port number with a service, for instance you have to change /etc/ssh/sshd_config on SUSE for  SSH. A custom rule may also be required for the firewall. This is irksome but manageable, and once the port settings are configured the router seems to forward the relevant ports OK.

    On balance the Home Hub seems a decent upgrade in terms of speed, about 22 MB/sec download where I am and around 4 MB/sec upload, an enormous improvement on copper-based ADSL where I could only scrape 2MB/sec download. From a Linux perspective, I haven't found any major issues with it although it's always worth bearing in mind that BT expect customers using Linux to set up their own Internet connections (as BT's own Web site makes clear). Some Linux users seem to have difficulty, particularly with certain distributions. I have always found knetworkmanager a user-friendly way of managing wireless connections under Linux.