17 November 2010

Setting up my Arch-Linux-based production environment II

I wrote about this topic before. Here, I want to record my experience on Arch Linux after migrating from GNOME to awesome as my major window manager. GNOME is a great desktop environment; it also provides a lot of useful utilities I love (Evince, for an instance). Nevertheless, I find awesome window manager significantly increase my desktop productivity, so a migration is worthwhile.

Here is an index of the topics.

Initial Setup

According to here, as root

pacman -Syu
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.

I choose to use the simple and robust netcfg utility to manage my network connectivity. According to here, install the following packages with

pacman -S wpa_actiond ifplugd wifi-select
and add to rc.conf the following lines
WIRELESS_INTERFACE="wlan0"
WIRED_INTERFACE="eth0"
...
DAEMONS=(... !network net-auto-wireless net-auto-wired ...)

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.

Having NTPD to automatically synchronize with time server is handy. See the instructions.

pacman -S ntp
and add ntpd to DAEMONS in /etc/rc.conf. We can enable it right away by /etc/rc.d/ntpd start.

Since we are going to pull a lot of stuff from AUR, we are better off to install an AUR helper at this point. I used to use the tried yaourt; but now I use packer.

wget http://aur.archlinux.org/packages/packer/packer.tar.gz
tar xvfz packer.tar.gz
cd packer
makepkg -s
pacman -U packer-....pkg.tar.xz
packer -S pacman-color
Now, we can use packer -S to pull from AUR or simply replace pacman for installation.

On my laptop, I do the following according to these instructions

packer -S acpi acpid laptop-mode-tools cpufrequtils pm-utils

I install the "outdated" batterymon by

packer -S batterymon
It does not run out of the box due to Python's 2 to 3 migration. An easy fix is to edit the shebang of /usr/bin/battery to /usr/bin/env python2. For it to work, be sure to start dbus and hal by /etc/rc.d/dbus start and /etc/rc.d/hal start. Add (... dbus hal ...) to DAEMONS in /etc/rc.conf. As noted here, dbus should procedes hal.

Setup the Desktop

The instructions are here. Basically, we need to do

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

Install fonts with

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

We can start installing awesome according to these instructions.

packer -S --noedit awesome rlwrap feh xscreensaver

Edit $HOME/.xinitrc. I use

/usr/bin/xscreensaver -no-splash &
xset dpms 600 900 1200
{ sleep 1 && xmodmap -e 'remove lock = Caps_Lock' -e 'add shift = Caps_Lock' \
                     -e 'remove mod1 = Alt_R' -e 'add mod4 = Alt_R'; } &
exec ck-launch-session awesome

Install slim for display manager (Login interface) by

packer -S slim slim-themes archlinux-themes-slim
and edit /etc/slim.conf. This file is nicely commented and you should be able to figure it out without much difficulty. A few tweaks I use are
sessions awesome
#current_theme rear-window
current_theme archlinux-soft-grey
default_user wei
The themes are listed in /usr/share/slim/themes/.

Edit /etc/inittab as follows

id:5:initdefault:
...
x:5:respawn:/usr/bin/slim >/dev/null 2>&1

Now we can reboot and log into awesome via slim.

Install Utilities

General

To make the rest of the procedure goes smoothly,

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

Install the following packages (YMMV)

packer -S rxvt-unicode sakura gksu gvim gnupg conky wmname
packer -S openssh putty firefox chromium uzbl-browser lynx mutt lftp git nmap aircrack-ng
packer -S --noedit tmux byobu screen irssi
packer -S emacs racket sbcl slime-cvs
packer -S gimp graphviz gnuplot xfig transfig fig2eps octave octave-forge r sage-mathematics
packer -S ntfs-3g gstreamer0.10-plugins gstreamer0.10-pulse mplayer mpd mpc ncmpcpp radiotray
#packer -S thunar thunar-volman thunar-archive-plugin xarchiver
#packer -S thunar-media-tags-plugin thunar-thumbnailers
packer -S qtfm mc autofs lsof sshfs
packer -S xarchiver gzip bzip2 zip unzip unrar p7zip
packer -S totem totem-plparser totem-plugin vlc vlc-plugin
packer -S gstreamer0.10-ugly-plugins gstreamer0.10-bad-plugins gstreamer0.10-ffmpeg
Here are my configurations for Vim, Emacs, Conky, qtfm, MPD, and uzbl.

autofs needs some initial setup; make sure to check this ArchWiki entry out! In summary, you need to

  1. modprobe autofs4 fuse; also add them to the MODULES line to your/etc/rc.conf.
  2. Edit /etc/autofs/auto.master. Set proper --timeout, e.g., --timeout=600 sets auto-umount timeout to 600 seconds (10 minutes).
  3. A good suggestion is to visudo your sudoers file with the line ALL ALL=(ALL) NOPASSWD: /usr/bin/killall -USR1 automount, which allows non-privileged user to umount with killall -USR1 automount. See automount(8) for the explanation of -USR1 signal.
  4. Add a line automount: files to /etc/nsswitch.conf.
  5. Add automount's startup option to /etc/conf.d/autofs's daemonoptions option, e.g., daemonoptions='--verbose'. Start the service with /etc/rc.d/autofs start
