Gadget – Google Calendar

官方的 Google Calendar Gadget 在 iGoogle 上的表現非常不好,一者是檢視的能力差,另一個是載入的速度過慢,每次只要開 iGoogle 都會因為官方的 Google Calendar Gadget 而等上數十秒,有時候還會發生需要先登入 Google Calendar 事件清單才會顯示的囧事。今天特地搜尋了一下,找到幾個不錯的 Gadget 。

Google Calendar by Matthew Johnson

  • 可以使用 Week 、 Month 、 Agenda 三種檢視方式,顯示出來的樣子就像是一個縮小版的 Google Calendar ,不過只能看,不能增刪。
  • 可以加入最多九個行事曆,加入時需要填入行事曆的 ID ,而行事曆的事件可以自訂顯示顏色。

Google Calendar by Bas Hennekam

  • 跟上面那一個 Gadget 幾乎一模一樣,差別在於這一個 Gadget 不用自己一個一個新增行事曆,他會自己登入 Google Calendar ,而且可以直接選擇哪一些行事曆要顯示。

Google Calendar (YAGCG) by Bernie T.

  • 會顯示一個簡單的日曆跟事件清單,不同的事件會用不同的顏色標示,但是和 Google Calendar 的顏色設定不會相同。

上面這些載入的速度都比官方的 Google Calendar Gadget 快,目前我正在使用的是第二個。

Travian 簽名檔

Cry’s Travian Tools 有個網頁可以產生 Travian 簽名檔,簽名檔部份有個 Chinese Trad. 可以選,不過 Avatar 在聯盟的部份無法顯示中文。仔細看了一下,不用這個網頁也可以自己找出來簽名檔的圖像位址:

  • 首先記下來簽名檔圖像的伺服器,我試了一下, http://travian.macaputo.de/http://cry.travianteam.com/ 都可以使用。
  • 接著是鏈結位址的後半段,其格式為:sig-[風格代碼]-[語言]-[未知]-[伺服器]_[UID].gif
    • [風格代碼] 如下:
      1. Standard
      2. Travian Neutral
      3. Travian 羅馬人
      4. Travian 條頓人
      5. Travian 高盧人
      6. Travian Auto
      7. Travian Auto UTF8
      8. Travian Auto Avatar
      9. Travian Auto Chinese Simpl.
      10. Travian Auto Chinese Trad.
      11. Travian Ally Gray
      12. Travian Ally Green
    • [語言] 的部份為兩個英文字元,例如 en 或 hk ,會影響表格標頭,例如 en 會顯示 Alliance 、 Rank 、Points 、 Vill. ,而 hk 則顯示聯盟、排名、總人口、村莊,要注意的是目前沒有 tw 這個選項。
    • [未知] 的部份就不曉得要幹嘛了,用產生器做出來的都是 2 ,但是我把這部份改成 200 還是得到一樣的結果。
    • [伺服器] 是玩家所在的 Travian 伺服器,例如 tw1 代表 s1.travian.tw ,而 com2 則代表 s2.travian.com 。
    • [UID] 是玩家的使用者代碼,按一下”個人資料”再看看網址列,其中 “uid=xxx” 的 xxx 部份就是 UID 。
  • 底下是兩個範例:
    http://cry.travianteam.com/sig-7-en-2-org1_22166.gif

    ex1

    http://cry.travianteam.com/sig-8-en-2-com2_109933.gif

    ex2

Ubuntu Diary : Segmentation Fault while Removing capplets-data

前天使用 GUI 介面更新 Ubuntu 時不知道為什麼,跳出一個視窗跟我說更新失敗,因為要睡覺了,就沒有仔細查看。結果昨天發現 Gnome 進不去了,今天早上開始嘗試解決這個問題,發現使用 apt-get upgrade 的時候,會出現類似下面的訊息:

dpkg: error processing capplets-data (--configure):
subprocess post-installation script returned error exit status 139

如果用 apt-get remove capplets-data 的話,則會出現 Segmentation fault ,訊息大致上是說執行 postrm 的時候出錯。於是就完全不能更新,也不能移除有問題的套件,連重新 config 也不行。

