筆記本上使用Archlinux[轉]

筆記本上使用Archlinux來自: http://arithboy.org/wiki/gnu/arch/Laptop.html

近日購得二手筆記本一臺,在其上運行linux的一些設置記錄以下: 型號爲 <nop>ThinkPad T30html

tp 上功能鍵的使用

個人.xmodmaprclinux

keycode 227 = F30
keycode 234 = F19
keycode 233 = F20
keycode 77 = Num_Lock

remove Lock = Caps_Lock
remove Control = Control_L
remove Mod4 = Hyper_L
keycode 227 = Caps_Lock
keysym Control_L = Hyper_L
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L
add Mod4 = Hyper_L以上把兩個翻頁鍵設爲F19和F20,把Fn設爲F30,使shift+scrlk正常工做.<br> 把caps lock鍵用於ctrl鍵,左ctrl鍵用於窗口管理器.Fn用於大小寫切換.<br> Fn作窗口管理器的modifier我沒成功,可能主板?已經截獲掉好多組合鍵了 Contents
網絡環境的配置
laptop-mode的配置
設置筆記本的待機
cpu自動降頻
監測硬盤,cpu,電池等
thinkpad筆記本的熱鍵設置
DPMS的使用
top 網絡環境的配置首先添加udev規則,解決兩個網卡的順序問題.<BR> 編輯/etc/udev/rules.d/10-network.rulesSUBSYSTEM=="net", SYSFS{address}=="00:02:8a:47:f4:a5", NAME="wlan0"
SUBSYSTEM=="net", SYSFS{address}=="00:09:6b:06:a5:b4", NAME="lan0"

筆記本上常常移動,須要多套網絡的配置.<BR> 編輯rc.confios

...
HOSTNAME="localhost"
lo="lo 127.0.0.1"
INTERFACES=(lo)
NET_PROFILES=(menu)
...將NET_PROFILES=(menu)打開,在/etc/network-profiles/中添加配置文件.

例如文件/etc/network-profiles/20-home正則表達式

DESCRIPTION="home"
INTERFACE=lan0
HOSTNAME=localhost
IFOPTS="219.242.113.92 netmask 255.255.255.0 broadcast 219.242.113.255 hw ether 00132051A785"
GATEWAY=219.242.113.1
DNS1=202.112.144.30使用sudo /etc/rc.d/network restart則可更改網絡設置,/etc/resolv.conf的值會被更新.<BR> 當有多個配置時,文件名以字典序排列,數字開頭則比較方便,數字最小的爲默認網絡配置. top laptop-mode的配置

安裝 laptop-mode-tools 軟件包.windows

編輯文件/etc/laptop-mode/laptop-mode.conf 默認設置已經可以知足須要了,只要把CONTROL_開頭的打開便可, 裏面包含了硬盤,cpu等多方面的設置,能極大延長電池的使用時間, 推薦使用.網絡

top 設置筆記本的待機

安裝acpid,機器待機時,背光仍然打開,主要是使用radeon的顯卡可能會有這個問題. 詳細的描述見1,使用radeontool解決該問題,腳本2以下:ide

#!/bin/sh

# if launched through a lid event and lid is open, do nothing
echo "$1" | grep "button/lid" && grep -q open /proc/acpi/button/lid/LID/state && exit 0

# remove USB 1.1 driver
rmmod uhci_hcd

# sync filesystem and clock
sync
/sbin/hwclock --systohc

# switch to console
FGCONSOLE=`fgconsole`
chvt 6
/usr/sbin/radeontool light off

# go to sleep
sleep 5 && echo -n "mem" > /sys/power/state

# readjust the clock (it might be off a bit after suspend)
/sbin/hwclock --adjust
/sbin/hwclock --hctosys

# reload USB 1.1 driver
modprobe uhci_hcd

# turn on the backlight and switch back to X
radeontool light on
chvt $FGCONSOLE將腳本保存在/etc/acpi/actions/sleep.sh,並chmod +x sleep.sh

修改/etc/acpi/handler.sh 按下sleep按鍵時(我這裏是Fn+F4)執行sleep.sh,進入待機測試

