Sunday, December 18, 2011

Install X window, enlightenment window manager on FreeBSD

安裝 X-Window

Xorg 是預設的 X11 系統。 Xorg 是由 X.Org 機構發布的,根據 X11R6.7 所製作的 X11 伺服器。 X11R6.7 是基於 XFree86 4.4RC2 的程式碼和 X11R6.6。

1. 安裝 x11/xorg
# cd /usr/ports/x11/xorg ; make install clean
或是以 package 的方式安裝:
# pkg_add -r xorg

Note: 與 XFree86 的差異只有幾個設定方式改變。像是設定程式 XFree86(1) 變成 Xorg(1)、 xf86cfg(1) 變成 xorgcfg(1)、 xf86config(1) 變成 xorgconfig(1)。 設定檔 XF86Config 變成 xorg.conf。 紀錄檔 XFree86.0.log 變成 Xorg.0.log。

As of version 7.3, Xorg can often work without any configuration file by simply typing at prompt:

% startx
Starting with version 7.4, Xorg can use HAL to autodetect keyboards and mice. The sysutils/hal and devel/dbus ports are installed as dependencies of x11/xorg, but must be enabled by the following entries in the /etc/rc.conf file:

hald_enable="YES"
dbus_enable="YES"

Note: HAL (Hardware Abstraction Layer) is a daemon that allows desktop applications to readily access hardware information, to locate and use such hardware regardless of bus or device type. In this way a desktop GUI can present all resources to its user in a seamless and uniform manner.

Note: DBUS In computing, D-Bus (Desktop Bus) is a simple inter-process communication (IPC) open-source system for software applications to communicate with one another. Heavily influenced by KDE2–3's DCOP system, D-Bus has replaced DCOP in the KDE 4 release. An implementation of D-Bus supports most POSIX operating systems, and a port for Windows exists. It is used by Qt 4 and GNOME. In GNOME it has gradually replaced most parts of the earlier Bonobo mechanism.


Note: someone says if you enable hald_enable, you will get "Freebsd 8 kernel fault and automatic reboot"

Another possible solution might be remove the virtual CD-ROM from your virtual machine.

Feb 28 05:03:02 freebsd kernel: acd0: WARNING - unknown CMD (0x4a) read data overrun 8>0
Feb 28 05:05:08 freebsd syslogd: kernel boot file is /boot/kernel/kernel
Feb 28 05:05:08 freebsd kernel: acd0: WARNING - unknown CMD (0x4a) taskqueue timeout - completing request directly
Feb 28 05:05:08 freebsd kernel:
Feb 28 05:05:08 freebsd kernel:
Feb 28 05:05:08 freebsd kernel: Fatal trap 12: page fault while in kernel mode
Feb 28 05:05:08 freebsd kernel: cpuid = 0; apic id = 00
Feb 28 05:05:08 freebsd kernel: fault virtual address = 0x1a0
Feb 28 05:05:08 freebsd kernel: fault code = supervisor read, page not present
Feb 28 05:05:08 freebsd kernel: instruction pointer = 0x20:0xc060cdcf
Feb 28 05:05:08 freebsd kernel: stack pointer = 0x28:0xe537ab58
Feb 28 05:05:08 freebsd kernel: frame pointer = 0x28:0xe537ab70
Feb 28 05:05:08 freebsd kernel: code segment = base 0x0, limit 0xfffff, type 0x1b
Feb 28 05:05:08 freebsd kernel: = DPL 0, pres 1, def32 1, gran 1
Feb 28 05:05:08 freebsd kernel: processor eflags = interrupt enabled, resume, IOPL = 0
Feb 28 05:05:08 freebsd kernel: current process = 12 (swi6: task queue)
Feb 28 05:05:08 freebsd kernel: trap number = 12
Feb 28 05:05:08 freebsd kernel: panic: page fault
Feb 28 05:05:08 freebsd kernel: cpuid = 0
Feb 28 05:05:08 freebsd kernel: Uptime: 6h10m59s
Feb 28 05:05:08 freebsd kernel: Cannot dump. Device not defined or unavailable.
Feb 28 05:05:08 freebsd kernel: Automatic reboot in 15 seconds - press a key on the console to abort
Feb 28 05:05:08 freebsd kernel: Rebooting...

http://forums.freebsd.org/showthread.php?t=11782

> can you explain to me what is it : dbus_enable="YES" and
> hald_enable="YES" in file /etc/rc.conf? What is their function?

In explicit correspondence with their names, these settings enable to run dbus and hald. dbus is a D-Bus messaging daemon, hald is a HAL daemon. These programs are using in X environment to automount DVD's, flashcards and another, even mices and keyboards.