後來仔細看一下 /var/lib/dpkg/info/capplets-data.postrm ,發現原來是在執行

scrollkeeper-update -q

的時候會發生 Segmentation fault ,只要執行

scrollkeeper-rebuilddb

就可以解決這個問題了。

2007.09.03-2007.09.09 里斯本雜感

里斯本的路相當複雜,其中最令人討厭的是常常搞不清楚路名。在馬路上永遠不會有指標指著這一條路是什麼路,只會說左轉是什麼路,右轉是什麼路,但是指標一多的話,也不知道哪個才是路名。

9/6 在街上吃完晚餐之後,想憑著大約的方向走回旅館。印象中這一條街往東走應該會跟一條最大的路 Avenida da Republica 垂直,左轉向北順著 Avenida da Republica 走下去就可以到旅館。但沒想到這一條街是斜的,旅館在餐廳的東北邊,而這一條街則斜向東南,於是我就繞了一個大圓圈而迷路了。

這時候大約是晚上九點,雖然餐廳都還開著,但路上沒什麼行人,也沒什麼車。一個人走在路上其實有點怕怕的,不知道這邊的治安好不好。加上路這麼亂, 走來走去都不知道身在何處。還好後來讓我發現路旁的公車等候亭都會有地圖,並且指出目前的位置。只要順著馬路走到下一個候車亭,就可以知道馬路的方向了。 結果當天這麼一迷路,多花了一個小時的時間才回到旅館。

Move Free

上個星期幫老媽買了幾罐 Move Free ,我找到最便宜的是在 Costco ,但是我不是會員,沒辦法進去買。結果後來發現原來不是會員也可以從 Costco 的網頁買,只是要加 5% 。而且我發現這個時候剛好 Move Free 在促銷,又更便宜了。

因為怕來不及,所以用 Express shipping ,三天就到了。不過當天晚上十點多回到公寓時還真是嚇一跳,一個長方形的盒子就大喇喇地立在門前。本來以為會由公寓管理員代收的,沒想到就這樣丟在門口, 更令人意外的是我這麼晚才回去,它竟然還靜靜地立在門前而沒有被幹走。

Ubuntu Diary : OXIM and im-switch

Intro

Linux 上的輸入模組也蠻多種的,像是 scim 、 gcin 等等,一開始我裝的是 scim ,不過有時候叫不出來。如果我在用 MSN 跟笨笨聊天的時候叫不出來,那可真是令人生氣。後來棄 scim 改投 gcin ,雖然沒什麼大問題,不過就是用不習慣。因為以往在 Windows 上用的輸入法是新酷音,而最近剛好發現還有另一個輸入模組 oxim 的存在, oxim 加上 libchewing 的長相真是像極了 Windows 上的新酷音,所以決定裝 oxim 來試試看。

在 Ubuntu 上裝 oxim 也不是那麼簡單,因為官方的 Repository 沒有 oxim 套件,雖然網路上有人有做好,但是不想加入來源不明的 Repository ,只好從原始碼編譯。只是從編譯到安裝使用出了一些小狀況,還好網路上找的到資料解決。以下就說明一下安裝 oxim 的步驟。

Install OXIM

  1. 首先到 OXIM 首頁下載原始碼,我自己是抓 cvs 版本的。
  2. cvs 版本沒有 configure 跟 Makefile.in ,而自動產生 configure 與 Makefile.in 是利用 autotools 來完成,所以要先有 autotools 。 Ubuntu 的話裝個 autobook 就會自動安裝 autoconf 跟 automake 等等套件。(其實我沒有裝 autobook ,我是看缺甚麼就裝甚麼,所以不確定只裝 autobook 夠不夠。)
    $ sudo apt-get install autobook

    oxim 作者很貼心地把產生的步驟寫成一個 script ,執行他一下 configure 跟 Makefile.in 就出來了。

    $ ./autogen.sh
  3. 接下來就跟一般編譯原始碼的動作一樣了,只是有些必要套件要安裝,像是 libqt3-headers 、 qt3-dev-tools 、 libchewing3-dev 等等族繁不及備載(其實是我裝好忘了)。而 configure 會找不到 qt3 ,得自己加上參數指定。
    $ ./configure --with-qt-dir=/usr/share/qt3

    如果跑出來的結果像這樣

    Build options:
    Version 1.1.3.90
    Install prefix /usr
    IM Module directory ${exec_prefix}/lib/oxim/immodules
    Module directory ${exec_prefix}/lib/oxim/modules
    Table directory ${exec_prefix}/lib/oxim/tables

    Input Method modules:
    Chewing yes
    Unicode yes

    Optional:
    GTK+ IM module yes
    QT IM module yes

    GUI Setup Tool yes

    恭喜你成功了,如果跑到一半跟你說找不到某個東西,或是有些功能你要但是 configure 的結果跟你說 no ,那就是缺了東西,看看缺了甚麼套件裝起來吧。

  4. configure 完之後就編譯跟安裝吧。
    $ make
    $ sudo make install