...
button/sleep)
case "$2" in
SLPB) #echo -n mem >/sys/power/state ;;
/etc/acpi/actions/sleep.sh;;#註釋掉上句,添加這句
...合上屏幕時,待機...
button/lid)
#echo "LID switched!">/dev/tty5
/etc/acpi/actions/sleep.sh #添加這句
;;
...修改腳本之後,重起服務便可生效./etc/rc.d/acpid restart

有個問題就是待機時usb口仍然供電,在windows下則無此現象.ui

top cpu自動降頻查找所須要的模塊modprobe -l |grep cpufreq
/lib/modules/2.6.17-ARCH/kernel/drivers/cpufreq/cpufreq_powersave.ko
/lib/modules/2.6.17-ARCH/kernel/drivers/cpufreq/cpufreq_stats.ko
/lib/modules/2.6.17-ARCH/kernel/drivers/cpufreq/cpufreq_userspace.ko
/lib/modules/2.6.17-ARCH/kernel/drivers/cpufreq/cpufreq_ondemand.ko
/lib/modules/2.6.17-ARCH/kernel/drivers/cpufreq/cpufreq_conservative.ko
/lib/modules/2.6.17-ARCH/kernel/drivers/cpufreq/freq_table.ko
/lib/modules/2.6.17-ARCH/kernel/arch/i386/kernel/cpu/cpufreq/longrun.ko
/lib/modules/2.6.17-ARCH/kernel/arch/i386/kernel/cpu/cpufreq/powernow-k8.ko
/lib/modules/2.6.17-ARCH/kernel/arch/i386/kernel/cpu/cpufreq/powernow-k7.ko
/lib/modules/2.6.17-ARCH/kernel/arch/i386/kernel/cpu/cpufreq/powernow-k6.ko
/lib/modules/2.6.17-ARCH/kernel/arch/i386/kernel/cpu/cpufreq/speedstep-smi.ko
/lib/modules/2.6.17-ARCH/kernel/arch/i386/kernel/cpu/cpufreq/speedstep-lib.ko
/lib/modules/2.6.17-ARCH/kernel/arch/i386/kernel/cpu/cpufreq/speedstep-ich.ko
/lib/modules/2.6.17-ARCH/kernel/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.ko
/lib/modules/2.6.17-ARCH/kernel/arch/i386/kernel/cpu/cpufreq/p4-clockmod.ko
/lib/modules/2.6.17-ARCH/kernel/arch/i386/kernel/cpu/cpufreq/cpufreq-nforce2.ko
/lib/modules/2.6.17-ARCH/kernel/arch/i386/kernel/cpu/cpufreq/gx-suspmod.ko
/lib/modules/2.6.17-ARCH/kernel/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.ko個人cpu是P4M1.6GHZ,選擇speedstep-ich.ko,同時須要cpufreq governors: 我這裏顯示有5個能夠選擇 userspace, powersave, ondemand, conservative, perform ance.

cpu降頻的軟件包有cpufreqd和cpufrequtils,後來發現laptop-mode-tools裏面直接能夠控制cpu頻率和throttling.推薦使用這個.this

須要在rc.conf中添加speedstep-ich和ondemand

top 監測硬盤,cpu,電池等arch中監測支持smart硬盤溫度軟件有smartmontools和hddtemp,第一個監測的功能不少,咱們使用第二個,[arch@localhost proc]$ sudo hddtemp -n /dev/hda
51

監測cpu頻率,溫度,電池等. 這些信息都在/proc/acpi中,通常窗口管理器裏面自帶腳本/插件均可以監測,若沒用的話,使用某個腳本語言,用正則表達式抓取數據也是很容易的. conky能夠將數據輸出到桌面.

這裏有一個ion下檢測系統信息的腳本

top thinkpad筆記本的熱鍵設置主要使用 ibm_acpi模塊,其它品牌筆記本不適用.<BR> 添加ibm_acpi到rc.conf中的MODULES,在/etc/modprobe.conf 添加options ibm_acpi hotkey=enable,0xffff experimental=1指定加載模塊時的參數,hotkey=enable,0xffff指明使用盡量多的快捷鍵,experimental=1打開一些在測試中的功能,如控 制cpu風扇等,啓用hotkey功能後,Fn+F4組合鍵將不產生sleep的acpi的事件,而是ibm/hotkey事件.

這樣運行 acpi_listen後,能夠監測Fn+F1-F12中那些組合產生acpi的事件,我這裏是 F3,F4,F7,F8,F12.我將F3設置爲開關屏幕,F4爲待機,F7爲切換顯示器,F8爲關閉bay(用來熱拔插光驅或第2塊電池),F12設置爲關機.

