Thursday, March 29, 2012

Headphones for Toshiba Satellite L640 in Ubuntu Natty

By default in Ubuntu Natty the built-in speakers keep playing even when headphones are plugged in. Adding the following to /etc/modprobe.d/alsa-base.conf fixes the problem for me.

options snd-hda-intel model=thinkpad

Via Ubuntu Forums.

Wednesday, March 28, 2012

ATI Radeon GPU power management in Ubuntu Natty

Update: Some YouTube videos don't work on the mid setting for me, high seems to be needed. More investigation required!

OK, CPU scaling wasn't the reason for my laptop's excess heat and fan noise after all. The problem was with the GPU.

A forum post outlines how to scale down the GPU to reduce power, heat and fan noise (found via a comment in a Launchpad bug report). Worked for me with the mid power setting.

$ sudo -i
# echo dynpm > /sys/class/drm/card0/device/power_method
# echo profile > /sys/class/drm/card0/device/power_method
# echo mid > /sys/class/drm/card0/device/power_profile 

After applying this change there was a marked decrease in fan noise. The GPU temperature has clearly come down.

Before:

$ sensors
radeon-pci-0100
Adapter: PCI adapter
temp1:       +66.5°C

After:

$ sensors
radeon-pci-0100
Adapter: PCI adapter
temp1:       +56.5°C 

Scaling CPU in Ubuntu Natty

When I use my laptop in Ubuntu Natty I notice extra heat from the CPU. It seems like Windows is being more agressive at slowing the CPU down to save power. Unfortunately, the Power Management control in Natty doesn't mention CPU speed at all.

There is (or was?) an option for controlling the CPU in the Power Management control. But I wasn't able to get it to work.

Instead I installed the cpufreq indicator:

$ sudo add-apt-repository ppa:artfwo/ppa
$ sudo apt-get update
$ sudo apt-get install indicator-cpufreq
$ indicator-cpufreq&

Sunday, March 25, 2012

Scala in gedit

The standard distribution of gedit doesn't understand Scala source. Here's how to add it.

  1. Create ~/.local/share/mime/packages/scala-mime.xml with the following content:
    <?xml version="1.0" encoding="UTF-8"?>
    <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
    <mime-type type="text/x-scala">
    <comment>Scala programming language</comment>
    <glob pattern="*.scala"/>
    </mime-type>
    </mime-info>
    
  2. Register the new MIME information and check that the registration has been successful.
    $ update-mime-database ~/.local/share/mime
    $ gnomevfs-info myfile.scala | grep MIME
    MIME type         : text/x-scala
    
  3. Add the Scala syntax highlighting information.
    mkdir -p ~/.gnome2/gtksourceview-1.0/language-specs/
    wget -P ~/.gnome2/gtksourceview-1.0/language-specs/ https://raw.github.com/scala/scala-dist/master/tool-support/src/gedit/scala.lang
    
  4. Enjoy your highlighted source!
    $ gedit myfile.scala
    

This post is based on information from Shashank Tiwari and from the GNOME Desktop System Administration Guide.

Saturday, March 17, 2012

Personal DNS hosting

As part of my slow migration away from GoDaddy I have a few personal domains that I want to arrange hosting for. After a bit of investigation I finally found what looks like a nice DNS hosting provider: Zonomi. As a bonus they also seem to be affiliated with Rimuhosting, who I've had good experiences with in the past!

I looked at some of the free DNS providers out there and after having a few difficulties with each of them decided I'd prefer to pay a bit of money for something nicer—but not too much!

Free DNS hosts I looked at:

Paid DNS hosts:

And, finally, an old but relevant Hacker News thread!

Monday, March 12, 2012

Toshiba Satellite L640 battery in Ubuntu Linux

A vanilla installation of Ubuntu Natty (11.04) doesn't show a battery indicator for my Toshiba Satellite L640 PSK0LA-05X00T. No battery is detected.

The problem seems to be in the process of being fixed, but in the meantime there is a workaround. The instructions below are a blend of those taken from posts by Faheem and Michael Kuron. Thanks!

  1. Extract the current DSDT.

    $ sudo cat /sys/firmware/acpi/tables/DSDT > dsdt.dat
  2. Decompile it.

    $ sudo apt-get install iasl
    $ iasl -d dsdt.dat
  3. Patch the source, as described here.

    $ sed -i 's/OperationRegion (EMEM, SystemMemory, 0xFF808001, 0xFF)/OperationRegion (EMEM, EmbeddedControl, 0x00, 0xFF)/g' dsdt.dsl
  4. Recompile the modified source.

    $ iasl -tc dsdt.dsl
  5. Configure GRUB to use the modified DSDT.

    $ sudo cp dsdt.aml /boot/
    $ sudo nano /etc/grub.d/01_acpi
    ----
    #! /bin/sh -e
    
    # Uncomment to load custom ACPI table
    GRUB_CUSTOM_ACPI="/boot/dsdt.aml"
    
    # DON'T MODIFY ANYTHING BELOW THIS LINE!
    
    prefix=/usr
    exec_prefix=${prefix}
    libdir=${exec_prefix}/lib
    
    . ${libdir}/grub/grub-mkconfig_lib
    
    # Load custom ACPI table
    if [ x${GRUB_CUSTOM_ACPI} != x ] && [ -f ${GRUB_CUSTOM_ACPI} ] \
            && is_path_readable_by_grub ${GRUB_CUSTOM_ACPI}; then
        echo "Found custom ACPI table: ${GRUB_CUSTOM_ACPI}" >&2
        prepare_grub_to_access_device `${grub_probe} --target=device ${GRUB_CUSTOM_ACPI}` | sed -e "s/^/  /"
        cat << EOF
    acpi (\$root)`make_system_path_relative_to_its_root ${GRUB_CUSTOM_ACPI}`
    EOF
    fi
    ----
    $ sudo chmod +x /etc/grub.d/01_acpi
    $ sudo update-grub2
    ...
    Found custom ACPI table: /boot/dsdt.aml
    ...
  6. Reboot and enjoy proper battery support.