Config with im-switch

電腦上安裝了很多輸入模組,想切換時怎麼辦?用 im-switch 吧。首先把 im-switch 套件裝起來。

$ sudo apt-get install im-switch

使用 im-switch -s 可以設定要使用哪一個輸入模組,用 root 身份執行的話還可以改變整個系統的預設值。所以要用 oxim 的話,就執行下面指令。

$ im-switch -s oxim

如果要指定在哪個語系環境下使用哪一種輸入模組,可以加上 -z 參數,例如:

$ im-switch -z zh_TW -s oxim

這樣一來就會在使用者的 ~/.xinput.d 下建立 en_US 或 zh_TW 的連結指向 /etc/X11/xinit/xinput.d/oxim 設定檔。在 /etc/X11/xinit/xinput.d 目錄下會有各輸入模組的設定檔,連結到哪個檔案的話就會用該輸入模組。

不幸的是,光這樣是不足的,重新登入 Gnome 之後可能會發現 oxim 沒跑出來,雖然 XMODIFIERS 等環境變數設定都有。上網找了一下沒找到相關資料,最後發現原來是 /etc/X11/xinit/xinput.d/oxim 設定檔的問題。看看 scim 與 gcin 的設定檔,發現他們的 XIM_PROGRAM 都是完整路徑,只有 oxim 不是,把這部份改成完整路徑 /usr/bin/oxim 就 OK 了。底下是我的 /etc/X11/xinit/xinput.d/oxim 設定檔,注意一下 XIM_PROGRAM 那一行吧:

#!/bin/sh
#
# Open X Input Method startup script.
#
# By Firefly.
#

OXIM_IM_MODULE_DIR="/usr/lib/oxim/immodules"
XIM=oxim
XMODIFIERS="@im=${XIM}"
XIM_PROGRAM=/usr/bin/oxim
XIM_ARGS="-x oxim"

USR_DIR="$HOME/.oxim"
GTK_IM_MODULE_FILE="${USR_DIR}/gtk.immodules"

# 找出 gtk-query-immodules 指令的完整路徑與真正名稱
for cmd in gtk-query-immodules-2.0-64 \
gtk-query-immodules-2.0-32 \
gtk-query-immodules-2.0 \
gtk-query-immodules
do
TEST_CMD=`which ${cmd} 2>/dev/null`
if [ ! -z ${TEST_CMD} ]
then
GTK_QRY_CMD=${TEST_CMD}
break
fi
done

# 檢查 OXIM 的 GTK2 輸入模組是否安裝
if [ -f ${OXIM_IM_MODULE_DIR}/gtk-im-oxim.so ] ; then
# 檢查使用者家目錄之下是否有下列目錄
if [ ! -d ${USR_DIR} ] ; then
mkdir -p ${USR_DIR}
fi

# 建一個 gtk im modules 的紀錄檔
if [ ! -z ${GTK_QRY_CMD} ] ; then
${GTK_QRY_CMD} > ${GTK_IM_MODULE_FILE}
else
# 否則只建立自己的 immodule 紀錄
echo "\"${OXIM_IM_MODULE_DIR}/gtk-im-oxim.so\"" > ${GTK_IM_MODULE_FILE}
echo "\"oxim\" \"Open X Input Method\" \"gtk20\" \"/usr/share/locale\" \"*\"" >> ${GTK_IM_MODULE_FILE}
fi
GTK_IM_MODULE=oxim
export GTK_IM_MODULE_FILE
else
GTK_IM_MODULE=xim
fi