Since Xorg 1.7.5 running dbus and hald is required in some hardware equipment.
===
Those enable the startup of the DBUS and HAL services via their control files in /usr/local/etc/rc.d. Those services are often needed for X, and programs related to X (KDE, Gnome, Xfce, and many programs that have "Use DBUS for something" compile time options set).

Sadly, those don't provide "man dbus" or "man hal" in a very impolite manner. I'm sure you can find more documentation on the web, but it may already be outdated.

If you ask what HAL and DBUS actually *ARE*, I'm not sure what to answer - to me, they are both useless. :-)

Removing the entries in /etc/rc.conf may cause problems for some of your programs, or may even make your X stop working properly.
===
hald is an interface between devices and programs. It listens for attachment/detachment of input devices (keyboard, mouse, etc.) and informs listening programs of those events.

dbus is an interprocess communication system that allows programs to connect to and exchange messages with other programs. It allows the kernel, for example, to interact with your desktop. Rather than you interacting directly with the kernel, dbus acts as a middle man, controlling the communications between the two and only allowing you to perform actions which are considered "safe" or "reasonable".

The two work together, for example, to let your desktop know when you connect a new mouse or type on your keyboard.
===
http://en.wikipedia.org/wiki/HAL_%28software%29
http://en.wikipedia.org/wiki/D-Bus


These services should be started (either manually or by rebooting) before further Xorg configuration is attempted.

The automatic configuration may fail to work with some hardware, or may not set things up quite as desired. In these cases, manual configuration will be necessary.

Note: Desktop environments like GNOME, KDE or Xfce have tools allowing the user to easily set the screen parameters such as the resolution. So if the default configuration is not acceptable and you planned to install a desktop environment then just continue with the installation of the desktop environment and use the appropriate screen settings tool.

Starting with Xorg 7.4 and above, this test produces a black screen which may make it difficult to diagnose whether X11 is working properly. The older behavior is still available by using the retro option:

# Xorg -config xorg.conf.new -retro
If a black and grey grid and an X mouse cursor appear, the configuration was successful. To exit the test, switch to the virtual console used to start it by pressing Ctrl+Alt+Fn (F1 for the first virtual console) and press Ctrl+C.

http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/x-config.html

2. 產生設定檔 & 設定
先用 Xorg -configure 產生 xorg.conf.new 並且搬移到 /etc/X11/xorg.conf,或是用選單模式的 xorgcfg -textmode 產生 xorg.conf,然後用 Xorg -xf86config xorg.conf 來測試這個檔案能不能正常的運作。
# Xorg -configure

把檔案移到 /etc/X11
# mv xorg.conf.new /etc/X11/xorg.conf

由於筆者通常使用三鍵滑鼠,所以會設定一下, 接著編輯 /etc/X11/xorg.conf, 在 Section "InputDevice" 區段, 加入 Option "ZAxisMapping" "4 5"。並且用 /stand/sysinstall 來設定好 moused, 以便讓 /dev/sysmouse 有作用。 Configure → Mouse → Enable。

Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "MouseSystems"
Option "Device" "/dev/sysmouse"
Option "ZAxisMapping" "4 5"
EndSection

通常都需要指定 HorizSync 和 VertSync 才能讓解析度設定的高一點, 像是使用 1024x768 的解析度, 在 Section "Monitor" 區段, 加入 HorizSync 31.5 - 57.0 與 VertRefresh 50.0 - 100.0。

Section "Monitor"
Identifier "Monitor0"
VendorName "Monitor Vendor"
ModelName "Monitor Model"
HorizSync 31.5 - 57.0
VertRefresh 50.0 - 100.0
EndSection

筆者通常都用 24bpp 和 1024x768 的螢幕, 在 Section "Screen" 區段, 加入 DefaultDepth 24,並在 SubSection "Display" 中, Depth 24 的地方加上 Modes "1024x768"。

Section "Screen"
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1024x768"
EndSubSection
EndSection

Note: To test the server, run
# X -config /etc/X11/xorg.conf

3. 啟動 X-Window
# startx
如果看到全黑的畫面(正常應該要看到"格子背景" 和 "滑鼠游標 X") 那就把 HorizSync 和 VertRefresh 的值調小一點。

Note: 如果當掉的話,可以按 Ctrl + Alt + Backspace(<-) 來跳回 console

4. Install enlightenment
# cd /usr/ports/x11-wm/enlightenment ; make install

# echo "exec /usr/local/bin/ck-launch-session /usr/local/bin/enlightenment_start" > ~/.xinitrc

4. 安裝 Gnome # cd /usr/ports/x11/gnome2 ; make install clean

加了這句至 .xinitrc 以後,輸入 startx 即會執行 gnome
# echo "/usr/local/bin/gnome-session" > ~/.xinitrc

