Posts from July 2008

Back light keys on IBM/Lenovo Thinkpad X60t

I just got back light keys to work on my Thinkpad X60t. This is actually pretty easy. If I just had read the documentation for thinkpad_acpi before I would have known.

Anyways lets get to it.

First we need to modprobe thinkpad_acpi with some arguments, otherwise the back light Fn-key combo will not show up as acpi events, and then we will not be able to control the back light.


modprobe thinkpad_acpi brightness_enable=1 hotkey=enable,0xffffff

You probably want to do that on every boot, in gentoo you do that by adding the following to /etc/conf.d/modules:


modules_2_6="${modules_2_6} thinkpad_acpi"
module_thinkpad_acpi_args_2_6="brightness_enable=1 hotkey=enable,0xffffff"

When that is done we can start grabbing some events with acpi_listen, mine looks like this:


tomasz@arcadia ~ $ acpi_listen
ibm/hotkey HKEY 00000080 00001011
ibm/hotkey HKEY 00000080 00001010

First one is for down second for up.

Now we know this we can make some files for acpid to react on when we push the Fn-key combo for either back light up or down.

/etc/acpi/events/backlight-up:


# called when brightness up key combo is pressed
event=ibm/hotkey HKEY 00000080 00001010
action=/etc/acpi/actions/backlight-up

/etc/acpi/events/backlight-down:


# called when brightness down key combo is pressed
event=ibm/hotkey HKEY 00000080 00001011
action=/etc/acpi/actions/backlight-down

Now we need some actions. I made a couple of simple bash scripts that looks at the current state of the back light level and subtracts or adds 1 to the level. You can control the level either in /sys/class/backlight/thinkpad_screen/brightness or in /proc/acpi/ibm/brightness the latter is as far as I know deprecated, so I am not going to use that.

So here are the scripts:

/etc/acpi/actions/backlight-down:


#! /bin/bash
# A little simple script to control backlight on a Thinkpad X60 Tablet

# Check current state
typeset -i state=`cat /sys/class/backlight/thinkpad_screen/brightness`
# Subtract one from the current state and echo it to the file
down=$((state-=1))
echo "$down" > /sys/class/backlight/thinkpad_screen/brightness

/etc/acpi/actions/backlight-up:


#! /bin/bash
# A little script to control backlight on a Thinkpad X60 Tablet

# Check current state
typeset -i state=`cat /sys/class/backlight/thinkpad_screen/brightness`
# Add one to the current state and echo it to the file
state+=1
echo "$state" > /sys/class/backlight/thinkpad_screen/brightness

Reload acpid and see if it works.


/etc/init.d/acpid restart

This should be it!

Installed reCAPTCHA

I recently got a very large amount of user registrations and I also get a lot of spam comments, though the get catched by akismet, and I verify the comments before they get added. But since I now have installed reCAPTCHA, that adds a confirmation about the person writing the comment or signing up as a user, is human – I guess it is not necessary to manually confirm every comment anymore.

From now comments should appear after you have written them.

How to get Framebuffer to work on IBM/Lenovo X60t

I finally got the framebuffer to work on my X60t, though it took a bit effort to get working.

What you need is to use uvesafb, which was introduced in kernel 2.6.24. Though to get make it to work properly you need the packages dev-libs/klibc and sys-apps/v86d, and it is these packages that are tricky since they are still a bit buggy.

To install klibc you need the patch from bug 212531 that uses the C implementation for memmove.c instead of the new assembly implementation. If you can not find it get it here: klibc-1.5.11-klibcmemmove.patch
Add it to the klibc-1.5.11 ebuild, by adding the following line in the src_unpack() section:

epatch "${FILESDIR}"/${PN}-1.5.11-klibcmemmove.patch || die "Failed to patch memmove"

Now compile it.

After it is done, compile v86d with -O0 cflag, otherwise it will not work! I compiled it the following way:

CFLAGS="-march=prescott -mtune=generic -O0 -pipe -fomit-frame-pointer" emerge v86d