For reference, my /etc/autofs/auto.master is
/media /etc/autofs/auto.media --timeout=600
/media/ssh /etc/autofs/auto.ssh --timeout=600
My /etc/autofs/auto.media is
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# Details may be found in the autofs(5) manpage

cdrom -fstype=iso9660,ro,nodev,nosuid :/dev/cdrom
#floppy -fstype=auto,async,nodev,nosuid,umask=000 :/dev/fl
usb1 -fstype=auto,async,nodev,nosuid,umask=000 :/dev/sdb1
usb2 -fstype=auto,async,nodev,nosuid,umask=000 :/dev/sdc1
usb3 -fstype=auto,async,nodev,nosuid,umask=000 :/dev/sdd1
usb4 -fstype=auto,async,nodev,nosuid,umask=000 :/dev/sde1
Now you can automount your USB by simply accessing /media/usb*; Relevant references are autofs(5), auto.master(5), automount(8), automount mini-howtos, and GentooWiki entry.
My /etc/autofs/auto.ssh looks like (server.my.net is my server's hostname)
server  -fstype=fuse.sshfs.sshfs,rw,allow_other,IdentityFile=/home/wei/.ssh/id_dsa,port=22 \
   :pw@server.my.net\:/home/pw/
Before killall -HUP automount or /etc/rc.d/autofs restart, follow the procedure outlined in this ArchWiki entry first. In particular,
ssh-keygen -t dsa
ssh-copy-id -i /home/pw/.ssh/id_dsa.pub pw@server.my.net
sudo ssh -i /home/pw/.ssh/id_dsa pw@server.my.net
As noted in the entry, the last line is important: it adds the remote servers to root's ~/.ssh/known_hosts list; otherwise, ssh will get hung on the server fingerprint warning and wait in the background (of autofs) forever.

Now I can access the files on server.my.net through /media/ssh/server/. Convenient, isn't it?

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.

If you find Firefox a bit sluggish sometimes, try Chromium. A few of the extensions I use are Adblock, Forecastfox Weather, Speed Dial, Ultimate Chrome Flag, Facebook Photo Zoom, Google Mail Checker Plus. Wish Vimperator will be ported to Chromium some day.

[multilib]

In our Arch64 setup, since we have enabled [multilib] in /etc/pacman.conf,
packer -S libdvdread libdvdcss flashplugin skype

Networking

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 (packer -Qi empathy) to make it work correctly

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

Pidgin serves as an alternative to Empathy. Install with packer -S pidgin purple-plugin-pack aspell-en pidgin-otr pidgin-libnotify guifications microblog-purple. Use pacman -Ss aspell to list aspell's dictionary in other languages.

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.

Documentation

packer -S texlive-most lyx jabref xchm evince
packer -S openjdk6
packer -S ttf-dejavu artwiz-fonts ttf-ms-fonts
packer -S libreoffice
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

packer -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.

packer -S ibus-pinyin
and configure it via /usr/bin/ibus-setup.

Remember to install LibreOffice's Chinese language support

packer -S libreoffice-zh-CN

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 Do not panic if you find the look turns worse, because this is the caterpillar about to transform into butterfly

packer -S --noedit freetype2-ubuntu fontconfig-ubuntu libxft-ubuntu
Logout and login again. Enjoy the new look. :-)

Configuration Revisit

The following is the $HOME/.xinitrc on my laptop

source $HOME/.bashrc
ibus-daemon -d -x -r -n awesome
#urxvtd -q -o -f
#thunar --daemon & 
#batterymon -n 10 &
mpd $HOME/.mpd/mpd.conf
radiotray &

## Fun with XRandR settings
# Scenario 1
#xrandr --output LVDS1 --preferred
#xrandr --output VGA1 --preferred
#xrandr --output LVDS1 --primary
#xrandr --output VGA1 --right-of LVDS1
# Scenario 2
#xrandr  --fb 1920x1080 --output LVDS1 --scale 1.33x1.2 --output VGA1 --preferred
# Scenario 3
#xrandr  --fb 1920x1080 --output LVDS1 --off --output VGA1 --preferred

xscreensaver -no-splash &
#xrdb -merge $HOME/.Xresources
xset dpms 600 900 1200
( sleep 1 && xmodmap -e 'remove lock = Caps_Lock' -e 'add shift = Caps_Lock' \
                     -e 'remove mod1 = Alt_R' -e 'add mod4 = Alt_R'; ) &
( sleep 1; wmname LG3D && true ) & # fix JDK problem
                     
exec ck-launch-session awesome

The awesome configuration I use is here, which you can use by extracting it into your $HOME. Highlights of my tweaks are

... and Remember to Update the System

Do update and upgrade your system from time to time with

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