5. 安裝中文輸入法
個人建議 gcin 這個輸入PORT...如果你要用嘸蝦米輸入法安裝時請加 make WITH_BOSHIAMY=YES install clean這個指令去安裝...
# cd /usr/ports/chinese/gcin ; make WITH_BOSHIAMY=YES install clean

必須先執行一次 gcin,來建立相關目錄和檔案 (例如 ~/.gcin )
# /usr/X11R6/bin/gcin
進到 X-Window 以後,執行 gcin-setup 設定
# /usr/X11R6/bin/gcin-setup

想要在啟動 gnome 時,同時啟動 gcin,在 ~/.xinitrc 檔中加入
export XMODIFIERS=@im=gcin
gcin&

6. Install iBus

# cd /usr/ports/textproc/ibus ; make install

If you are using bash, please add following lines to your $HOME/.bashrc:

export XIM=ibus
export GTK_IM_MODULE=ibus
export QT_IM_MODULE=xim
export XMODIFIERS=@im=ibus
export XIM_PROGRAM="ibus-daemon"
export XIM_ARGS="--daemonize --xim"

If you are using tcsh, please add following lines to your $HOME/.cshrc:

setenv XIM ibus
setenv GTK_IM_MODULE ibus
setenv QT_IM_MODULE xim
setenv XMODIFIERS @im=ibus
setenv XIM_PROGRAM ibus-daemon
setenv XIM_ARGS "--daemonize --xim"

If you are using KDE4, you may create a shell script in $HOME/.kde4/env,
and add following lines:

#!/bin/sh
export XIM=ibus
export GTK_IM_MODULE=ibus
export QT_IM_MODULE=xim
export XMODIFIERS=@im=ibus
export XIM_PROGRAM="ibus-daemon"
export XIM_ARGS="--daemonize --xim"

Following input methods/engines are available in ports:

chinese/ibus-chewing Chewing engine for IBus
chinese/ibus-pinyin The PinYin input method
japanese/ibus-anthy Anthy engine for IBus
japanese/ibus-skk SKK engine for IBus
textproc/ibus-kmfl KMFL IMEngine for IBus framework
textproc/ibus-m17n The m17n IMEngine for IBus framework
textproc/ibus-table Table based IM framework for IBus

and QT4 input method module, textproc/ibus-qt.

If ibus cannot start or the panel does not appear, please ensure
that you are using up-to-date python.
There's a bug in python 2.5, which may prevent the panel from appearing.
-------------------------------------------------------------------
To display this message again, type /usr/sbin/pkg_info -D ibus-1.3.9_1

7. install 嘸蝦米 in iBus
# /usr/ports/textproc/ibus-table ; make install

# ls /usr/local/share/ibus-table
# tar zxvf boshiamy-ibus.tar.gz
# cd boshiamy-ibus
# cp *.png /usr/local/share/ibus-table/icons/
# cp *.db /usr/local/share/ibus-table/tables/

# ibus-setup
# ibus-daemon -rdx

Note: I use rxvt-unicode terminal to make ibus to work.

8. Install rxvt-unicode
# cd /usr/ports/x11/rxvt-unicode ; make install

# vi ~/.cshrc
setenv TERM rxvt-unicode

9. 安裝 chinese/fireflyttf 螢火飛中文字型。蠻漂亮的中文字型
# cd /usr/ports/chinese/fireflyttf ; make install clean

# pkg_add -r zh-fireflyttf

接著編輯 /etc/X11/xorg.conf, 在 Section "Module" 區段, 加入 Load "xtt"。

Section "Module"
:
Load "xtt"
EndSection

在 Section "Files" 區段, 加入 FontPath "/usr/X11R6/lib/X11/fonts/TrueType/" 與 FontPath "/usr/X11R6/lib/X11/fonts/local/"。

Section "Files"
:
FontPath "/usr/X11R6/lib/X11/fonts/TrueType/"
FontPath "/usr/X11R6/lib/X11/fonts/local/"
EndSection

請參考 輸出字型 http://chinsan2.twbbs.org/zh-tut/fonts.html 一節。XD

10. install google chrome
# /usr/ports/www/chromium ; make install
# /usr/local/share/chromium/chrome

11. install audio sound driver

# kldload snd_driver

# cat /dev/sndstat

# cat /boot/defaults/loader.conf | grep -i snd

# vim /boot/loader.conf
snd_driver_load="YES"

http://www.freebsd.org/doc/handbook/book.html#SOUND-SETUP

12. install mp3 player
# cd /usr/ports/multimedia/xmms ; make install

13. start x window
# startx
Add new application > /usr/local/bin/urxvt
Startup application


Reference:
http://gala4th.blogspot.com/2011/10/install-x-window-enlightenment-window.html

No comments: