Post Installing Arch on an X200

From ThinkWiki
Revision as of 17:02, 1 September 2010 by Kilior (Talk | contribs) (Fan control)
Jump to: navigation, search

Preface

If your native language is Chinese or you are good at Chinese, I strangely recommend you read the Chinese version of this page

In this page, I will NOT tell you how too install ArchLinux in X200, but something make X200 work better after ArchLinux installation.

If you don't know how to install ArchLinux to your X200, ArchWiki,and Installing Arch on an X200. So if you reach here, I think you have installed ArchLinux to you X200 with desktop environment. If you think the tools in this page isn't the best one, or can't use in your desktop environment, please edit the page, and show your tools to us.

Prepare kernel modules

package: tp_smapi

You can install this package through yaourt, but the source is not patched for X200. So we need to patch the source.

in file hdaps.c

Search "X61" and add following line between " HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad X61", HDAPS_ORIENT_SWAP | HDAPS_ORIENT_INVERT_X)," and "};"

add:

      HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad X200", HDAPS_ORIENT_SWAP | HDAPS_ORIENT_INVERT_X | HDAPS_ORIENT_INVERT_Y),
      { .ident = NULL }

After you patch source, you can repack the source, edit PKGBUILD, use makepkg to build the package.

Or you can make it step by step

    $HDAPSD=true make
    #make install
    #depmod -a

Configure modules

1 fan control:

file /etc/modprobe.d/modprobe.conf, add one line:

     options thinkpad_acpi fan_control=1

2 audio:

     options snd-hda-intel model=lenovo-x200 enable_msi=1

3 autoload modules:

     tp_smapi hdaps acpi-cpufreq

Sensors

Package: lm_sensors、sensors-applet (gnome_applet)、hddtemp

Add hddtemp to DAEMON, run sensors-detect to detect sensors, add sensors-applet to panel.

Fan control

Package: tpfand tpfan-admin(This package may not work well)

Add tpfand to DAEMON. If tpfan-admin can't work, you can write a profile yourself or install tpfand-profiles

After ArchLinux update Xorg to version 1.8, hal can remove from DAEMON. But this make tpfand doesn't work.

Simply edit the source can make tpfand works well.

File /usr/lib/python2.6/site-packages/tpfand/settings.py

change the part of code

   def read_model_info(self):
       """reads model info from HAL"""
       try:
           bus = dbus.SystemBus()           
           computer_obj = bus.get_object('org.freedesktop.Hal', '/org/freedesktop/Hal/devices/computer')
           computer = dbus.Interface(computer_obj, 'org.freedesktop.Hal.Device')
          
           product_id = computer.GetProperty('system.hardware.vendor') + "_" + computer.GetProperty('system.hardware.product')
           self.product_id = product_id.lower()
           product_name = computer.GetProperty('system.hardware.vendor') + "_" + computer.GetProperty('system.hardware.version')
           self.product_name = product_name.lower().replace('/', '-').replace(' ', '_')
          
           self.product_pretty_vendor = computer.GetProperty('system.hardware.vendor')
           self.product_pretty_name = computer.GetProperty('system.hardware.version')
           self.product_pretty_id = computer.GetProperty('system.hardware.product')
       except:
           print "Warning: unable to get your system model from HAL."
           self.product_id = None
           self.product_name = None
           self.product_pretty_vendor = None
           self.product_pretty_name = None
           self.product_pretty_id = None   

TO

    #    try:
    #       bus = dbus.SystemBus()           
    #       computer_obj = bus.get_object('org.freedesktop.Hal', '/org/freedesktop/Hal/devices/computer')
    #       computer = dbus.Interface(computer_obj, 'org.freedesktop.Hal.Device')
               
    #       product_id = computer.GetProperty('system.hardware.vendor') + "_" + computer.GetProperty('system.hardware.product')
    #       self.product_id = product_id.lower()
    #       product_name = computer.GetProperty('system.hardware.vendor') + "_" + computer.GetProperty('system.hardware.version')
    #       self.product_name = product_name.lower().replace('/', '-').replace(' ', '_')
          
    #       self.product_pretty_vendor = computer.GetProperty('system.hardware.vendor')
    #       self.product_pretty_name = computer.GetProperty('system.hardware.version')
    #       self.product_pretty_id = computer.GetProperty('system.hardware.product')
    #    except:
    #       print "Warning: unable to get your system model from HAL."
         self.product_id = u'LENOVO_74574AC'
         self.product_name = u'LENOVO_ThinkPad X200'
         self.product_pretty_vendor = dbus.String(u'LENOVO')
         self.product_pretty_name = dbus.String(u'ThinkPad X200')
         self.product_pretty_id = dbus.String(u'74574AC')

The last 5 lines you should replace them to yours. You can get them by python or from the bottom side of your X200.

Wheel Emulation

