Wednesday, February 25, 2009

The Perfect ArchLinux Semi-Lightweight Desktop / LXDE

Introduction

Arch is a rolling-release, binary based distribution. Like Gentoo, you can piece your distro together, but you don't have to compile anything. Like Slack, you install only what you want, but you have dependency resolution. Like Gentoo and PCLinuxOS there are no versions of the distro; you simply update your system as usual to get the latest and greatest.

Unlike most of the 'top ten' distros, Arch can be lean and mean. It can also be a bloat fest. It's all up to you, the user.

Arch follows the KISS principal (Keep It Simple Stupid). The Simple aspect of the Arch Way refers to the ability to install a no-nonsense base system, and build upon that. You do have to configure the packages you install, as no assumptions are made by the installer.

Get the Install Media

The media I used is archlinux-2009.02-core-i686.iso, located here. I would highly recommend following the official Arch Installation Guide as you're installing your system. I have loosely based my guide on their guide. While it makes no sense for me to duplicate their content in this How-To, there's a lot of good information to be had in their guide. Specifically when it comes to installing the graphical interface. My install procedure is lean and mean, but theirs is much more comprehensive. So until you've got a GUI up and running, I recommend following both.

Keep in mind, that while this tutorial is rather verbose, it's not targeted to neophytes. Some basic understanding of Linux or UNIX will go a long way in helping you out. As well as some experience in using nano. Have Fun!

Installing ArchLinux



Boot off the CD.


Login as root. There is no password.


Run the Arch installer /arch/setup. Here's the welcome screen to the installer. Nothing special to note. Press Enter


Press Enter to select Select Source


Press Enter to select CD-ROM or OTHER SOURCE


Press Enter after taking note of where the CD ROM is mounted. You really won't need to know this for the install.


Select Set Clock


Pick whether your system clock (ie, what your BIOS is set to) is set to UTC or localtime. It is generally a better idea to set your system clock to UTC. But, if you dual boot with Windows, it'll be better to set your system clock to Local time. Either way will work fine.


Setting it to local time will require selecting a part of the world you're located in.


Narrow down your location.


I'm in Chicago, so I'll pick Central Time.


Verify that your time zone information is correct.


Set the date


Set the time


Select Prepare Hard Drive


Select Auto-Prepare


Select a size for your /boot partition


Select a size for your swap partition


Select a size for your root partition. For the tutorial, I'll increase the size. I won't have any documents stored on this system.


The remaining space will be used for your home partition. Verify the size.


Select a filesystem for root and home. If you don't know what to select, differ from the default and choose EXT3.


Verify your choice in filesystems


Your hard drive is about to be completely erased. Select Yes to continue. Your drive will be partitioned and formatted.


If all went well, you should get this message.


Select Return to Main Menu, as we're finished here.


Select Select Packages


This tells you that there are two stages of package selection. A basic selectioin, and a finer-grained section. Press Enter


Press enter to accept the current choice. We won't install any of the devel packages. We'll do that later, only if we need to.


Feel free to browse the packages that will be installed. If you know of anything you need, or dont' need, use the space bar to select/deselect packages. I'm fine with the defaults.


Select Install Packages.


You're ready to install! Press Enter to start installing.


If you scroll all the way down, you'll see the Package Installation Complete message. Press Enter.


Now it's time to configure your system


Pick a text editor. If you've never used vi, select nano as an editor.


Here is a list of configuration files. It would be wise to review the Configure the System section of the Arch Install Wiki for a comprehensive look at the configuration. I'll itemize the basics that need tending to.

/etc/rc.conf
Networking Section

HOSTNAME="myhost" - Enter your hostname
eth0="eth0 192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255" - Modify, or replace bold type with dhcp if you have a router/dhcp server
gateway="default gw 192.168.0.1" - Comment out line if using a router/dhcp server

/etc/hosts
Add your hostname to the aliases on the loopback line.

