8 September 2010

Setting up my Arch-Linux-based production environment

The Arch Way, the devotion to KISS, a good memory of the BSD-style configuration system, the extensive technical (rather than merely philosophical or evangelistic) documentation, and the rolling release model with bleeding-edge packages are what initially drive me to try the Arch Linux distribution. So far, I like it.

The Beginners' Guide provides a solid ground for setting up a general desktop environment. Nevertheless, the rest of my needs are met only through other sources of information (e.g., the fine ArchWiki) and experimenting.

This page is a memorandum for setting up a production desktop environment on Arch Linux. The choices of packages and configurations are purely based on personal taste and experience.

Arguably, good writers write for no one but themselves; yet, in doing this, they produce pieces of writing that serve others better than if they had started with too many other things in mind. In the same spirit, I write this memorandum for myself. Nevertheless, I hope you will also find it useful.

Here is an index of the topics.

Installation

In homage to the comprehensive Beginner's Guide, I only highlight the choices I have made throughout the installation procedure here.

Installation Media

Many modern personal computers are capable of booting from USB drive. This page describes how to make a USB installation media. I took a free 512M USB pen from the UITS and burned the 2010.05 dual-arch netinstall image on it.

Try Arch64 if your computer is capable of hosting it. Enable [multilib] in /etc/pacman.conf. Do not forget to pacman -Syy after this.

Partition and Filesystem

As regard to disk space allocation for filesystem, I allocate 20G for / as ext4, 15G for /var as reiserfs, 1G on top of physical memory size for swap, and the rest of the space for /home as ext4. Please see here for an explanation for the rationale behind these choices.

Post-installation Configuration

Initial Setup

First, as root, update and upgrade the system with pacman -Syu. This should not be an issue for netinstall.

Next, install sudo

pacman -S sudo
and set up a user account wei with
useradd -m -g users -G audio,lp,optical,storage,video,wheel,games,power -s /bin/bash wei
passwd wei

With visudo, edit /etc/sudoers to enable

%wheel ALL=(ALL) ALL
and now we should login and work as the regular user wei, and use sudo for privileged operations. For the sake of clarity, we omit sudo in the following command snippet; the context should make it clear if a sudo is warranted.

Install and configure Advanced Linux Sound Architecture (ALSA) has been detailedly described here. Basically, after pacman -S alsa-utils, run alsamixer as wei (rather than root) and store the setting with sudo alsactl store. Of course, do not forget to add alsa to the DAEMONS array in /etc/rc.conf.

If you find the system beeping annoying as I do, you may disable it by adding !snd_pcsp !pcspkr to the MODULES array in /etc/rc.conf as

# Scan hardware and load required modules at boot
MOD_AUTOLOAD="yes"
# Load the following modules (do not load with the ! prefix)
MODULES=(... !snd_pcsp !pcspkr ...)
and unload it with
lsmod | grep -i spkr
rmmod pcspkr
if you already have loaded it.

Setup a Desktop Environment

The instructions are here. Basically, we need to do

pacman -S xorg mesa
lspci | grep -i vga
pacman -S xf86-video-<chip>

We do not need to configure Xorg at this point because we are going to install the GNOME desktop environment in a moment.

Install fonts with

pacman -S ttf-ms-fonts ttf-dejavu ttf-bitstream-vera

After this, install GNOME with

pacman -S gnome gnome-extra gnome-system-tools
and enable GDM with /etc/rc.d/hal start and edit the DAEMONS array in /etc/rc.conf into something like
DAEMONS=(syslog-ng dbus hal gdm network crond alsa)
Restart the computer, and we will land right into GDM.

I prefer to disable CapsLock key by the desktop menu System>Preferences>Keyboard>Layout>Options.

Set the mouse focus policy at (somewhat counter-intuitive) System>Preferences>Windows.

Set the single-click-select mouse behavior at Nautilus's menu Edit>Preferences>Behavior>.

Install Utilities

Basic Utilities

To make the rest of the procedure goes smoothly,

pacman -S bash-completion
echo 'set show-all-if-ambiguous on' >> ~/.inputrc

The following packages are basics for everyday use (for me)

pacman -S openssh putty gksu gvim firefox thunderbird git
pacman -S chromium screen irssi
pacman -S emacs racket sbcl
pacman -S graphviz gnuplot xfig octave
pacman -S ntfs-3g gstreamer0.10-plugins gstreamer0.10-pulse
Use the Vim's configuration for a quick start. We can set the following keyboard shortcuts (Mod4 usually maps to the Win key)
Mod4+O -> gnome-terminal --working-directory=$HOME
Mod4+B -> firefox
Mod4+R -> gksu gnome-terminal
Mod4+. -> thunderbird
Mod4+I -> gvim
Mod4+P -> putty
Mod4+L -> nautilus /home/wei/documents

Use Firefox's Add-On manager to add the following extensions: Vimperator (the reason to stay with Firefox; a recommended try for any Vim user), Forecastfox Weather, Adblock Plus, mozplugger. A few quickmarks are handy for Vimperator (use M<char> to add a quickmark <char>; then we can use go<char> or gn<char> to quickly access the page)

g -> www.google.com
s -> scholar.google.com
d -> docs.google.com
c -> www.google.com/calendar/render
m -> www.gmail.com
M -> maps.google.com
u -> umail.iu.edu
o -> onestart.iu.edu
e -> edas.info
f -> www.facebook.com
r -> www.renren.com
h -> www.cs.iupui.edu/~pengw/
k -> slickdeals.net
y -> www.youtube.com
S -> mitpress.mit.edu/sicp/full-text/book/book-Z-H-4.html#%_toc_start
and so on.

