Archive for the ‘Linux’ Category
Linux 上的 Quicksilver
Quicksilver 是 mac 上好用的輔助軟體,可以在圖形介面下享受命令列直接執行指令的快感,相關介紹請見 zonble 跟 orcas 的 blog。
Gnome 下有人寫了 Quicksilver 的 clone,Gnome-Do,安裝的時候需要 mono,所以應該是以 .Net 完成的,使用起來應該跟 Quicksilver 差不多吧(沒用過快銀),連介面都非常相似,也可以自己寫 plugin =)
ps. 聽說 Quicksilver 變成 opensource 了?不過網站怎麼跑到 127.1.1.1 去了.. Orz
gcc-4.3 & linux kernel
答案就是:gcc-4.3 還不能拿來 compile kernel.. 因為會用到沒有定義的 libgcc function.
錯誤如下:
CC arch/i386/lib/msr-on-cpu.o
LD arch/i386/lib/built-in.o
CC arch/i386/lib/bitops.o
AS arch/i386/lib/checksum.o
CC arch/i386/lib/delay.o
AS arch/i386/lib/getuser.o
CC arch/i386/lib/memcpy.o
CC arch/i386/lib/mmx.o
AS arch/i386/lib/putuser.o
AS arch/i386/lib/semaphore.o
CC arch/i386/lib/string.o
CC arch/i386/lib/strstr.o
CC arch/i386/lib/usercopy.o
AR arch/i386/lib/lib.a
GEN .version
CHK include/linux/compile.h
UPD include/linux/compile.h
CC init/version.o
LD init/built-in.o
LD .tmp_vmlinux1
kernel/built-in.o: In function `getnstimeofday':
(.text+0x1d927): undefined reference to `__umoddi3'
kernel/built-in.o: In function `do_gettimeofday':
(.text+0x1d9e9): undefined reference to `__udivdi3'
kernel/built-in.o: In function `do_gettimeofday':
(.text+0x1da0c): undefined reference to `__umoddi3'
kernel/built-in.o: In function `timekeeping_resume':
timekeeping.c:(.text+0x1db18): undefined reference to `__udivdi3'
timekeeping.c:(.text+0x1db3b): undefined reference to `__umoddi3'
kernel/built-in.o: In function `update_wall_time':
(.text+0x1e214): undefined reference to `__udivdi3'
kernel/built-in.o: In function `update_wall_time':
(.text+0x1e237): undefined reference to `__umoddi3'
kernel/built-in.o: In function `update_wall_time':
(.text+0x1e2d3): undefined reference to `__udivdi3'
kernel/built-in.o: In function `update_wall_time':
(.text+0x1e2fd): undefined reference to `__umoddi3'
make[1]: *** [.tmp_vmlinux1] Error 1
make[1]: Leaving directory `/usr/src/linux-source-2.6.23'
make: *** [debian/stamp-build-kernel] Error 2
參考:
Xorg 1.4 XInput Hotplug
Xorg 1.4 開始支援 hal based 的 xinput hotplug,也就是說滑鼠跟鍵盤這些設備可以拔來拔去而不用在 xorg.conf 裡面設定,再加上越來越多 driver 可以 auto-configuration,xorg.conf 裡面的東西越來越少了。
xorg 的 evdev driver 是利用 linux kernel 的 evdev 支援,來使用滑鼠、鍵盤等多種設備,我的 Logitech V450 就一定要用 evdev 才能支援所有的按鍵。
無奈 Debian Sid 中的 Xorg 以及 evdev 都非常的新,但是一些升級的配套措施跟文件跟不上,導致最近發生許多問題,相關的 bug report 有 #443292、#442316。
今天終於把滑鼠鍵盤都設定好了,關鍵在於 hal 的設定跟 gnome 的設定。
首先是設定 hal,因為 hal 預設只設定了使用 evdev,但是沒有顧慮到非使用 us layout 的人,導致升級之後鍵盤 layout 大亂,目前暫時取消了這項設定,我們可以從 /usr/share/doc/hal/examples/10-x11-input.fdi 把設定撿回 /etc/hal/fdi/policy/,內容如下:
<?xml version="1.0" encoding="ISO-8859-1"?>
<deviceinfo version="0.2">
<device>
<!-- FIXME: Support tablets too. -->
<match key="info.capabilities" contains="input.mouse">
<merge key="input.x11_driver" type="string">mouse</merge>
<match key="/org/freedesktop/Hal/devices/computer:system.kernel.name"
string="Linux">
<merge key="input.x11_driver" type="string">evdev</merge>
</match>
</match>
<match key="info.capabilities" contains="input.keys">
<!-- If we're using Linux, we use evdev by default (falling back to
keyboard otherwise). -->
<merge key="input.x11_driver" type="string">keyboard</merge>
<match key="/org/freedesktop/Hal/devices/computer:system.kernel.name"
string="Linux">
<merge key="input.x11_driver" type="string">evdev</merge>
<merge key="input.xkb.rules" type="string">xorg</merge>
<merge key="input.xkb.model" type="string">evdev</merge>
<merge key="input.xkb.layout" type="string">dvorak</merge>
</match>
</match>
</device>
</deviceinfo>
其中關於鍵盤 layout、model、rules 的設定是我加上去的。滑鼠不需更動即可 hotplug 使用。
接下來關鍵的地方是,如果你使用 gnome 的話,記得把 keyboard model 改成 evdev,如圖:
最後,xorg.conf 就可以清乾淨了:
Section "Device"
Identifier "intel"
Driver "intel"
Option "AccelMethod" "XAA"
Option "XAANoOffScreenPixmaps" "True"
EndSection
Section "InputDevice"
Identifier "Synaptics Touchpad"
Driver "synaptics"
Option "CorePointer"
Option "Device" "/dev/input/event9"
Option "Protocol" "auto-dev"
Option "SHMConfig" "on"
Option "LeftEdge" "1100"
Option "RightEdge" "5800"
Option "TopEdge" "1600"
Option "BottomEdge" "4200"
Option "HorizEdgeScroll" "on"
EndSection
Section "Monitor"
Identifier "Configured Monitor"
Option "DPMS"
DisplaySize 330 200
EndSection
Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
DefaultDepth 24
SubSection "Display"
Modes "1280x768" "1024x768"
EndSubSection
EndSection
HPET
裝了 linux-kernel 2.6.24-rc2,從來沒出現過的 HPET 突然可以用了,總算可以進入 C3 的狀態,估計這樣電池可以再撐久一點。
可是 capacity 已經只剩 52% 了… (嘆
Debian 開機速度調教
看了 Yuren 的這篇,不禁手癢,也想幫我的伙伴調整一下增進開機速度。首先沒用過 bootchart,以前總以為要 patch 一些東西才能用,沒想到其實只要 apt-get install bootchart 就可以用了 XD
首先是沒有調整過的 bootchart:

在搜尋 bootchart 資料時,找到了這個 Debian 的 SoC 計劃,裡面有各項關於調整開機速度的建議,一項一項試,試了大概有數十次吧,最後終於找到最好的方案:
- 把 /bin/sh 連結到 dash,只要下
dpkg-reconfigure dash就可以了 - 裝好 insserv 之後,下
update-bootsystem-insserv,重新排列 rcX.d 底下的 script 順序 - 修改 /etc/default/rcS 裡面的設定,
CONCURRENCY=shell(原來現在的 initscripts 已經支援 parallel 執行) - 修改
hwclock.sh跟hwclockfirst.sh,讓他們在背景執行 - 開機時,不要加
vga=791參數
減少的時間主要都是來自以上的修改,之後還試過整理多餘的 /etc/init.d/ scripts,試用 ubuntu 的 readahead 程式,prlink gdm 等,都沒有更多的進步…
這是最後的 bootchart:

時間從 39 s 變成 29 s,嗯… 不錯不錯,進步滿多的,不過我覺得應該還可以再進步,只是我不知道該怎麼調了 XD
Prototype
設定 IPv6
從 IPv6 被提出到現在以經過很久了,最近漸漸有看到實際的應用,像是 IRC, 地下 FTP 站等等 XD
看著 IRC 登入時顯示的 IP 變成 ipv6 其實滿有趣的,還可以躲掉學校一些管制,那要如何獲得 global 的 ipv6 IP 呢?
我自己是使用 tspc 這個套件,他會跟 freenet6 這個 broker 建立 ipv6 的 tunnel,藉由 ipv4 先到 router 後進入 ipv6 網路,如果你有到 freenet6 申請帳號的話,還可以利用這組帳號,每次都獲得一樣的 IP,這樣就可以拿來架站了。國內也有一些 ipv6 broker,像是中研院也是使用 tspc 來連線,另外還有一個 aiccu 套件是使用 SixXS 的服務,不過我沒有用過,申請的步驟好像比較繁瑣。
取得 IP 後,就可以經由 IRC.ipv6.oftc.net 或 IRC.ipv6.freenode.net 連上 IRC 囉… 也可以架設使用 ipv6 的 web server 或是 mail server XD
阿,不過不快就是… 常常都要十幾個以上的 hops 才會到目的地..
Compiz Fusion 試用心得
等了很久很久,Beryl 跟 Compiz 合體的計劃終於有名字了!叫作 Compiz Fusion,網站在 http://www.opencompositing.org/ ,最近終於有一個比較像樣的首頁出現,git repository 也稍微可以拿出來跑了
如果要自己從 git 編的話,要從 http://gitweb.opencompositing.org/ 抓 compiz, ccsm, libcompizconfig, emerald, bcop, plugins-main, plugins-extra 等等下來…
目前跑起來的感覺是,特效的預設值比 beryl 來的順(可能是時間都設比較短),不過使用習慣跟 beryl 不太一樣,可以設定的值似乎沒有 beryl 多,wobbly 的效果很怪,會亂彈… 新增的幾個 plugin 像是 expo, cube reflection, dodge animation 等,都很有趣。
Intel 新玩具 — PowerTop!
常常覺得筆電的電池肚量不夠嗎?每次都撐不了幾個小時就沒電了? Intel 釋出這個名為 powertop 的新玩具,可以測量出是哪些程序常常把 CPU 從深層睡眠中喚醒,只要有辦法去掉這些惱人的 timer,搭配 linux 2.6.21 中的新特性 dynamic tick,可以讓電腦在不工作的時候可以好好休息,延長工作時間。
在 debian/sid 中只需要
apt-get install powertop
就可以安裝最新版的 powertop,但是要真正實用的分析功能,還需要把 kernel 中的 debug 功能打開
Kernel hacking --->
[*] Kernel debugging
[*] Collect kernel timers statistics
輸出結果如下
Cn Avg residency (5s) Long term residency avg
C0 (cpu running) (17.6%)
C1 0.0ms ( 0.0%) 0.0ms
C2 3.3ms (82.4%) 3.1ms
C3 0.0ms ( 0.0%) 0.0ms
Wakeups-from-idle per second : 252.8
Power usage (ACPI estimate) : 22.9 W (2.3 hours left)
Top causes for wakeups:
27.5% (165.2) <interrupt> : uhci_hcd:usb5, HDA Intel, i915@pci:0000:00:02.0
22.2% (133.6) firefox-bin : schedule_timeout (process_timeout)
18.5% (111.0) liferea-bin : schedule_timeout (process_timeout)
8.4% (50.2) java : schedule_timeout (process_timeout)
4.1% (24.8) Xorg : do_setitimer (it_real_fn)
2.6% (15.4) xchat : schedule_timeout (process_timeout)
2.5% (15.0) laptop_mode : queue_delayed_work_on (delayed_work_timer_
2.1% (12.8) <interrupt> : libata
2.1% (12.8) gnome-terminal : schedule_timeout (process_timeout)
2.1% (12.4) <interrupt> : yenta, ipw2200
清單上的常客 i915@pci, firefox, liferea 等可以在 powertop 網站上的 Tips and Tricks 找到紀錄,也有紀錄一些解決的方法或是 patch… 不過目前我的 i915@pci 無解 囧rz
期待這個計劃可以將 linux 在筆電上的工作效率提高
ps. 網站上有個很誘人的 Success stories
With PowerTOP, I managed to increase the battery life of my Panasonic R4 laptop from 4 to almost 7 hours — Keith Packard, Principal Engineer at Intel
Emacs 使用 Xft
Emacs 22 有新的 GTK 介面以及更進步的 unicode 支援,而使用 xft 來顯示字體的部份程式則進了 emacs-unicode-2 這個 branch,據說這會是 Emacs 23 的候選之一。
從 CVS 編譯好 emacs 23 之後,照著一些網路上的教學,的確讓英文的部份變成了 Xft 顯示的漂亮字型,但是中文部份仍然是使用醜醜的 bitmap (X font, 因為我沒有安裝中文字型所需要的相關檔案),網路上也甚少提及如何設定中文的 Xft 字型,大部份都還是用 X font。
其實很簡單,只要:
設定與設使用 Xft backend,把以下加入 ~/.Xresources 中
Emacs.FontBackend: xft在 ~/.emacs 中指定使用的中文字型
(set-default-font "Bitstream Vera Sans Mono-14") (set-fontset-font (frame-parameter nil 'font) 'han '("cwTeXHeiBold" . "unicode-bmp"))啟動 emacs
emacs-snapshot --enable-font-backend
“–enable-font-backend” 一定要加,因為預設沒有開啟除了 X font 以外其他任何 backend。
Update: 先前設定字型的部份,英文的設定會蓋掉中文的部份,現在已經修正。




