tips-computer-lenovoX61t-gnuLinuxSetup

Debian GNU/Linux on a Lenovo (IBM) x61 tablet (x61t) (model number 7764CTO)

In progress...

These notes assume some prior knowledge of Debian. However, I've spelled things out more than a Debian expert would need.

Please know that these notes were compiled after the fact. It is likely that i omitted or misremembered some steps. If you find any such mistakes or omissions, please lemme know so that i can correct this page.

Summary: what works

Works

Partially working

Haven't tried but heard it will work

Haven't tried and don't know

Hardware

Please see hardwareDetails for lspci output, etc.

How to get various things working

Debian install

I installed Debian 4 amd64 from CD (via the ultrabase), and over the network (via the ethnic connection), without a hitch.

I figured that I won't be using Windows Vista much, so I gave it 21 gB. I deleted the first partition (the thinkvantage recovery partition), which was about 5.5 gigs, and made a swap partition of the same size in its place. This left about 68 gB for my ext3 GNU/Linux partition.

I made recovery disks (I forgot if I did "rescue" or "recovery"; it made 7 CDs which I'm told will be able to restore my system to the factory configuration if I ever need to) before deleting the recovery partition.

After the initial install, I upgraded to kernel version 2.6.22, and then rebooted.

Basic XWindows configuration

apt-get install xorg xserver-xorg-input-all xserver-xorg-input-evtouch xserver-xorg-video-all xserver-xorg-video-intelligence xbase-clients

Actually, though, i think that only xorg, xserver-xorg-video-intel, xbase-clients (for xrandr), and xserver-xorg-input-all were necessary.

I installed most of those from Debian Unstable. The versions I have are:

xorg 1:7.2-5
xserver-xorg-input-wacom 0.7.7.11-1
xserver-xorg-video-intel 2:2.1.1-1
xbase-clients 1:7.2.ds2-2

Rumor has it that linuxwacom 0.7.8 can do the touchscreen ("multitouch"). I haven't tried it yet though.

Here is my /etc/X11/Xorg.conf file. It is configured to be able to use both the internal screen and also a 1600x1200 external monitor. xrandr will be used to switch between the internal and external displays.

Sometimes XWindow crashes (totally freezes up) and I think it's the video driver. It happens whenever I try to run Second Life. It also happens when I use OpenGL? on my external monitor and make the window too big (even glgears will do it). The second situation (OpenGL? on a big window on the external monitor) seems like it can be avoided by only using the internal LCD when using those applications.

Troubleshooting X

less /var/log/Xorg.0.log

Window manager and how to start X

I use XFCE because it is fast and yet has all the features I want (such as multiple workspaces).

apt-get install xfce4 xfce4-goodies

At this point you can do

startx

as any user to start XWindows.

Using xrandr

I usually like to have the display be in one of three modes:

To switch on the internal screen and switch off the external monitor,

xrandr --output LVDS --auto  --output VGA --off

To switch off the internal screen and switch off the external monitor,

xrandr --output VGA --auto  --output LVDS --off

To switch both on, displaying the same thing:

xrandr --output VGA --auto  --output LVDS --auto

To get a status report,

xrandr -q

For convenience, I've added the following scripts to my system.

In /usr/local/bin/intscr:

#!/bin/sh

xrandr --output LVDS --auto  --output VGA --off

In /usr/local/bin/extscr:

#!/bin/sh

xrandr --output VGA --auto  --output LVDS --off

In /etc/X11/Xsession.d/40xrandr (will be executed during startx):

extscr

And be sure to

chmod a+x /usr/local/bin/intscr /usr/local/bin/extscr

If you want to combine the two screens into one area, you'll have to uncomment the "Virtual 2624 1200" lines in xorg.conf (these tell X to be ready to accomodate a virtual workspace with dimensions up to 2624, 1200), and restart X. Then do something like:

xrandr --output VGA --auto  --output LVDS --auto
xrandr --output VGA --left-of LVDS

See this page for more guidance there.

Tablet

Package xserver-xorg-input-wacom was already installed, because it is a dependency of xserver-xorg-input-all, which was installed above.

As root, i created the file /etc/init.d/mysetserials and put the following into it:

#!/bin/sh

/bin/setserial /dev/ttyS0 port 0x0200 irq 5 autoconfig

Then execute

chmod a+x /etc/init.d/mysetserials
update-rc.d mysetserials defaults

From now on the setserial command will execute at startup time, but to get the tablet working now without restarting, do

/bin/setserial /dev/ttyS0 port 0x0200 irq 5 autoconfig

You'll probably have to restart X, too, before it starts to work.

Troubleshooting the tablet

apt-get install wacom-tools

wacdump /dev/ttyS0

Advanced tablet configuration

---

Connectivity

Wireless card (Intel 4965 AGN)

Update: now it's in Debian; instructions are on http://wiki.debian.org/iwlagn ; I think you just do

aptitude install firmware-iwlwifi wireless-tools

To configure the card, you can use the usual /etc/network/interfaces stuff, and/or ifconfig and iwconfig. The interface name is wlan0.

I found that I have to do "iwconfig wlan0 ap any" before it will associate with my router. Dunno if that's a general problem or if I did something wrong in /etc/network/interfaces.

Old instructions

The following is a modified version of the howto from http://forums.debian.net/viewtopic.php?t=18233:

This howto is to try and get Intel 4965 wifi cards, found in the Santa Rosa chipset, working. Since the iwlwifi driver is not yet in the Debian repositories, to get it to work requires you to download that and compile it yourself.

This Howto assumes a 2.6.22 kernel, which has mac80211 already built in. I assume if you compile and load it for 2.6.21, it should work, but I haven't tested that.

apt-get install linux-source-2.6.22 linux-headers-2.6.22-2-amd64 

(note: I'm actually using 2.6.22-1 myself, but I bet that 2.6.22-2 should work too; in any case, the version of the headers should match the version of linux-image-2.6-amd64 that you have installed)

cd /usr/src
tar xovj linux-source-2.6.22.tar.bz2
cd linux-source-2.6.22
make oldconfig

Download both a "microcode image" (iwlwifi-4965-ucode-foo.tgz) and a "driver snapshot" (iwlwifi-foo.tgz) from http://intellinuxwireless.org/?p=iwlwifi&n=Downloads. Change to the directory where those files are. In the directions below, I'll assume that the files were iwlwifi-4965-ucode-4.44.1.18.tgz and iwlwifi-0.1.15.tgz.

tar xvzf iwlwifi-4965-ucode-4.44.1.18.tgz
tar xvzf iwlwifi-0.1.15.tgz
mkdir /lib/firmware

(I forgot if mkdir /lib/firmware was needed, probably not. If not, there will be an error "mkdir: cannot create directory `/lib/firmware': File exists", just ignore it)

mv iwlwifi-4965-ucode-4.44.1.18/iwlwifi-4965-1.ucode /lib/firmware
cd iwlwifi-0.1.15
ln -s /usr/src/linux-source-2.6.22 /lib/modules/`uname -r`/source
ln -s /usr/src/linux-headers-`uname -r` /lib/modules/`uname -r`/build
make
make install

Now edit /etc/modules and add a line: "iwl4965". This will make sure that the iwl4965 driver loads automatically the next time you boot. To load it right now, too, do

modprobe iwl4965

Troubleshooting the wireless card

You may wish to read part of the page http://intellinuxwireless.org/?p=iwlwifi&n=HOWTO-iwlwifi, or check out the forum thread http://forums.debian.net/viewtopic.php?t=18233.

Also, the commands "dmesg", "less /var/log/syslog", "ifconfig", and "iwconfig" are useful for troubleshooting this sort of thing.

Making the wireless card turn on when the ethernet cable is unplugged

aptitude install ifplugd}}}