Finally, install yaourt for ease of accessing AUR. First, add to /etc/pacman.conf the following lines

[archlinuxfr]
Server = http://repo.archlinux.fr/$arch
Then, install it by
pacman -Syu yaourt

[multilib] Tools

In our Arch64 setup, since we have enabled [multilib] in /etc/pacman.conf,
pacman -S mplayer gecko-mediaplayer xine-lib xine-ui \
libdvdread libdvdcss alsa-oss flashplugin jre skype

Networking Utilities

Configure NetworkManager by

pacman -S networkmanager network-manager-applet gnome-keyring
and edit the DAEMONS array in /etc/rc.conf as
DAEMONS=( ...hal networkmanager... ) 

Do not forget to allow others to use your SSH service by adding to the file /etc/hosts.allow

sshd: ALL

Enable SSH's X11 forwarding by editing /etc/ssh/sshd_config with

X11Forwarding yes
but be aware of the hazard of doing so (forewarned is forearmed). Add sshd to the DAEMONS array in /etc/rc.conf and start it with /etc/rc.d/sshd start.

Install optional dependencies for Empathy (pacman -Qi empathy) to make it work correctly

pacman -S telepathy-butterfly telepathy-farsight telepathy-gabble telepathy-glib \
telepathy-haze telepathy-idle telepathy-salut telepathy-sofiasip

As regard to Skype microphone or voice problem, first check ALSA's configurations

alsamixer
sudo alsactl store
In particular, press [F4] and press [SPACE] on Capture to enable it (press [F1] for usage). See here for more information.

Desktop

Crispy Look

One thing I like about Ubuntu is its crispy look out of the box. Fortunately, it is easy to get the look by using the LCD filter patched packages

pacman -Rd cairo libxft freetype2 fontconfig
Do not panic if you find the look turns worse, because this is the caterpillar about to transform into butterfly
yaourt -S freetype2-ubuntu fontconfig-ubuntu libxft-ubuntu cairo-ubuntu
Logout and login again. Enjoy the new look. :-)

Compiz

With a dose of restraint and proper configurations, Compiz can greatly enhance your productivity and desktop experience.

Install it with

pacman -S compiz-fusion-gtk
Before activating it, use ccsm to enable a few basic plug-ins
Move Window
Resize Window
Wallpaper
Gnome Compatibility
Window Decoration
Dbus
Inotify
GLib
Regex Matching
Workarounds
Then, we can test it with (thanks for the help from a few kind souls on irc.freenode.net#archlinux: icarus-c, oskude, and rabbitear)
compiz --replace --indirect-rendering ccp &
Somehow, the --indirect-rendering option is vital for the proper function of Compiz on my setup. As noted here and here, Intel GMA user (e.g., Thinkpad X61s user as me) should start Compiz with
LIBGL_ALWAYS_INDIRECT=1 INTEL_BATCH=1 compiz --replace --indirect-rendering --sm-disable ccp
and add a file 20-intelgma.conf to /etc/X11/xorg.conf.d/ with this content
Section "Device"
Identifier "Intel video card"
Driver "intel"
Option "AccelMethod" "exa"
Option "MigrationHeuristic" "greedy"
Option "ExaNoComposite" "false"
EndSection
And we can always fall back to GNOME's window manager Metacity with
metacity --replace --sm-disable &
Make them into bash scripts my-compiz.sh and my-metacity.sh for quick access; a good place would be $HOME/bin and add a line
PATH=$HOME/bin;$PATH
to $HOME/.bashrc.

If you want to automatically start with Compiz enabled, see this tip: create the file (if it does not exist) /usr/share/applications/compiz.desktop containing the following

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Compiz
Exec=bash -c 'compiz --replace --indirect-rendering --loose-binding\
--sm-client-id $DESKTOP_AUTOSTART_ID ccp decoration move resize'
NoDisplay=true
# name of loadable control center module
X-GNOME-WMSettingsModule=compiz
# autostart phase
X-GNOME-Autostart-Phase=WindowManager
X-GNOME-Provides=windowmanager
# name we put on the WM spec check window
X-GNOME-WMName=Compiz
# back compat only
X-GnomeWMSettingsLibrary=compiz
and set GConf parameters with gconftool-2 by
gconftool-2 --set -t string /desktop/gnome/session/required_components/windowmanager compiz

A list of plug-ins can be found at /usr/share/compiz/*.xml, which you can add to the Exec above.

A few Compiz plug-ins comes very handy

Documentation Utilities

Install TeXLive, OpenOffice.org, JabRef, gnochm with

pacman -S texlive-most jabref gnochm
pacman -S openjdk6
pacman -S ttf-dejavu artwiz-fonts ttf-ms-fonts
pacman -S openoffice-base
pacman -S openoffice-base-beta openoffice-base-devel
See here for a few LaTeX styles (e.g., IEEEtran). Simply extract the package into $HOME should work, i.e., tar xvf texmf.tgz.

Chinese Language Environment

Install Chinese fonts with

pacman -S ttf-arphic-ukai ttf-arphic-uming ttf-fireflysung

A Chinese input method is essential for everyday use. For this purpose, I find ibus-pinyin a good choice.

pacman -S ibus-pinyin
and configure it via System > Preferences > IBus Preferences desktop menu.

Remember to install OpenOffice.Org's Chinese language support

pacman -S openoffice-zh-CN

... and Remember to Update the System

Do update and upgrade your system from time to time with

pacman -Syu
This is the beauty of a rolling release distro like Arch.