We are almost done. Now to the kernel.


        General Setup  --->
                [*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
                (/usr/share/v86d/initramfs) Initramfs source file(s)

        Device Drivers  --->
                <*> Connector - unified userspace <-> kernelspace linker  --->

                Graphics support  --->
                        <*> Support for frame buffer devices  --->
                                <*>   Userspace VESA VGA graphics support

Those settings are:
CONFIG_CONNECTOR=y
CONFIG_FB_UVESA=y
CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE=”/usr/share/v86d/initramfs”

Compile the kernel and add following line to grub.conf at the end of the kernel line:

video=uvesafb:1400x1050-32,mtrr:3,ywrap

Reboot and now you should have a nice framebuffer.

EDIT: I have also added it to Gentoo-wiki

lsof -i; list information about Internet and network files

I talked to a person on IRC, who had a problem with his computer spamming his service provider with UDP packets. He solved his problem by using lsof -i, which lists information about Internet and network files.

Using more options for the -i parameter can give a more specific list of information.


                [46][protocol][@hostname|hostaddr][:service|port]

                where:
                     46 specifies the IP version, IPv4 or IPv6
                          that applies to the following address.
                          ’6’ may be be specified only if the UNIX
                          dialect supports IPv6.  If neither ’4’ nor
                          ’6’ is specified, the following address
                          applies to all IP versions.
                     protocol is a protocol name - TCP or UDP.
                     hostname is an Internet host name.  Unless a
                          specific IP version is specified, open
                          network files associated with host names
                          of all versions will be selected.
                     hostaddr is a numeric Internet IPv4 address in
                          dot form; or an IPv6 numeric address in
                          colon form, enclosed in brackets, if the
                          UNIX dialect supports IPv6.  When an IP
                          version is selected, only its numeric
                          addresses may be specified.
                     service is an /etc/services name - e.g., smtp -
                          or a list of them.
                     port is a port number, or a list of them.

Here is a sample:


tomasz@arcadia ~ $ lsof -i
COMMAND  PID   USER   FD   TYPE DEVICE SIZE NODE NAME
xchat   5362 tomasz   10u  IPv4  22056       TCP 192.168.1.107:54186->censored.dk:ircd (ESTABLISHED)
xchat   5362 tomasz   15u  IPv4  22063       TCP 192.168.1.107:47961->springtide.springtide.ca:ircd (ESTABLISHED)
xchat   5362 tomasz   20u  IPv4  22070       TCP 192.168.1.107:38401->underworld.rizon.no:6697 (ESTABLISHED)
xchat   5362 tomasz   25u  IPv4  22077       TCP 192.168.1.107:45011->efnet.pte.hu:9999 (ESTABLISHED)
xchat   5362 tomasz   30u  IPv4  22084       TCP 192.168.1.107:59340->jobe.wgops.com:ircd (ESTABLISHED)
pidgin  5372 tomasz   11u  IPv4  22337       TCP 192.168.1.107:60255->by1msg2175306.phx.gbl:1863 (ESTABLISHED)
pidgin  5372 tomasz   12u  IPv4  22298       TCP 192.168.1.107:45727->2605ds1-ynoe.1.fullrate.dk:xmpp-client (ESTABLISHED)
pidgin  5372 tomasz   16u  IPv4 168971       TCP 192.168.1.107:41941->by2msg2132817.phx.gbl:1863 (ESTABLISHED)
pidgin  5372 tomasz   17u  IPv4 168311       TCP 192.168.1.107:59297->by2msg1231704.phx.gbl:1863 (ESTABLISHED)

lsof can not only list information about Internet and network files, but list file information opened by processes and help solving problems in general. Just wanted you to know this cool application.

IBM/Lenovo Thinkpad X60t Gentoo installation guide now on gentoo-wiki

Go visit: http://gentoo-wiki.com/HARDWARE_Lenovo_Thinkpad_X60t for my installation guide on how to get the hardware and drivers work in Gentoo Linux work.