Root-Password. Use this to set the root password.


When finished, select Return at the bottom of the list. It'll take a few moments to configure the system.


Select Install Bootloader


Unless you know what you're doing, select GRUB.


Before GRUB will install, you'll have to review its contents.


Again, unless you need to add lines for another Operating System, just Ctrl-X to exit out of Nano.


Select the device file that represents your hard drive, not a specific partition.


Since we don't have software RAID, we can overlook this. This would important in a RAID 1 array because the MBR (where the boot loader is installed) is not mirrored. So, if the main disk fails, the boot loader is gone. But we don't have RAID.


GRUB install was successful!


Select Exit Install


Reboot the system, and you'll boot into your new Arch install.

Login as root. So far, this install is weighing in at around 578 MB. But this is just for a base system that is not capable of doing much of anything useful.

Since we installed off the CD-ROM, there's a good chance some packages are out of date. Let's update the system.
  • pacman -Syu
If the kernel gets updated, then you'll need to reboot. After upgrading, total system usage shoots up to 656 MB. That's because when packages are installed, the install files are kept in /var/cache/pacman/pkg. Since we're looking for a minimalistic desktop, let's clean up the package cache.

  • pacman -Scc

Enter Y to remove ALL packages from the cache. And Yes to remove unused repositories.

Now we're down to 622 MB. Next, add your user account, and give it a password. We'll call it archie.
  • useradd -m -G users,audio,lp,optical,storage,video,wheel,power -s /bin/bash archie
  • passwd archie
Install sudo, and configure it
  • pacman -S sudo
  • EDITOR=nano visudo
Uncomment the # %wheel ALL=(ALL) ALL line and exit. This will allow all users in the wheel group to do everything. Or, adjust to your taste.

For sound, I would read over the Arch Installation Guide . You've been following that too, right?

Installing a Graphical User Interface

OK, here comes the fun part. Let's install a GUI. To do this, we have to install the graphic server, and then install a window manager. Remember to follow the Arch guide also. We'll digress from the guide after the window manger is installed. There's still a lot of useful info in the Arch guide.
  • pacman -S libgl
  • pacman -S xorg
  • pacman -S xf86-input-evdev
  • pacman -S mesa
  • pacman -S xf86-video-vmware - or the video driver you need
  • Xorg -configure
  • cp /root/xorg.conf.new /etc/X11/xorg.conf
  • /etc/rc.d/hal start
  • /etc/rc.d/fam start
  • startx
Be sure to edit /etc/rc.conf, and add hal and fam to the list of daemons started. It's at the end of the file. You also may like the xorgcfg utility. It fires up X and has a graphical tool for configuring X. xorgconfig is a text base configurator, but requires a little more detailed knowledge of your hardware.

At this point, the graphic display should come up, with a few terminals windows and a clock. Press Ctrl-Alt-Backspace to kill the X server

Here's a few more additions to the xorg.conf file.


Section "Extensions"
Option "Composite" "Enable"
EndSection


Switch to your user account
  • su - archie
You could alternatively log out and log in.

Add exec xterm to the .xinitrc file. If you startx, you should get a GUI with a single terminal window. Press Ctrl-Alt-Backspace to kill X and get back to your terminal.

Install a Desktop Environment

Now that X is working, we can have a little more fun. The Arch Guide show how to install (in order from heaviest to lightest) KDE, Gnome, XFCE, and LXDE. Since we're going for a lightweight yet comfortable desktop, we'll use LXDE. If you don't like LXDE, XFCE would be a good alternative.

Also, there's no GUI tools in LXDE to administer your computer.

So, let's go!

Let's install some fonts, and install the GUI. As root,
  • pacman -S ttf-ms-fonts ttf-dejavu ttf-bitstream-vera lxde
Add exec startlxde to the .xinitrc file in your user's home folder. You could add this to root's as well. As your user,
  • startx
Inside of a virtual machine, on a P4 HT CPU, running other VMs, it took 3 seconds to load the LXDE desktop. That is unbelievably fast.

After a pacman -Scc, the total install size is 924 MB. My system is using 75M out of 256M installed in the system.
Add Applications

This is where the Arch guide ends, and the real work takes place. Since we have a lightweight, yet usable GUI, we'll have to be careful in our package selection so as not to chew up RAM and overload the CPU. This is assuming Arch is being installed on an older system. Even on a new system using heavyweight apps, LXDE will still outperform both Gnome and KDE, since the GUI overhead is kept at a minimum.

I must admit, I turned to DamnSmallLinux when it came to looking for light applications. Simply because they do a "damn fine job" at cramming all that functionality into a 50 megabyte distro. I entertained the possibility of using some of the software used by that distro for this guide. But for a modern desktop, it just didn't fit. DSL has it's purpose, and I use it myself. But for a desktop, it just doesn't suit me.

Before continuing with my software selections, you may want to review the Arch Common Apps page.

Package Management

pacman is fine for text mode installations. But let's install a package manager that we can use from the GUI.
  • pacman -S shaman
If you're new to Linux, this can be a great asset. It will also help you out as you get used to pacman. It makes it easier to browse for packages when you don't know the package name. This is the only package in this tutoria that uses the QT libraries. All others use GTK, if any. This package is optional, and is not needed to proceed.

Want to remove Shaman after using it, including all added dependancies? Here's how:
  • pacman -Rs shaman
Note that downloaded files for installation are kept in /var/cache/pacman/pkg
Note that the local sync'd database is kept in /var/lib/pacman/sync
Note that installed package listing is kept in /var/lib/pacman/local

Web Browser

This is where we're going to have to install the most useable browser. You could certainly install Dillo, but then you'd be limited as to the webistes you could visit. Here's an article on Dillo.

You could also try Midori. It has a slick feature that allows you to not download images on a web page, right in the status bar. Amaya is the w3c's web browser/editor.

But I think anything other than Firefox will just not do for today's websites. Not to mention, if you're considering Midori or Amaya, just spring for the extra few megs and use Firefox. Just be conservative as to the extentions you add. So let's install Firefox, and make one vital tweak.
  • pacman -S firefox
Lauch Firefox. In the address bar, enter about:config. Click the 'I'll be careful, I promise!' button. In the filter box, enter general. Double click general.useragent.extra.firefox. Change it from GranPardiso/3.0.6 to Firefox/3.0.6 - just maintain your existing version number. This will allow you to add third-party add-ons and toolbars designed for Firefox. Gran Pardiso is a Mozilla sponsored rebranding of Firefox. The user agent is how your browser identifies itself to websites. For example, the Yahoo Toolbar website checks your user agent. If it doesn't match Firefox, it tells you it can't install it. Aggravating, since GranPardiso (and IceWeasel) are 99.9% Firefox.

Opera is another alternative, but is QT-centric. Firefox is GTK-centric, so we're sticking with the minimalistic approach here. Sort of. I like Opera a lot, but there's some sites that it just doesn't work with.

Email

Sylpheed is DSL's choice in email clients. It's really not a bad choice at all. The limitations I see are not having the ability to add extensions to the program. For basic IMAP or POP emails, it's quite nice. And it integrates well into a GTK environment.

But, I have to pass on Sylpheed. There's too many extensions for Thunderbird that make it the better choice. And, we also have chosen its sibling as a web browser. So Thunderbird wins, by a hair.
  • pacman -S thunderbird
Instant Messaging
  • pacman -S pidgin
Office Suites

OpenOffice is probably the most usable office suite around. Koffice is another good choice, second to OpenOffice. GnomeOffice is the lightest of the 'Big Three', lets lacks on some of the more advanced feature. . OpenOffice provides the best compatibility with MS Office, though it's not perfect. If you only need to keep documents for personal use and not share them with the outside world, then you can use pretty much anything. If you do need to distribute a file, there's always the option of sending a PDF. While I've made my selections below, you may want to choose to install OpenOffice instead. It all depends on your needs.

Word Processors

Abiword is the word processor of the Gnome Office suite of apps. It has decent MS Word import abilities. Feels modern. And has most of what an at-home user would need. It's not as complete as OO Writer, but it doesn't choke your system, either.
  • pacman -Ss abiword
The abiword-plugins package is optional, but it does extend the functionality. This adds a thesaurus, as well as some other handy tools. Install this if you like.

Spreadsheets

Siag is DSL's spreadsheet. It really doesn't feel like a spredsheet should. I must be used to OO. I'm taking Siag off the table as a possible option. Since I've used Abiword for a word processor, I'm sticking with that line of thought.
  • pacman -S gnumeric
Looks like Gnome Office is going to be the way to go. That's OK. We need to be lightweight, but useable.

PDF Reader

Always a good idea
  • pacman -S xpdf
Photo Management

My choice here is Gthumb. OK, it's not the primo photo management tool. But it's capable of doing the job. Complete with minor photo enhancements. F-spot is a good choice too, but in this case, the lighter package won out
  • pacman -S gthumb

Photo Manipulation

The de-facto Linux standard is the Gimp. Certain photo album software has stripped-down editing software. But for any serious work, it's the Gimp. If you're concerned about hard drive space, you need not install this, as gthumb has a basic set of tools for photo editing that should suit the needs of the casual user.
  • pacman -S gimp
An alternative to the Gimp, is gimpshop. It modifies the layout of the interface to match that of Adobe Photoshop. It's not my choice, as I'd rather use the real thing.

Vector Graphics

Inkscape is the Linux answer to Adobe Illustrator. It's no where near as robust. But it's done everything I've needed to do. Note that I'm not a graphic artist!
  • pacman -S inkscape
Personal Finance

Of the good options, only one fits into the GTK ecosystem. As much as I like KMyMoney, it's got to be Gnucash for our little QT free system. Except for Shaman, if you installed it.
  • pacman -S gnucash
Movie Player

Keeping with the GTK-centric applications chosen, we'll install the Totem movie player, and the plugin for Mozilla browsers.
  • pacman -S totem totem-plugin
Music Player

The slim, yet powerful Quod Libet would be a great choice in a music player. But Exaile edged it out because of iPod support. Rhythmbox would be a fair choice also, but it depends on a lot of Gnome stuff, including Nautilus.
  • pacman -S exaile
Additional Media Codecs

Gotta have the codecs. The more the merrier.
  • pacman -S flashplugin codecs xvidcore libdvdcss
CD/DVD Burning

Graveman would be a tempting choice in burning software. However it is not quite mature, and lacks the ability to burn video DVD's. Brasero wins.
  • pacman -S brasero
Printing System

OK, I guess you'll want to print at some point. So let's install CUPS, the Common Unix Printing System.
  • pacman -S cups cups-pdf
  • /etc/rc.d/cups start
Be sure to add cups to the list of daemons in /etc/rc.conf so it starts on the next boot. Also, add the following line in /etc/cups/cups-pdf.conf, under the Pathname heading.

/etc/cups/cups-pdf.conf

Out /home/${USER}


This will insure your PDF file gets placed in your home directory, instead of /var/spool/cups-pdf/archie, or whatever your username is.

Physical printers will require installing additional drivers. Check out foomatic and hpijs.

Login Manager

This step is optional. Instead of booting to a console, logging in, and starting X, this will boot to a login manager where you enter your username and password.
  • pacman -S slim slim-themes archlinux-themes-slim
We'll need to edit a line in the config file for slim.

/etc/slim.conf
current_theme           archlinux-simplyblack


Additional themes can be found in /usr/share/slim/themes.

Now, let's modify the /etc/inittab file to fire up slim at boot. Using the daemon method would work, but if you wanted to change run levels to single user mode, it wouldn't work.

/etc/inittab
# Boot to console
#id:3:initdefault:
# Boot to X11
id:5:initdefault:

# Example lines for starting a login manager
x:5:respawn:/usr/bin/slim >& /dev/null


This first set of lines tells Arch to boot in to graphical mode instead of text mode. The second set tells which login manager to use. Some examples may be present. Make sure that all other login managers are commented out except for slim.

Please note that .xinitrc still controls which desktop to load. Further info can be found on the Arch Slim tutorial page, and the Adding a Login Manager page.

First Stage Summary


Now our install size is about 1.8 Gigs. When I reboot now, login, and check memory, I show 41 Megs used, and 21 Megs cached. That's a total of 20 megs used. Not bad at all!

There is, however, a few more things we could install if we want to. The following items are strictly eye-candy, and are optional.

Eye Candy

Nitrogen - For wallpaper

In order for Conky to work properly, as you'll see in the next section, we'll have to stop letting PCmanFM control the desktop. For that to work, we'll have to use something else to use wallpaper. Black screens get really boring.

Right click on the desktop, and select Desktop Settings. Click on the Desktop tab. Uncheck Manage the desktop and show file icons. Click OK.

Now, as root,
  • pacman -S nitrogen
As your user, enter
  • nitrogen /usr/share/lxde/wallpapers
Select a wallpaper to use. You can safely ignore any error messages on the console

Edit your ~/.xinitrc file so it looks like the following.

~/.xinitrc
( sleep 3 && nitrogen --restore /usr/share/lxde/wallpapers ) &
exec startlxde


That's all there is to it. You can specify an alternate location for wallpaper, something like ~/wallpaper that is located in your home directory. It's up to you. Just create the directory, and edit the above as necessary.

Conky - System Monitor


This piece of eyecandy is somewhat useful. What it does is place a transparent system monitor on the desktop, that updates itself at an interval you determine. Let's go!
  • pacman -S conky
And now create/edit your ~/.conkyrc file

/home/user/.conkyrc

update_interval 3.0
alignment top_right
minimum_size 250
gap_x 5
gap_y 5


own_window yes
own_window_type desktop
own_window_transparent yes
own_window_hints undecorated,below,skip_taskbar
double_buffer yes
draw_shades no

TEXT
SYSTEM ${hr 2}
${time %a %b %d %Y} ${time %I:%M%p}
$nodename - $kernel

CPU ${hr 2}
${freq} MHz ${color red}Load: ${loadavg}${color}
${cpugraph 000000 ffffff}
${cpubar}

NAME PID CPU% MEM%
${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}

PHYSICAL MEMORY ${hr 2}
RAM: ${mem} of ${memmax} / ${memperc}%
${membar 6}

SWAP ${hr 2}
Swap: ${swap} of ${swapmax} / ${swapperc}%
${swapbar 6}

DISK ${hr 2}
/boot sda1: ${fs_bar 6 /boot}
/ sda3: ${fs_bar 6 /}
/home sda4: ${fs_bar 6 /home}

NETWORK ${addr eth0} ${hr 2}
Down: ${downspeed eth0} k/s ${alignr}Up: ${upspeed eth0} k/s
${downspeedgraph eth0 25,140 00000 ffffff} ${alignr}${upspeedgraph eth0 25,140 000000 ff0000}
Total Down: ${totaldown eth0} ${alignr}Total Up: ${totalup eth0}


This begets the following display

Now, let's make it start every time you log in. Note that this is on a per-user basis
  • mkdir -P ~/.config/lxsession/LXDE
Inside of the newly created directory, create the following file

~/.config/lxsession/LXDE/autostart

#/bin/bash
conky &


And at the console, as your user, enter
  • chmod 755 ~/.config/lxsession/LXDE/autostart
This will make it executable. Now every time you log in, conky will start.

Wbar - OSX style launch bar

If you're familiar with OSX, you no doubt are familiar with the launch bar on the bottom of the screen. We have something similar called wbar. All this panel does is provide a bar for launching applications. It unfortunately does not have a dock bar for minimized apps
  • pacman -S wbar
Make it start at login. Add this line to the .xinitrc file, above the exec startlxde

~/.xinitrc
( sleep 5 && wbar -above-desk -pos top -isize 30 -nanim 3 -balfa 0 -bpress ) &
( sleep 3 && nitrogen --restore /usr/share/lxde/wallpapers ) &

exec startlxde


The idea behind using sleep functions is to allow the desktop environment to start, then put up wallpaper, and then put up wbar. The desktop should load before the wallpaper, and the wallpaper should load before wbar. You may need to adjust the sleep time for everything to work properly.

Now let's configure wbar with the installed applications.

~/.wbar
# The Bar && Font
i: /usr/share/wbar/iconpack/wbar.osx/osxbarback.png
t: /usr/share/wbar/iconpack/comic/12
c:

i: /usr/share/pcmanfm/icons/folder.png
c: pcmanfm
t: PCmanFM

i: /usr/share/pixmaps/lxterminal.png
c: lxterminal
t: LXterminal

i: /usr/share/wbar/iconpack/wbar.osx/firefox.png
c: firefox
t: Firefox

i: /usr/share/pixmaps/thunderbird.png
c: thunderbird
t: Thunderbird

i: /usr/share/icons/hicolor/48x48/apps/pidgin.png
c: pidgin
t: Pidgin

i: /usr/share/pixmaps/abiword_48.png
c: abiword
t: Abiword

i: /usr/share/pixmaps/gnome-gnumeric.png
c: gnumeric
t: Gnumeric

i: /usr/share/icons/hicolor/48x48/apps/gnucash-icon.png
c: gnucash
t: Gnucash

i: /usr/share/icons/hicolor/48x48/apps/gimp.png
c: gimp
t: The Gimp

i: /usr/share/pixmaps/inkscape.png
c: inkscape
t: Inkscape

i: /usr/share/icons/hicolor/48x48/apps/gthumb.png
c: gthumb
t: Gthumb

i: /usr/share/icons/hicolor/48x48/apps/brasero.png
c: brasero
t: Brasero

i: /usr/share/pixmaps/exaile.png
c: exaile
t: Exaile

i: /usr/share/icons/hicolor/48x48/apps/totem.png
c: totem
t: Totem


Note that if you change the config file or the wallpaper, wbar will not automatically update. If you right click anywhere on the bar, it wiil reread the config file and redraw the launch bar.

LXpanel

Since we have wbar installed, we don't really need all the stuff in the lxpanel. We will keep a few things, though.
  1. Right click in the taskbar area of the panel and select Panel Settings.
  2. Under Background, select Enable Transparency. The default tint should suffice, but feel free to modify it to your taste.
  3. Right click on the open folder towards the bottom left corner of the screen
  4. Select "Application Launch Bar" Settings
  5. Remove all buttons
  6. Click Close


This will leave you with the standard menu, the Iconify Windows button, a pager, a transparent dock bar, a clock, and a CPU load meter.

System Management

If you like, you could install some of the Gnome tools for system management.
  • pacman -S gnome-system-tools
This will give you tools for the network, services, shared folder, time and date, and users and groups. This is optional, and it will pull in some Gnome components like Nautilus.

Summary

Now you should have a lilghtweight, and very responsive desktop. I'm amazed how quickly things lauch, and the small memory footprint that the desktop takes up. Add to that the functionality of the desktop. It's no KDE, but then again, that may be a good thing!

For grins, I installed OpenOffice, just to see how much faster it starts under LXDE. It took about 14 seconds to lauch Writer the first time, and about 3 seconds to lauch it the second time -- Inside of a virtual machine! Not bad at all!

-- Dr. Rockhopper

No comments: