Thursday, July 09, 2009

How to create a permanent alias

When you frequently need to type the same long command on your terminal, you need to create aliases so you can save time. Unfortunately, when I created a 67 character alias, I didn't know it wouldn't be a permanent one. Having created this alias three times the past few days, I began to suspect it wasn't just an error, but a patern... aliases are not stored by default.

To create permanent aliases, follow this command:
1. Open your ~/.bash_aliases file with text editor you like then add the alias you want. (If you don't have .bash_aliases, create a new one on your home directory).
alias cdvid="cd /home/user/Downloads/Entertainment/Files/Video"

2. Uncomment these 3 lines on your ~/.bashrc file

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases

3. Restart your terminal

And that's it. Now your carefully crafted aliases will be preserved forever..

Wednesday, May 20, 2009

How to enable the Thinkpad volume notification

A typical Thinkpad has two ways to control the volume of the speakers:
1. a hardware mixer and,
2. not surprisingly, a software mixer.

The volumen up, down and mute buttons on the Thinkpad keyboard are used to control the hardware mixer and have nothing to do with the software mixer. A software mixer is a bit more advanced since it has many more steps in volume control than the 15 steps the hardware mixer has (including mute), but still they're there and they work.

Since Jaunty, the Ubuntu packagers have decided to disable the volume control in the various modules they pack in the distribution. This was because there were too many complaints and bug reports that the usage of the volume buttons resulted in very big steps in volume control. Logical, because if you push volume up and it then ups the hw mixer and sw mixer at the same time, the gain in volume would be twice as big as to be expected.

So, out hw mixer from the volume control. The only real solution here would be if there was an Alsa mixer (or any of the other sound softwares) module to control the hw mixer, but there isn't any.

Draw back is that pressing the volume buttons don't give any graphical feedback about their status, so you're completely in the dark if it is muted, soft or hard. Annoying at least. But... there is a solution.

A bloke named Lorne has recompiled the thinkpad_acpi module for the community and is available at this ppa. It has a new kernel image and headers, that will upgrade your kernel, but not in version. It will remain a slightly addapted stock 2.6.28-11 kernel. Also, the HDAPS fix I posted earlier will remain working after this upgrade.

Just add
deb jaunty main
deb-src jaunty main
to your sources.list or through Synaptic as third party software. Then add the key of this repository to your system using:

$ sudo apt-key adv --recv-keys --keyserver f6a3a943a0f94e10d19c2f35ad3d7a1a3e3d239e

Then upgrade your kernel with either Synaptic or the Update manager and reboot.
VoilĂ , the notification system now shows you the status of the volume when you use the hardware buttons.

You could also use the 'tpb' (for Thinkpad Button) package to accomplish this, but it has some drawbacks. It doesn't look too good, it's not integrated in your desktop experience as the notification system is (and with Jaunty, that looks very slick) and it consumes considerably more power. The latter because tpb polls the nvram subsystem while otherwise the acpi system is used.

Also, installing tpb from the stock Ubuntu packages will deinstall the hotkey package, so you would have to compile/install it manually if you don't want to lose the hotkey package..

Tuesday, May 19, 2009

Getting HDASP to work on Jaunty

When working on getting the IBM Hard Drive Active Protection System (HDAPS) to work properly on Intrepid (8.10), I found out the newer kernel that would be part of Jaunty would support some things out of the box. As I hate compiling kernels and love to leave that to the more gifted, I decided then I'd sit it out until Jaunty would come out.

Having said that, it turned out it wasn't going to work out of the box on Jaunty either, but... it would not require any kernel compilations either. So I decided to give it a go.

Some things are documented on other blogs as well and I'll be copying/pasting a lot of content from there. However, I still ran into quite some problems that required digging further and further through the internet. Luckily I wasn't the only one, so I was able to find out how to get it to work properly. Please regard this post as summary of information gathered from all kinds of sources on the net. Unfortunately I can't remember all sources I used exactly, there were just too many before I found the ultimate solution, so I won't be giving any credits as I wouldn't like to ommit any (so therefor I give none - but I won't take credits either, it's mostly copy/paste completed with the things I recovered from the xterm history!!!).

How to get it to work:

The HDAPS system consist of two parts. The driver that enables reading the acceleration data and some sort of userspace software that does the actual parking of the harddrive heads, usually hdapsd.

The hdaps driver is part of the kernel but the driver maintainers actually recommend using the tp-smapi driver instead. So that’s what we’ll do.

Start by making sure you have the necessary tools installed

$ sudo apt-get install build-essential module-assistant

Luckily it’s in the package repository (universe)

$ sudo m-a a-i tp-smapi

this will fetch and install the tp-smapi-source package, unpack the source and then compile and install the kernel module. If you ever get the message that it is already compiled and you still want to recompile/reinstall it, throw in the -f (force) option here.

Try loading it:

$ sudo modprobe tp_smapi
$ sudo modprobe hdaps

The kernel log should show something like this (use dmesg):

[ 1546.780684] thinkpad_ec: thinkpad_ec 0.37 loaded.
[ 1546.784125] tp_smapi 0.37 loading...
[ 1546.784406] tp_smapi successfully loaded (smapi_port=0xb2).
[ 1571.445942] hdaps: LENOVO ThinkPad T61 detected, setting orientation 1
[ 1571.446111] hdaps: initial mode latch is 0x05
[ 1571.446265] hdaps: setting ec_rate=250, filter_order=2
[ 1571.446493] hdaps: device successfully initialized.
[ 1571.446607] input: ThinkPad HDAPS joystick emulation as /devices/virtual/input/input13
[ 1571.469284] input: ThinkPad HDAPS accelerometer data as /devices/virtual/input/input14
[ 1571.505138] hdaps: driver successfully loaded.

For some reason some configuration for udev is missing. Fix this by running

echo 'KERNEL=="event[0-9]*", ATTRS{phys}=="hdaps/input1",ATTRS{modalias}=="input:b0019v1014p5054e4801-*",SYMLINK+="input/hdaps/accelerometer-event"' | sudo tee /etc/udev/rules.d/51-hdaps.rules

Now for the userspace stuff. First let us test if APS is actually working.

$ sudo apt-get install hdaps-utils

After installation you can use hdaps-pivot or hdaps-gl to verify that the sensors are working

hdapsd in Jaunty is old. There is a PPA with newer versions.

Add the PPA to your repository list

$ cat | sudo tee /etc/apt/sources.list.d/hdapsd.list <<> deb jaunty main
> deb-src jaunty main

And add the PPA key

$ sudo apt-key adv --recv-keys --keyserver 45EA2DEACE74152B61554DE4036A90F2BEFC6EB4

and then update the package list and install the package

$ sudo apt-get update
$ sudo apt-get install hdapsd

Remember to edit /etc/default/hdapsd to match your system. Most likely you will want to change the sensitivity settings. I found '15' to be too sensitive. At the moment I use '50', but you might want another setting...

Now, we're not there just yet. It will work with the above once, but after a reboot it will stop working again. Modprobe'ing will not work anymore either. It'll throw an error like:

thinpad_ec: Unknown parameter 'force_io'

when you try (check with dmesg). It took me 5 hours to find out why and how to resolve this.

It is because there an entry in /etc/modprobe.d/local.conf which explicitly loads the thinkpad_ec module with the option 'force_io=1'.
Open this file as root (sudo) for editing and comment the line which mentions the thinpad_ec module:

$ sudo gedit /etc/modprobe.d/local.conf
The you can restart the HDASP demon with
$ sudo /etc/init.d/hdasp restart

Now you should be fine and it will work over reboots.
There are some pretty cool applets that will show you the status of the HDAPS system. I still use the Avant Window Manager and the latest version has an applet that shows it's status too. With these you can check if it actually works.

Also, the newer HDAPS system you now got implements a joystick device; now you can play Tuxrace by tilting your Thinkpad! Also available: an anti-theft alarm... more on these on the thinkwiki.

Now on Jaunty Jackalope (Ubuntu 9.04)

That's right, I'm now on Jaunty. That's also why I've been quiet for a bit; too many things to find out again ;-)