咱們使用radeontool來切換,它沒有監測lcd狀態的功能,可使用腳原本簡單判斷lcd的狀態.

/etc/acpi/actions/lcd_switch.sh

#!/bin/sh

flag=/tmp/thinkpad_lcd_off

if [ -e $flag ]; then
/usr/sbin/radeontool light on
rm -f $flag
else
/usr/sbin/radeontool light off
> $flag
fi注意要chmod +x lcd_switch.sh

切換顯示器使用

echo video_switch > /proc/acpi/ibm/video關閉bay使用echo eject > /proc/acpi/ibm/bay

修改handler.sh

...
ibm/hotkey)
case "$2" in
HKEY)
case "$4" in
00001003) #echo "f3" >/dev/tty5
/etc/acpi/actions/lcd_switch.sh
;;
00001004) #echo "f4" >/dev/tty5
/etc/acpi/actions/sleep.sh
;;
00001007) #echo "f7" >/dev/tty5
echo video_switch > /proc/acpi/ibm/video
;;
00001008) #echo "f8" >/dev/tty5
echo eject > /proc/acpi/ibm/bay
;;
0000100c) #echo "f12" >/dev/tty5
/sbin/halt
;;
esac
;;
*) logger "ibm_acpi undefined:$2";;
esac
;;
...使用tpb能夠在屏幕上顯示音量等信息,還能夠設置thinkpad等熱鍵. top DPMS的使用

修改xorg.conf在Section "Monitor" 中添加 Option "DPMS",在 Section "ServerLayout" 中添加

Option "StandbyTime" "20" # Turn off screen in 20 minutes
Option "SuspendTime" "30" # Full hibernation in 30 minutes
Option "OffTime" "40" # Turn off DPMS monitor使用xset dpms force standby能夠當即查看效果.

我這裏dpms一直沒法使用,將驅動從"versa"換爲"radeon"(軟件包爲 xf86-video-ati)後dpms正常,使用versa時,使用mplayer播放某些rmvb時,cpu佔用率很高,可是畫面和聲音不一樣步. mplayer提示"Your system is too SLOW to play this! "使用"radeon"再增長cache的值,能夠解決.

xorg.conf部分配置,參考34

Section "Device"
Identifier "Card0"
Driver "radeon"
Option "AGPMode" "4"
Option "EnablePageFlip" "on"
Option "Ahod" "EXA"

Option "AGPFastWrite" "yes"
Option "ColorTiling" "on"
Option "RenderA" "on"
#Option "OverlayOnCRTC1" "on"
#Option "OverlayOnCRTC2" "on"
# enable (partial) PowerPlay features
Option "DynamicClocks" "on"
# use bios hot keys on thinkpad (aka fn+f7)
Option "BIOSHotkeys" "on"
# enable radeon specific xinerama
#Option "MergedFB" "true"
#Option "CRT2Position" "RightOf"
#Option "CRT2Hsync" "50-75"
#Option "CRT2VRefresh" "30-82"
#Option "MetaModes" "1024x768-1024x768"
#Option "MergedNonRectangular" "true"
#BusID "PCI:1:0:0"
EndSectionmplayer -cache 16000 abc.rmvb radeontool的PKGBUILDpkgname=radeontool
pkgver=1.5
pkgrel=2
pkgdesc=
url="http://fdd.com/software/radeon/"
license=GPL
depends=('pciutils')
makedepends=()
backup=()
source=( http://fdd.com/software/radeon/$pkgname-$pkgver.tar.gz)
md5sums=(8065eebe5a2b163e43b40461bfe49a56)

build() {
cd $startdir/src/$pkgname-$pkgver
make || return 1
mkdir -p $startdir/pkg/usr/sbin
cp $pkgname $startdir/pkg/usr/sbin
}

1. http://www.thinkwiki.org/wiki/How_to_configure_acpid<br />

2. http://www.thinkwiki.org/wiki/How_to_configure_acpid#Action_Script<br />

3. http://dri.freedesktop.org/wiki/ATIRadeon<br />

4. http://thinkwiki.org/wiki/Additional_options_for_the_radeon_driver

相關文章
相關標籤/搜索