New file /etc/X11/xorg.conf.d/10-wheel-emulation.conf

   # Accelerometer device, posts data through ABS_X/ABS_Y, making X unusable
   # http://bugs.freedesktop.org/show_bug.cgi?id=22442
   Section "InputClass"
       Identifier "Trackpoint Wheel Emulation"
       MatchProduct "TPPS/2 IBM TrackPoint|DualPoint Stick|Synaptics Inc. Composite TouchPad / TrackPoint|ThinkPad USB Keyboard with TrackPoint|USB Trackpoint pointing device"
       MatchDevicePath   "/dev/input/event*"
       Option      "EmulateWheel"      "true
       Option      "EmulateWheelButton"   "2"
       Option      "Emulate3Buttons"   "false"
       Option      "XAxisMapping"      "6 7"
       Option      "YAxisMapping"      "4 5"
   EndSection

HDAPS

Packages: hdapsd hdaps-gl thinkhdaps

Add hdapsd to DAEMON, add thinkhdaps to gnome gnome startup programs.

Laptop Mode

Package: laptop-mode-tools

Add laptop-mode to DAEMON, add edit file /etc/laptop-mode/laptop-mode.conf, change ENABLE_AUTO_MODULES' value to 1

Protect Battery

Make battery charge cycle grows slowly, we should change some value in sysfs.

New file: /etc/sysfs.conf

   # Make battery live longer
   devices/platform/smapi/BAT0/start_charge_thresh = 50
   devices/platform/smapi/BAT0/stop_charge_thresh = 90

OR

   # Make battery live longer
   devices/platform/smapi/BAT0/start_charge_thresh = 10
   devices/platform/smapi/BAT0/stop_charge_thresh = 100

(choose one you like, and I use the first one)

New file: /etc/rc.d/sysfsutils

   #! /bin/sh -e
   
   ### BEGIN INIT INFO
   # Provides:          sysfsconf
   # Required-Start:    mountkernfs
   # Should-Start:      udev module-init-tools loadcpufreq
   # Required-Stop:
   # Default-Start:     2 3 4 5
   # Default-Stop:
   # Short-Description: Set sysfs variables from /etc/sysfs.conf
   # Description:       Similarly to /etc/init.d/procps.sh, you can configure
   #                    values for sysfs variables (such as power management
   #                    defaults) and /sys file permissions in /etc/sysfs.conf.
   ### END INIT INFO
   
   # /etc/rc.d/sysfsutils:
   #
   # (c) 2005 Martin Pitt <mpitt@debian.org>
   
   CONFFILE=/etc/sysfs.conf
   
   
   [ -r "$CONFFILE" ] || exit 0
   
   . /etc/rc.conf
   . /etc/rc.d/functions
   
   case "$1" in
       start)
       stat_busy "Setting sysfs variables..."
   
      sed  's/#.*$//; /^space:*$/d;
             s/^space:*\([^=[:space:]]*\)space:*\([^=[:space:]]*\)space:*=space:*\(.*\)/\1 \2 \3/' \
                 $CONFFILE | {
          while read f1 f2 f3; do
                   if [ "$f1" = "mode" -a -n "$f2" -a -n "$f3" ]; then
                       if [ -f "/sys/$f2" ]; then
                           chmod "$f3" "/sys/$f2"
                       else
                           stat_fail
                       fi
                   elif [ "$f1" = "owner" -a -n "$f2" -a -n "$f3" ]; then
                       if [ -f "/sys/$f2" ]; then
                           chown "$f3" "/sys/$f2"
                       else
                           stat_fail
                       fi
                   elif [ "$f1" -a -n "$f2" -a -z "$f3" ]; then
                       if [ -f "/sys/$f1" ]; then
                           # Some fields need a terminating newline, others
                           # need the terminating newline to be absent :-(
                            echo -n "$f2" > "/sys/$f1" 2>/dev/null ||
                            echo "$f2" > "/sys/$f1"
                       else
                           stat_fail
                       fi
                   else
                       stat_fail
                       exit 1
                   fi
          done
      }
   
      stat_done
      ;;
      stop)
      ;;
      *)
      echo "Usage: /etc/rc.d/sysfsutils {start|stop}"
      exit 1
      ;;
   esac
Help needed
I don't know how to use wikieditor, so the script displays wrongly.
   #chmod +x /etc/rc.d/sysfsutils

Add sysfsutils to DAEMON.

Profiles I am using

a: rc.conf

   MODULES=(!snd_pcm_oss !snd_mixer_oss !snd_seq_oss !thinkpad_ec tp_smapi hdaps acpi-cpufreq)
   DAEMONS=(syslog-ng dbus acpid hdapsd tpfand networkmanager hddtemp alsa laptop-mode sysfsutils)

b: tpfand.conf

   enabled = True
   override_profile = True
   
   0. CPU = 0:0 45:3 60:6
   1. Mini PCI = 0:0 50:3
   2. Sensor 2 = 0:255
   3. GPU = 0:0 50:3
   4. Bat0 = 0:0 35:2
   5. Sensor 5 = 0:255
   6. Bat1 = 0:0 35:2
   7. Sensor 7 = 0:255
   8. MB? = 0:0 45:2 60:4
   9. MB? = 0:0 55:3
   10. Sensor 10 = 0:255
   11. Sensor 11 = 0:255
   12. Sensor 12 = 0:255
   13. Sensor 13 = 0:255
   14. Sensor 14 = 0:255
   15. Sensor 15 = 0:255
   
   hysteresis = 2
   interval_speed = 2
   interval_duration = 500.000000
   interval_delay = 5000.000000