Add the following file as {{{/etc/ifplugd/action.d/activateWirelessOnDisconnect}}}:

{{{
#!/bin/sh
set -e

if [[ "$1" == eth1 ]]; then
  case "$2" in
  up)
        /sbin/ifdown wlan0
        ;;
  down)
        /sbin/ifup wlan0; /sbin/iwconfig wlan0 ap any
        ;;
  esac
fi

When anything happens to one of the network interfaces, ifplugd calls this file with two arguments, the first argument being which interface is changing state, and the second argument telling which state it is transitioning to. As you can see, when eth1 (the wired ethernet) goes up, the script turns off the wireless card. When eth1 goes down, the script turns on the wireless card, and sets configuration option "ap" to "any", which i found necessary to be able to associate with my router.

And then I have /etc/network/interfaces set up so that the wired ethernet (eth1) goes up at boot. This setup doesn't solve the problem of making the wireless card work if you boot while not connected to the wired ethernet; i guess that eth1 probably never goes down, so activateWirelessOnDisconnect is probably never executed. Todo.

If you are curious, here is my /etc/network/interfaces:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth1
iface eth1 inet static
        address 192.168.1.MYSTATICIP
        gateway 192.168.1.1
        network 192.168.0.0
        netmask 255.255.255.0
        nameservers: 199.175.137.212 144.162.120.230 207.69.188.186

iface wlan0 inet static
        address 192.168.1.MYSTATICIP
        gateway 192.168.1.1
        network 192.168.0.0
        netmask 255.255.255.0
        wireless-essid MYROUTERSNAME
        wireless-key MYPASSKEY
        nameservers: 199.175.137.212 144.162.120.230 207.69.188.186
        wireless-ap any

If you use WPA, then i think you need to do aptitude install wpasupplicant, and you'll need a stanza in /etc/network/interfaces with something like this in it instead:

iface wlan0 inet dhcp
      wpa-ssid MYROUTERSNAME
      wpa-psk  MYPASSKEY

sleep and hibernate (suspend-to-ram and suspend-to-disk)

NOTE: at some point, after upgrading something, the sleep and hibernate function keys stopped working -- but I can still use the command (as root) s2disk. hibernate works most of the time, but not if i've attached an sdcard and then later removed it, so i just use s2disk all the time now. also, i guess since acpi isn't working right, my script that disables power management on the hard drive after wakeup stopped working, so actually instead of just s2disk, i do:

s2disk; hdparm -B 255 /dev/sda 

now.

Sleep and hibernate basics

First, make sure acpi is installed:

apt-get install acpi acpi-support acpid

At this point (or maybe after a reboot?), you should already be able to go to sleep by running, as root, the command /etc/acpi/sleep.sh, and to enter hibernation mode by running the command /etc/acpi/hibernate.sh.

Hibernation worked immediately for me. Sleep worked at first, but broke when I upgraded something. But here's how to fix it; edit /etc/acpi/sleep.sh; comment out the line that uses /sys/power/state to initiate sleep, and use s2ram instead:

#echo -n $ACPI_SLEEP_MODE >/sys/power/state
/sbin/s2ram -f -a3

You may need to install Debian package uswsusp to get s2ram.

IMPORTANT NOTE

If you boot the computer attached to the docking station, hibernate, disconnect the computer from the docking station (the "ultrabase"), and then resume, it may crash. In fact, I think this may happen anytime you boot while attached to the docking station, and then wake from hibernation while undocked, even if you initiated hibernation mode while undocked.

Luckily, there is an easy workaround. Just don't boot while docked. You can dock once the boot process enters runlevel 2 (I think... I haven't tested that out precisely, but I usually dock about when it says "Starting MTA", which is after runlevel 2 has been entered).

ANOTHER IMPORTANT NOTE

Sometimes after resuming the screen is blank. Often, there's nothing to worry about; you just have to switch to another virtual terminal and then back to X to get it to reset. Do this by first hitting cntl-alt-F1, and then hitting cntl-alt-F7.

Useful trick

The hibernation mode saves the computer's state to disk, then actually shuts down. When you next turn on the computer, GNU/Linux checks to see if there is a hibernation image, and if so, restores it. Sometimes if the hardware state gets "screwed up" in some way, you can go into hibernation and then wake it up and the problem will be resolved; it's almost as good as rebooting (because it actually does reboot, at least partially).

Getting Fn-F4 to cause sleep and Fn-F12 to cause hibernation

On my machine, I think Fn-F4 already caused sleep, but Fn-F12 didn't do anything. But we're going to muck with both of them.

how it's going to work

There's a kernel module thinkpad_acpi. I'm not sure, but I think that it intercepts special thinkpad key ("hotkey") events and sends them through the acpi subsystem. When you press, for example, Fn-F4, this generates an ACPI event of type:

ibm/hotkey HKEY 00000080 00001004}}}

(I think) this event is sent to the acpid daemon, which checks registered event handlers to see what to do. This event will be caught by the handler in the file {{{/etc/acpi/events/ibmsleepbtn}}}. The contents of that file is:

 {{{
# /etc/acpi/events/ibmsleepbtn
# Called when the user presses the sleep button

event=ibm/hotkey HKEY 00000080 00001004
action=/etc/acpi/sleepbtn.sh
 As you can see, this file says that when Fn-F4 is pressed, execute the file /etc/acpi/sleepbtn.sh.
 The file {{{/etc/acpi/sleepbtn.sh}}} by default contains:
 {{{#!/bin/sh

test -f /usr/share/acpi-support/power-funcs

exit 0

. /usr/share/acpi-support/key-constants acpi_fakekey $KEY_SLEEP }}}

 That is, it fakes a keypress of the standard "sleep" key. For some reason this didn't do anything on my system, so I changed that file so that instead of calling {{{acpi_fakekey $KEY_SLEEP}}}, it directly calls {{{/etc/acpi/sleep.sh}}}, which is the program that actually puts the computer to sleep.
 One more detail: thinkpad_acpi will only catch some keys, depending on the "mask" that you give it. To tell it to catch all the keys that it can, you have to do:
 {{{echo "enabled" >> /proc/acpi/ibm/hotkey echo 0xffffffff >> /proc/acpi/ibm/hotkey }}}

End of "how it's going to work"

Getting back to the actual setup instructions, add the following line to /etc/modules:

thinkpad_acpi

Now that module will load upon each boot. To also load it right now, without rebooting, do:

modprobe thinkpad_acpi

Put the following into the file /etc/init.d/enable-ibm-hotkeys:

#!/bin/sh

echo "enabled" >> /proc/acpi/ibm/hotkey
echo "0xffffffff" >> /proc/acpi/ibm/hotkey

Then do:

chmod a+x /etc/init.d/enable-ibm-hotkeys
update-rc.d  enable-ibm-hotkeys defaults

and, in order to enable hotkeys right now without rebooting, also do:

echo "enabled" >> /proc/acpi/ibm/hotkey
echo "0xffffffff" >> /proc/acpi/ibm/hotkey

Now we're going to workaround those places where acpi_fakekey didn't work.

Put the following into the file /etc/acpi/sleepbtn.sh:

#!/bin/sh

test -f /usr/share/acpi-support/power-funcs || exit 0

#. /usr/share/acpi-support/key-constants
#acpi_fakekey $KEY_SLEEP

/etc/acpi/sleep.sh

Put the following into the file /etc/acpi/hibernatebtn.sh:

#!/bin/sh

test -f /usr/share/acpi-support/power-funcs || exit 0

#. /usr/share/acpi-support/key-constants
#acpi_fakekey $KEY_SUSPEND 

/etc/acpi/hibernate.sh

Troubleshooting acpi

Whenever you change any file in the /etc/acpi/events/ directory, you must run

/etc/init.d/acpid restart

for the change to take effect (you could also reboot).

The command acpi_listen lets you see which events acpi is receiving.

The command tail -f /var/log/acpid lets you see what acpi is doing in response (although the output of this seems to me to be lagged or confusing in some way).

Advanced acpi

Dunno if this works, but if you want to change ACPI defaults, I think the proper place, rather than /etc/default/acpi-support, may be to add a file at /usr/share/acpi-support/LENOVO.config containing something like:

case "$model" in
        # X61 tablet
        7764*)
                #SAVE_VBE_STATE=false;
        ;;
esac

Checking battery life

Use the command acpi

Video cycling

It's annoying if you have the display set to external screen only and then you put the computer to sleep or into hibernation and then take it somewhere and wake it up, only to see a blank screen (because the internal screen is deactivated and the external screen is not there). When then happens, I end up fumbling blindly trying to type "intscr" into a terminal.

I use two solutions to this. First, upon resuming from sleep or hibernation, my x61 is programmed to switch to the internal display. Second, Fn-F7 is programmed to cycle through the following video modes:

Autoswitch to internal display upon wake/resume

To do this, put the following into /etc/acpi/resume.d/66-intscr.sh:

#!/bin/sh

/usr/local/bin/intscr

# for some reason the screen is blank the first time that the internal
# screen is activated after sleep. tried to find the command to
# directly turn it on, but co uldn't find it. "vbetool dpms on" is not
# it. But this will fix it:
chvt 12
chvt $CONSOLE

Making Fn-F7 video cycle

I've heard that there's some way to get the firmware to do this. But here's how I do it.

Put the following into file /etc/acpi/events/ibm-videobtn:

# /etc/acpi/events/ibm-videobtn
# This is called when the user presses the video button.

event=ibm/hotkey HKEY 00000080 00001007
#action=/bin/true
action=/etc/acpi/videocycle

You've changed /etc/acpi/events/, so now you must execute:

/etc/init.d/acpid restart

Now put the following into file /etc/acpi/videocycle.sh:

#!/bin/sh

/usr/local/bin/xrandr_cycle
CONSOLE=`fgconsole`;
chvt 12
chvt $CONSOLE

And do:

chmod a+x /etc/acpi/videocycle.sh

Now put the following into file /usr/local/bin/xrandr_cycle:

#!/usr/bin/perl

# Copyright 2007 Bayle Shanks. Release under the GPL version 2 or later.

#print `whoami` . "\n";
#$ENV{'DISPLAY'} = ":0.0";
$ENV{'HOME'} = "/root";
#print `echo $DISPLAY` . "\n";

$xrandr_query = `xrandr -q`;

while ($xrandr_query =~ /^([^\n]*?) connected/msg) 
  {$connected{$1} = 0; 
   #print "$1\n";
   
  }

while ($xrandr_query =~ /^([^\n]*?) connected((?!connected).)*?\*/msg) 
  {$enabled{$1} = 1;}

$num_digits = scalar keys(%connected);

$state_integer = 0;
for ( $digit = 0; $digit < $num_digits; $digit++ ) {
  #print "$digit: " . (keys(%connected))[$digit] . "\n";
  $current_interface =  (keys(%connected))[$digit];
  
  if ($enabled{$current_interface}) {
    $state_integer = $state_integer + 2**$digit;
  }
}

#print "$num_digits\n";
#print "$state_integer\n";

$next_state_integer = $state_integer + 1;
$next_state_integer = $next_state_integer % (2**$num_digits);

#print "$next_state_integer\n";

if (!$next_state_integer) {$next_state_integer = 1;}

#print "$next_state_integer\n";

$remainder = $next_state_integer;
for ( $digit = $num_digits-1; $digit >= 0; $digit-- ) {
  $current_interface =  (keys(%connected))[$digit];
  
  if ($remainder >= 2**$digit) {
    $new_state{$current_interface} = 1;
    $remainder = $remainder - 2**$digit;
  } else {
    $new_state{$current_interface} = 0;
  }
}

$cmd_str = 'xrandr ';
foreach $current_interface (keys(%connected)) {
  $cmd_str = $cmd_str . "--output " . $current_interface . " ";
  if ($new_state{$current_interface}) {
    $cmd_str = $cmd_str . "--auto ";
  } else {
    $cmd_str = $cmd_str . "--off ";
  }
}

#print $cmd_str

system($cmd_str);

Finally, we need to make it so that the root user has access to the Xwindows session (so that xrandr_cycle, which will run as root when we press Fn-F7, will be permitted to call xrandr). This is something that you may want to do even if you don't set up video cycling, so I've put it in the next section. So you have to follow the next session also before this will work.

Microphone

To enable the microphone, do alsamixer -V capture and then select each 'capture' device (using the arrow keys) and press the spacebar.

Making it so that the "root" user can access the XWindows session of your user

This only works if XWindows is typically used by a particular user account.

For example, let's say that XWindows is usually used by the user "bshanks". Then do this (do it as root, but not when you are running an X-ray session owned by root):

cd /root
rm .Xauthority
ln -s home/bshanks/.Xauthority

Note that on the "rm .Xauthority" step, .Xauthority may not exist, generating an error. If so, ignore the error.

Making startup not take forever when there is no ethernet

(this section assumes that you opted for the "unsplit configuration" during exim configuration. if you don't know what that is, don't worry, it's the default.)

In /etc/exim4/update-exim4.conf.conf, change

dc_minimaldns='false'

to

dc_minimaldns='true'

Then run

update-exim4.conf

The purpose of this is so that the computer doesn't pause for a very long time during boot at the step "Starting MTA..." when the wired ethernet interface is enabled, but the cable is unplugged (such a pause can happen when exim attempts to do a reverse-DNS lookupon the local hostname, but the internet is unavailable -- the DNS query waits awhile and then times out)

By the way, if you ever need to reconfigure the email SMTP server info, the command is either dpkg-reconfigure exim4 or dpkg-reconfigure exim4-config.

sound

To get sound working, i downloaded the latest ALSA sources from here, unpacked them and did configure, make, make install. I don't know if it was actually necessary to install these drivers because i didn't properly test out sound without them (i couldn't get it working, but i didn't know that you had to unmute using the hardware volume controls back then, so maybe it would have worked if i had tried that). However, others have reported that they needed to install recent ALSA sources to be able to get sound on the x61 and x61 tablet, so maybe it is necessary.

After this, i ran alsaconf, although i doubt that it was necessary. Then i fiddled with the sound levels with alsamixer.

Even if you turn up the volume in alsamixer, no sound comes out until you adjust the volume level with the hardware volume control buttons also. If you ever want to mute sound, the hardware mute button will mute it again. It is not a toggle; that is, pressing mute twice does not unmute. To unmute, you press the button labeled volume-up.

After you have done this, you can test the sound using the command speaker-test.

One person says that changing some of the BIOS settings might somehow screw up the sound. I changed one or two of the BIOS settings and sound still works, but perhaps other settings that i didn't alter are the problem ones.

If you want to install a Debian package, rather than just installing the latest build of ALSA from source, Franklin Piat has created a script to make a .deb based on some particular patches from the ALSA sources.

Optical drive in the ultrabay

Supposedly this will work better (with DMA, I think) with later versions of the kernel. But for now, add "ide-generic" to /etc/modules. The drive ends up at /dev/hda and a symlink from /dev/dvd is automaticaly created.

I use xine to watch DVDs. You can say either "xine dvd:" (maybe you don't need those slashes, i dunno), or you can start xine and press the DVD button.

Xine recommends that you run hdparm -d 1 /dev/dvd in order to make the drive faster (it disables some error-checking or something like that) but I haven't needed that yet.

In order to watch most DVDs with xine, you need libdvdcss. This isn't part of Debian for evil intellectual property reasons. So get libdvdcss from here. They have .deb s but only for x86. Since I am running amd64, I downloaded the source and compiled it myself (the standard configure, make, make install worked fine).

It seems that if I boot without being docked with the ultrabase, the DVD drive isn't completely recognized/configured; no /dev/dvd appears. The solution is to reboot with the ultrabase attached.

xdm

If you want the computer to boot into X, so that you don't have to type "startx" every time, you can install "xdm":

apt-get install xdm

But don't do that until you are done setting stuff up, because sometimes you can screw things up in such a way that X-windows hangs the computer, which is a problem if X will be started automatically upon boot (if that ever happens to you, I think the thing to do is to give the boot option "single" in grub (i.e., "linux single"), which boots you into runlevel 1; xdm is configured not to start until runlevel 2).

making firefox the default web browser

To install firefox,

apt-get install iceweasel

(Debian has to use the name "iceweasel" for their firefox packages to avoid trademark infringement.)

Various applications will trigger the default web browser to display HTML. To set the default to firefox (well, there are multiple places where defaults are set, but this is the main one in Debian),

ln -sf /usr/bin/iceweasel /etc/alternatives/x-www-browser

internal screen brightness

apt-get install x-backlight

Put this into /usr/local/bin/bright:

#!/bin/sh

/usr/bin/xbacklight -set 100%

Put this into /usr/local/bin/dark:

#!/bin/sh

/usr/bin/xbacklight -set 5%

Put this into /usr/local/bin/brighter:

#!/bin/sh

/usr/bin/xbacklight -inc 5%

Put this into /usr/local/bin/darker:

#!/bin/sh

/usr/bin/xbacklight -dec 5%

Now do:

chmod a+x /usr/local/bin/dark /usr/local/bin/bright /usr/local/bin/darker /usr/local/bin/brighter

UTF-8

Sometimes my XFCE terminals would display weird symbols, for example, when I ran aptitude, or in the "SYNOPSIS" part of the manpage generated by "man locale". This is a character encoding issue -- I think some parts of the system were in UTF-8 mode, and others weren't.

The solution was to put the following into /etc/environment:

LANG="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"

accessing the windows partition from GNU/Linux

apt-get install ntfs-3g

add this line to /etc/fstab:

/dev/sda2 	/mnt/windows	ntfs-3g	defaults,user,noauto 0 0

where sda2 is replaced by the partition that you used (you can print out the partition table with fdisk -l /dev/sda)

docking and undocking from the ultrabase x6

Docking and undocking mostly just worked, but there are two workarounds that were necessary.

First, as I noted earlier, if you want hibernation to work, you'd better be undocked when you boot.

Second, when I dock, then undock, then dock again, the USB connections thru the ultrabase stop working. In my case, this means my external mouse doesn't work after I re-dock. However, the hibernation trick works here; after you re-dock, just hibernate and then resume -- after this, the USB devices plugged into the dock (the ultrabase) work again.

hotkeys

By "hotkeys", I just mean buttons or keys on the keyboards that you program to do something special.

How it works

There are two kinds of hotkeys, normal ones and thinkpad-specific ones.

For the thinkpad-specific ones, use thinkpad_acpi and acpid as described in the section above on "Getting Fn-F4 to cause sleep and Fn-F12 to cause hibernation". In this case, the kernel module "thinkpad_acpi" detects the button presses and sends them to "acpid", and then you tell acpid what to do with them via the files in the /etc/acpi hierarchy.

In general, whenever you want a hotkey to cause some program to be run by the user "root", or whenever you want a hotkey to function even when you're not running X, it seems like acpi is the way to go.

But sometimes you want a keypress to cause something to happen within your current X-windows session, as if the currently logged in user had done it. That approach will be described here. The idea is to, first, convince X to notice when the desired hotkey is pressed, and second, tell your X-windows windows manager to do something when certain keys are pressed.

Above, I described how special thinkpad hotkeys are processed. Here is how other keys are processed. The GNU/Linux kernel receives "scancodes" from the keyboard (I think...). It maps these to "keycodes". If you are in X-windows, X then maps keycodes to "keysyms". Then either your window manager or even some individual programs can be set to do something in response to certain keysyms.

powersaving mode stuff

cpu frequency scaling

aptitude install cpufrequtils}}}

Add the following to {{{/etc/modules}}}:

{{{
acpi-cpufreq
cpufreq_ondemand

and load them now with:

modprobe acpi-cpufreq cpufreq_ondemand

Now you can use cpufreq-info and cpufreq-set to control the cpu frequency scaling. The scaling policies are called "governors". You can switch governors with the cpufreq-set -g option. Use cpufreq-set -g performance to leave the CPU at the highest frequency all the time. Use cpufreq-set -g ondemand to scale the CPU frequency according to need. Apparently1 the "ondemand" governor is the best thing for battery life, even better than just leaving the CPU speed low all the time.

In order to select "ondemand" at startup, i edited the file /etc/default/cpufrequtils, and i set the options to:

ENABLE="true"
GOVERNOR="ondemand"
MAX_SPEED=0
MIN_SPEED=0

Links:

Laptop mode

The Linux kernel apparently now has something called "laptop mode" to save battery life. It's a special mode that spins down the hard drive and then delays syncing files to disk so that the hard drive can stay spun down.

Unfortunately it didn't work too well for me. I found that i couldn't use firefox without making the hard drive spin up. I even tried putting the firefox cache in a ramdisk. I also tried forcing the computer to read everything in the firefox folder into memory right before i spun down the disk.

I think i saw an article somewhere that claimed that some power is saved even if the laptop spins back up fairly frequently (maybe adding half an hour to battery life), however i've also heard that spinning up and down wears down the hard drive.

I would like a little bit of battery life, but it's more important to me that my hard drive last a long time. So I don't want to spin down and up every two minutes. My conclusion is that laptop mode would be great if common applications could also be convinced to minimize hard disk access, but until then, it's not worth the potential for wearing out the hard disk. So I'm not using it.

Links:

Miscellaneous neat ACPI stuff

To query your battery level, use the command:

acpi}}}

To query information about what temperature your computer thinks it is and how much power it thinks it is using:

{{{
cat /proc/acpi/battery/BAT0/state
cat /proc/acpi/thermal_zone/THM0/temperature

Active hard disk protection

This laptop has a feature where it can detect if it is being dropped and park that hard drive head to reduce the risk of damage. I've heard that you can get it to work in Debian GNU/Linux, but I believe that you need to patch the kernel, at least as of now (hopefully some future kernel version will be better). I didn't bother.

For more information:

noatime

Apparently by default GNU/Linux systems (and more generally, POSIX systems, I think) keep a record of the most recent time that each file was accessed; the access time, or 'atime'. This seems to me to be kinda lame because it means that the computer has to write to the hard disk many more times than it otherwise would. You can turn this off by adding the "noatime" mount option in /etc/fstab. This might break some things; it is known to break something having to do with mutt's tracking of new email, although I forgot the details.

{{{/etc/fstab}}}

Here's my /etc/fstab:

# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/sda1       /               ext3    defaults,errors=remount-ro,noatime 0    
   1
/dev/sda4       none            swap    sw              0       0
/dev/hda        /media/cdrom0   udf,iso9660 user,noauto     0       0
/dev/sda2       /mnt/windows    ntfs-3g defaults,user,noauto 0 0
none            /tmp            tmpfs   noatime              0  0

SMART (S.M.A.R.T.) (Self-Monitoring, Analysis, and Reporting Technology)

SMART is a standard for monitoring the health of hard drives.

To install it:

aptitude install smartmontools

To use it:

smartctl

Fixing the clicking problem

I think my x61 came with a Seagate Momentus 7200.1 hard drive preinstalled. There appears to be a problem with GNU/Linux and this hard drive which can be fixed but which might be serious. Namely, it seems like the is somehow in some sort of powersaving mode by default, which causes it to spin up and spin down a lot. I have heard that this puts a lot of wear on the hard drive. The most easily observed symptom is a soft clicking noise from time to time when the hard drive is first accessed after a little while of being dormant. This click seems to correspond to spinning up the hard drive.

More information can be found in the section "Seagate Momentus 7200.1" in the web page ThinkWiki:Problem_with_hard_drive_clicking. I wrote that section of that page (although it may have been modified by the time you read it).

The solution seems to be to tell the hard drive to go into APM state 254 instead of 255 (255 is supposed to turn off power management but it doesn't seem to do so). I did this in two places; /etc/hdparm.conf and /etc/acpi/resume.d/.

First, you'll need hdparm:

aptitude install hdparm}}}

In {{{/etc/hdparm.conf}}}, I added the stanza:

{{{
/dev/sda {
         apm = 254
}

I added the file /etc/acpi/resume.d/11hdparm.sh, with the following contents:

#!/bin/sh

hdparm -B 254 /dev/sda

And then i did chmod a+x /etc/acpi/resume.d/11hdparm.sh.

The /etc/hdparm.conf entry fixes it at startup. For some reason, it gets screwed up during hibernation or sleep (I forgot which one), so the /etc/acpi/resume.d/ entry puts it back when the computer wakes up.

Disabling the forced fscks

By default, my ext3 partition insists on being fsck'd every 25 boots. I wouldn't mind this, except that I don't think you can abort the fsck even if you really want to boot up fast. So I disabled this.

tune2fs -c -1 /dev/sda1}}}

Now you'll have to manually run fsck periodically. It's supposed to be run at startup, before you (writeably) mount the hard drive. To accomplish this in Debian, as root do

{{{touch /forcefsck}}}

Now fsck will be run upon the next boot (so reboot if you want to get it over with). This works via the Debian-standard {{{/etc/init.d/checkfs.sh}}} boot script, which is called at runlevel S as "{{{/etc/rcS.d/S30checkfs.sh}}}".

Also, did you know that by default (at least in Debian) the ext3 filesystem reserves 5% of the hard drive for the use of the root user? If your harddrive gets too full you can un-reserve some of this so that ordinary users can use it using the {{{tune2fs -m}} command.




== Handwriting recognition ==
The only one I've found so far is {{{cellwriter}}}. It's in Debian Unstable, but I think it's not in Debian Stable yet.

{{{aptitude install cellwriter}}}

I like it to start up whenever XWindows starts, so I created the file {{{/etc/X11/Xsession.d/40cellwriter}}} which contains

{{{
#!/bin/sh

cellwriter > /dev/null &

Reconfiguring the buttons on the stylus

I made it so that when you press the eraser on the screen, it works like the middle mouse button. Also, when I press the button on the side of the stylus (pen), it works like the right mouse button.

To do this, I use the command xsetwacom.

To make it work this way automatically, I created the file /etc/X11/Xsession.d/40xsetwacom and put the following into it:

#!/bin/sh

xsetwacom set eraser Button1 2
xsetwacom set stylus Button2 3

You'd think that the same thing could be accomplished through adding the equivalent Options to the stylus and eraser input devices in /etc/X11/xorg.conf, but I tried that and it didn't work for me for some reason.

Sometimes xsetwacom gives me a weird error about not being able to find something, and then I have to reboot before it will work.

Making Fn-F8 kill XWindows

For some reason, sometimes my XWindows stops working. The cursor still moves, but when I try to change window focus, it won't change. Usually it ends up that no window has focus, so I can't execute commands. Cntl-Alt-F1, which usually switches out of XWindows and back to virtual terminal 1, doesn't do anything.

I've experienced it when Firefox is doing things with plugins. It's happened after watching movies. I sort of think it may also have happened while doing other stuff like running Java, but maybe I'm misremembering that.

But I noticed that keyboard-triggered ACPI events still work when this happens.

For use in these situations, I've programmed Fn-F8 to kill Xorg.

To do this, I created the file /etc/acpi/events/ibm-F8, and within it I put:

# /etc/acpi/events/ibmdiskbtn
# This is called when the user presses Fn-F8 and calls
# /etc/acpi/break.sh for further processing.

event=ibm/hotkey HKEY 00000080 00001008
action=/etc/acpi/break.sh

And then I created /etc/acpi/break.sh, which contains:

#!/bin/sh

killall Xorg

And then I did:

chmod a+x /etc/acpi/break.sh

notes (to be written up)

hotkeys

getting the "backwards" and "forwards" buttons to work in firefox

thanks to http://snarfed.org/space/thinkpad%20keys%20in%20firefox:

emacs ~/.Xmodmap

keycode 234 = F19 keycode 233 = F20

xmodmap ~/.Xmodmap #to reload

as root:

emacs /usr/share/iceweasel/chrome/browser/content/browser/browser.xul &

below: <key id="goBackKb" keycode="VK_LEFT" command="Browser:Back" modifiers="alt"/> <key id="goForwardKb" keycode="VK_RIGHT" command="Browser:Forward" modifiers="alt"/> <key id="goBackKb2" key="&goBackCmd.commandKey;" command="Browser:Back" modifiers="accel"/> <key id="goForwardKb2" key="&goForwardCmd.commandKey;" command="Browser:Forward" modifiers="accel"/>

add lines: <key id="goBackKb3" keycode="VK_F19" command="Browser:Back"/> <key id="goForwardKb3" keycode="VK_F20" command="Browser:Forward"/>

now restart firefox

the list of allowed keysyms is in /usr/share/X11/XKeysymDB? you can add keysyms to this list as long as you give each other a unique numeric ID (altho i haven't tried this myself)

check out my other .xmodmap settings

note that for special hotkeys (for example, the thinkvantage button, or the function-blue key buttons), you have to use something else. acpi is a good bet. acpi_listen as root lets you see which keys acpi gets. then you can program a handler in /etc/acpi/events, for example

  1. /etc/acpi/events/ibmlockbtn event=ibm/hotkey HKEY 00000080 00001003 action=/etc/acpi/thinkpad-lockorbattery.sh

i think you can use acpi_fakekey to make that key generate an ordinary keycode.

the reason these keys are special is that they aren't presented to the kernel as keyscans; they are special bits flipped that the "nvram" kernel module reads.

i think the "thinkpad-keys" daemon, from the "hotkey-setup" debian package, is dealing with some of these. but i can't find any config files for "thinkpad-keys", so maybe it's hardcoded.

if you want to see how X perceives a key, use the "xev" program.

if you want to see how the kernel perceives a key, use the "showkey" program.

if you want to change how the kernel maps scancodes to keycodes, use the "setkeycodes" program.

see also http://www.thinkwiki.org/wiki/How_to_get_special_keys_to_work#Mapping_keys_with_setkeycodes

/usr/share/hotkey-setup/key-constants also looks inspirational, too bad i guess that X has a different list

once you have used xmodmap to get a keysym in X (as verified with xev), you can map this key to a command with

xfce settings menu -> keyboard -> shortcuts tab

(first you have to create a new profile because you can't change the "default" one). If you want to use a text editor instead, after you've created your new profile, edit the file named (my profile is named "bshanks"):

~.config/xfce4/shortcuts/bshanks.xml

todo

aptitude install network-manager network-manager-kde adduser bshanks netdev knetworkmanager

batterybtn darker lighter

chmod a+x /usr/local/bin/xbacklight_isbrightest /etc/acpi/thinkpad-lockorbattery.sh

 ifdown eth1; ifup wlan0; iwconfig wlan0 ap anynetwork-manager

/etc/syslog.conf

http://webgui.theblackmoor.net:8082/home/linux/firefox-on-laptops

/etc/X11/Xsession.d/40xmodmap /etc/X11/Xmodmap


links


Footnotes:

1. http://www.thinkwiki.org/wiki/How_to_make_use_of_Dynamic_Frequency_Scaling links to Arjan van de Ven, who apparently is Intel's kernel developer, recommending "ondemand" for best battery life.