I'll be posting the most noticeable or unfindable things I found out here, so stay tuned!

Thursday, March 26, 2009

TPFand - cool down

I had experienced this under Windows too: my T60p got very, very hot at times (CPU > 85°C) . Sometimes it would even exceed 100°C causing the lot to just switch off with an emergency halt. Boom; black screen and take a break for 30 minutes to let things cool down.

I found out that the BIOS (or other hw controlling software) didn't manage the fan properly. It would just sit there, humming peacefully and slowly while internals must have resembled hell in TP by then. The I found the Notebook Hardware Control (NHC) software suite. Execellent piece of work in which you could set tresholds for various part temperatures (CPU, GPU, etc.). It would spin up the fan, keeping temperatures inside agreeable or manageable at least.

Hardware issue, you say? Yes, that was what the helpdesk thought as well. My motherboard, cpu fan and gpu unit all have been replaced at least two times each. Never got any better. And I did truthfully install each and every BIOS/firmware upgrade Lenovo brought out; so that couldn't be it either.

Okay, so I had it working on Windows, now Linux. I found out the other day that CPU temperatures could easily reach 85°C or higher with the fan back in its lazy mode humming peacefully again. Something had to be done again.

So I found Thinkpad Fan Control and it does exactly what NHC did as well: you can set custom tresholds from where the fan will spin up or down. Vey easy and very well working, for me. Temperature never goes beyond 80°C anymore!

But, you got to know one thing about tpfand: if any of the settings are left to hw_ctrld (Hardware Controlled), then it seems that it will always hw_ctrl your fan, regardless of your settings. So I recommend you remove all hw_ctrld settings and replace them with a real value (=percentage).

There are two sensor you will want to watch:
Sensor 0 is your CPU which gets hot if you don't look out ;-)
Set tresholds to: < 50°C off, 50 < 30% < 58, 58 < 45% < 65, 65 < 60% < 70, 70 < 75% < 75, 75 < 90% 80, 80 < 100% < 85, 85> full
Sensor 3 is your GPU (ATI FireGL5200), which can get even hotter...
Set tresholds too: <50°C off, 50<15%<55, 55<30%<65, 65<45%<75, 75<60%<78, 78<75%<80, 80<90%<82, 82<100%<85, 85> full
Set all other thresholds too: <50°C off, 50°C> full
Under advanced set 'Hysteric' to 4 and minimum delay to 2.5 seconds.
(all temperatures in °C; please pay attention as tpfand can also show them in °F)

And then you'll have a quiet machine that won't get too hot but doesn't spin up at every temp spike either. Good for your ears and lifespan of your TP!

Tuesday, March 24, 2009

Get a better Second Life (on Linux)

Every now and then I go into Second Life. Just to browse around or attend my companies information sessions. I really like those; active and useful content delivery in a new environment... quite inspiring actually.

But, when I switched to Linux I found that the official Second Life viewer for Linux isn't too swell. It's slow, hicky and sticky. Like you're walking in a world drenched in melasses; it's just no fun anymore.

But there's an alternative for Linden Labs viewer, one that's quite a bit better performing on Linux. And it comes with an update server, so you get you're frequent updates as well.

Hah, the name you ask. Well, it's the Open Metaverse viewer. Have a look or get a second life first ;-)

Flawless video playback with Compiz

Maybe you have experienced, like me, that video playback isn't as flawless as it could be. I experienced frequent framedrops, stutterings and flashing windowparts when playing video full screen. I tried Totem-GStreamer and MPlayer but neither made any difference. Then I tried the many different rendering types MPlayer packages (X11shm, OpenGL, et cetera) to no avail.

I had a suspect though: Compiz. Changing the Desktop Effects to none - effectively shutting down Compiz - turned full screen video playback back to normal; no more hick ups, framedrops or anything. But toggling Compiz on and off isn't a solution. It's a workaround and thus feels wrong. So, I had to dig through the Internet to find a solution.

Many, many forums, blogs, bug-sites and other websites have been written full on this problem. Especially the combination Compiz - ATI fglrx cards seem to experience the video playback problems. I found many "solutions", ranging from adapting Xorg.conf with custom settings to fiddling with the aticonfig tool. However, judging from the comments on these "solutions", they seemed to work for only small parts of the populus and certainly not for the majority.

As I didn't want to mess up my system with complicated sets of script alterations of which I wouldn't be able to keep track of after a couple of rounds trying, I decided that I'd either have to go with the Compiz-shutdown-workaround or have to come up with something else. Shutting down Compiz isn't too complicated if you use the Compiz Fusion Icon in the system tray but it also changes your desktop appearance. Especially if you use things like the Avant Windows Manager like I do as this relies on a composited desktop.

But first I thought to go through the CompizConfig settings. This is easily found through System->Prefferences. Looking at each option, I tried to predict what it would do. I must admit that many aren't too obvious and the tooltips aren't very explicit either.

Under the "Tools" header I found "Video Playback". Now, I haven't got the foggiest on what that does or is expected to do, but I figured it might conflict with proper video playback in other software. So I toggled that off and retried full screen video playback. And... tataaa... it worked fine; as if Compiz wasn't running!

I haven't seen this solution anywhere else, so I am wondering if others experience toggling this setting to off solves their problems. If it does (or doesn't), please leave a comment for others. Thx!

Important update: You will have to close windows that are frequently updated or switch to a clear desktop in order to avoid the underlying windows to flash black boxes through your video. E.g. I have to close all active screenlets when I watch video, as these are updated every few seconds and flash through the full screen video.