# 檢查 OXIM 的 QT 輸入模組是否安裝
if [ -f ${OXIM_IM_MODULE_DIR}/qt-im-oxim.so ] ; then
export QT_IM_MODULE=oxim
fi

改成這樣之後重新登出再登入應該就可以看到 oxim 了。

Troubleshooting

Q: 你騙人!我執行 im-switch -s oxim 的時候明明就出現下面這個錯誤訊息。

update-alternatives: Cannot find alternative `/etc/X11/xinit/xinput.d/oxim'.

A: 這是因為你用 root 身份執行的關係,當你用一般使用者身份執行的話, im-switch 會在 ~/.xinput.d 建立設定檔連結,不會有甚麼大問題,除非你執行的指令是 im-switch -s zechs 之類的。當你用 root 身份執行的時候,連結會建立在 /etc/alternatives ,這時候問題就出現了,因為系統不認為 oxim 屬於一個 alternative 。

怎麼知道 oxim 是不是一個 alternative ?先執行下面這個指令:

$ im-switch -l

他會列出所有可以用的輸入模組,如果沒有看到

oxim - priority 0

這一行的話( priority 後面的數字不見得是 0 ),就表示 oxim 還沒被加到 alternatives 裡面(雖然說有的話也不見得每個語系都有,目前我也不知道該怎麼查)。

要解決這個問題也很簡單,加進去就好了。例如我使用的語系是 en_US ,就下這個指令:

$ sudo update-alternatives --install /etc/X11/xinit/xinput.d/all_ALL xinput-all_ALL /etc/X11/xinit/xinput.d/oxim 0

繁體中文語系的話改成 zh_TW 就可以了。

$ sudo update-alternatives --install /etc/X11/xinit/xinput.d/zh_TW xinput-zh_TW /etc/X11/xinit/xinput.d/oxim 0

想知道參數的意義? man 一下吧。

$ man update-alternatives

加進去之後再用 root 身份執行 im-switch -s oxim ,這時應該就不會再跟你抱怨了。

想從 alternatives 中移除 oxim 的話就用下面指令:

$ sudo update-alternatives --remove xinput-all_ALL /etc/X11/xinit/xinput.d/oxim

References

Ubuntu Diary : Suspend and Hibernate with µswsusp

Intro

The original suspension and hibernation functions in Ubuntu 7.04 does not work well on my laptop (IBM Thinkpad T42). After searching WWW, I found a better package, µswsusp, for supporting these functions. However, several problems occurred when I tried to use it. I could find solutions of some problems in Ubuntu forum. For those problems that I couldn’t find solutions, I had to solve them by myself. Finally I succeeded after a lot of try and error. Hope I don’t miss any step in the following.

Suspension

The following method works on my laptop.

  1. Install uswsusp.
    $ sudo apt-get install uswsusp
  2. Edit /usr/lib/hal/scripts/linux/hal-system-power-suspend-linux. Replace the whole content with the following two lines.
    #!/bin/sh
    /sbin/s2ram
  3. Try it.

Some users in the Ubuntu forum suggest the following way to use µswsusp.

  1. Install uswsusp.
    $ sudo apt-get install uswsusp
  2. Remove all packages that appear before s2ram in /usr/lib/hal/scripts/linux/hal-system-power-suspend-linux. Otherwise, s2ram will not be the first choice when suspending. Here we don’t really uninstall those packages but use dpkg-divert to rename necessary files. For example, I have /etc/acpi/sleep.sh before s2ram. So I execute the following command.
    $ sudo dpkg-divert --rename --divert /etc/acpi/sleep.sh.disabled /etc/acpi/sleep.sh
  3. In /usr/lib/hal/scripts/linux/hal-system-power-suspend-linux, it assumes s2ram is in /usr/sbin. However, Ubuntu installs it in /sbin. Thus we have to make a symbolic link.
    $ sudo ln -s /sbin/s2ram /usr/sbin/s2ram

However, this method does not work on my laptop. Every time it resumes from a suspension state, the Gnome desktop restarts and I lose the previous session.

Hibernation

  1. Install uswsusp.
    $ sudo apt-get install uswsusp
  2. It seems that the package in Ubuntu’s repository is too old. In this step, we want to use some scripts from Ubuntu’s repository to generate initrd with the latest uswsusp.
    1. Download the source code suspend-0.7.tar.gz of uswsusp.
    2. Extract suspend-0.7.tar.gz.
    3. Modify config_parser.h and Makefile. Replace “suspend.conf” with “uswsusp.conf. For example, in config_parser.h, we have the following line.
      #define CONFIG_FILE     "/etc/uswsusp.conf"

      In Makefile, we have the following line.

      CONFIGFILE=uswsusp.conf

      I have to change this such that the command resume can find configuration file after resuming.

    4. Compile the source code.
      $ make
    5. Install the executables.
      $ sudo cp s2both /sbin/s2both
      $ sudo cp s2ram /sbin/s2ram
      $ sudo cp s2disk /sbin/s2disk
      $ sudo cp resume /usr/lib/uswsusp/resume
    6. Copy the configuration in conf/suspend.conf to /etc/uswsusp.conf and modify it. Below is my /etc/uswsusp.conf.
      # /etc/uswsusp.conf(8) -- Configuration file for s2disk/s2both
      snapshot device = /dev/snapshot
      resume device = /dev/sda3
      #compress = y
      early writeout = y
      image size = 365106872
      #RSA key file = /etc/uswsusp.key
      shutdown method = platform
      splash = y

      In this configuration file, you have to specify your resume device. For example, my swap partition is /dev/sda3. Some lines are commented out because they are not recognized by uswsusp-0.7.

  3. Like suspend, we want s2disk to be the first choice when hibernating. Thus replace /usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux with the following.
    #!/bin/sh
    /sbin/s2disk

    Another way is to rename all files that appear before s2disk in /usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux. for example,

    $ sudo dpkg-divert --rename --divert /etc/acpi/hibernate.sh.disabled /etc/acpi/hibernate.sh

    and create a symbolic link because hal-system-power-hibernate-linux assumes s2disk is in /usr/sbin.

    $ sudo ln -s /sbin/s2disk /usr/sbin/s2disk

    Although /etc/acpi/hibernate.sh supports s2disk, it passes wrong arguments to s2disk. However, after I fix it, there is still other problem with /etc/acpi/hibernate.sh, for example, Gnome desktop restarts and previous session is lost. That’s why I want to disable hibernate.sh.

  4. Update /etc/initramfs-tools/conf.d/resume. Again you have to set the resume device to your real swap partition. For example,
    RESUME=/dev/sda3
  5. Update initrd.
    $ sudo update-initramfs -u
  6. Try it now.

Troubleshooting

Q: s2disk complains that it could not use the resume device.
A: Execute the following command first.

$ free

If your output looks like:

             total       used       free     shared    buffers     cached
Mem: 775100 422044 353056 0 448 227016
-/+ buffers/cache: 194580 580520
Swap: 0 0 0

This is because the swap partition has new UUID, but it does not update /etc/fstab. If this happens,
you can mount the swap partition by

$ sudo swapon /dev/sda3

Then change the UUID of the swap parition by the real path in /etc/fstab, for example

/dev/sda3        swap    sw              0       0

Q: After resuming, Gnome desktop restarts.
A: Be sure to use s2disk directly without /etc/acpi/hibernate.sh.

Q: When resuming, it stops in the boot logo.
A: This may be caused by setting wrong resume device or wrong configuration file such that the resuming procedure could not find where to load previous state. Press Ctrl+F1 to see if it asks you to enter the resume device, enter the path to your swap partition, for example /dev/sda3, and then press Enter. It should continue to resume. Make sure that the name of configuration file in config_parser.h and Makefile is set correctly. Also make sure to set correct resume device in /etc/uswsusp.conf and /etc/initramfs-tools/conf.d/resume. You may need to update initrd by

$ sudo update-initramfs -u

Reference

Since everyone could have different problems, I list some references below.