Friday, September 28, 2012

Archlinux + Systemd + Fluxbox + Old laptop = Impressive Speed

Alright, around two/three weeks ago I uninstalled wattOS R5 from one of my old laptops and decided I'd get Arch on it, and since I liked Fluxbox on Ubuntu so much, why not do exactly that: Archlinux + Fluxbox on this oldie laptop? Anyway, I'll try to write a guide on getting a basic Archlinux with Systemd set up. Then we'll get to a point where I install the applications (including Fluxbox) I use, you can install whatever you like though, just adapt it for your system.

"Everything" (as far as I can remember) I did I wrote on a text file so I'll post step by step what I did, but be advised, I did this a few weeks ago so I cannot be absolutely sure that EVERY command is listed here and since I don't know the specs of your computer, what's written here may not work for you. With this disclaimer: in case anyone wants to try this out and gets stuck remember that Archwiki is your friend! I didn't make any of this up, I just followed the Archwiki guide.

Also, one more advice: if you really want to do this, read the whole post before attemping to do this!

So here we go!

PRE-INSTALL

0) First download the iso boot it. :)

After booting you'll be presented just with a terminal. Don't be scared, in no time we'll have a system running.

1) First thing we do is loading the proper keyboard layout with the loadkeys command. You can load any keyboard layout listed on /usr/share/kbd/keymaps/. In my case, it's a br-abnt2 keyboard. Simply type:

loadkeys br-abnt2

2) Then we need to partition the drive(s). The tool included on the Arch cd is fdisk. Before using fdisk though, you may want to see what your current partitions are, and for that just use the lsblk command. I just erased all partitions I had and created 2: the root (/) partition and a swap partition. This lappy only has 512MB (shared with video card) of RAM so I need a swap partition. Anyway, just type:

fdisk /dev/sda

and follow the instructions. Fdisk may seem wierd if you have never used it, but with a little patience you'll get there. I'd post every step I took during the execution of fdisk but I didn't take notes of them (sorry...). Alternatively you can boot any livecd of your choice (Ubuntu is a good and popular one, it has gparted, which is a pretty stright forward partitioning program) and partiton your hard drive(s) on a graphical interface program. If you're gonna run Arch, you might as well learn to use fdisk!

3) Since I used fdisk, I now had two partitons: one with 39GB (/dev/sda1) which I had to turn into a ext4 root partition and one with 1GB (/dev/sda2) which I had to turn into my swap partition. Now this is very easy:

mkfs -t ext4 /dev/sda1

The above command creates a ext4 file system on /dev/sda1.

mkswap /dev/sda2

The above command creates swap area on /dev/sda2.

swapon /dev/sda2

The above command activates the swap area.

INSTALLING A BASE SYSTEM

Now we're ready to install a base system. But before that, we'll need to get the internet connection working. The easiest way (and the way I did it) is having a cabled connection to a router running a DHCP server. After getting networking working, we have to mount the root partition somewhere on our basic system, copy stuff there and then chroot into it.

4) Next we mount the hdd on /mnt of our system:

mount /dev/sda1 /mnt

5) Then we ask for a IP address from the DHCP server:

dhclient

If you wish to use a static ip address, check Archwiki for more details.

Now, before proceeding let's test if the internet connection in working:

ping -c 3 google.com

If all goes well, we can proceed.

6) Now we can install a very basic system to our hdd that is mounted on /mnt:

pacstrap /mnt base base-devel grub-bios

7) Next we have to generate a fstab file. To do it:

genfstab -p /mnt >> /mnt/etc/fstab

8) Now we're ready to chroot into our new system! In case you don't know what chroot is, check out Archwiki. Anyway, now we do:

arch-chroot /mnt

9) We're almost there! Now we're on the root of our new system! There's a lot of quick stuff to do:

9.1) Write your hostname to /etc/hostname file. Just type anything you want, mine was hp-laptop (creative right?).

9.2) Symlink /etc/localtime to /usr/share/zoneinfo/Zone/SubZone. Replace Zone and Subzone to your liking. In my case:

ln -s /usr/share/zoneinfo/America/Recife /etc/localtime

9.3) Set locale in /etc/locale.conf. Even though I'm Brazilian I use default english US as my locale (I don't want software translated). So I just wrote "LANG="en_US.UTF-8"" to my /etc/locale.conf, without the outter quotes.

For my Brazilian friends, these might work:

LANG="pt_BR.UTF-8"
LANG="pt_BR ISO-8859-1"


9.4) Add console keymap and font preferences in /etc/vconsole.conf. Check the Archwiki for more details. I used:

KEYMAP=br-abnt2
FONT=default8x16

9.5) Uncomment the selected locale in /etc/locale.gen and generate it with locale-gen:

locale-gen

9.6) Now we have to configure /etc/mkinitcpio.conf and create an initial RAM disk. I used the default one, except that I added consolefont keymap to the end of the HOOKS array. Then we have to run:

mkinitcpio -p linux

Great! RAM disk is created, now we only need to install and configure grub2 so we can reboot and have a very basic system!

9.7) Now, to install grub2 on the MBR (Master boot record) of the hdd:

modprobe dm-mod
grub-install --target=i386-pc --recheck --debug /dev/sda
cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo


Now we have to edit /etc/default/grub and add the following to the GRUB_CMDLINE_LINUX line:

init=/bin/systemd

Also, I took quiet out of the GRUB_CMDLINE_LINUX line.

This will make your system run on a systemV/systemd hybrid setup. Later we'll make it systemd pure!

9.8) Now we have to make the grub config file:

grub-mkconfig -o /boot/grub/grub.cfg

Grub2 should be working! Now we only need...

9.9)... to setup a root password!

passwd

9.10) Now we get out of the chroot environment with Crtl+D and unmount the hd file system:

umount /mnt

Now we can reboot!

reboot

Now take that cd out of the drive and grub2 should boot!

RUNNING A SYSTEMD PURE SYSTEM!

10) Ok, so now systemd is getting its info of which daemons to run from the /etc/rc.conf file and we'll fix that. The deafult rc.conf file only has 3 daemons on the DAEMONS array: syslog-ng, network, crond. What we'll do is enable these services on systemd so we can ditch the rc.conf file:

systemclt enable syslog-ng
systemclt enable cronie
systemclt enable dhcpcd@eth0


Like I said, I have a router with a DHCP server, so the last line means exactly that: ask the DHCP server for an ip address. If you're using static ip address, check the Archwiki.

I'd like to spend some time here and explain something really important. In Arch, on the contrary of Debian, Ubuntu, Fedora, etc, the system will only run programs you tell it to run. I mean, on the course of this tutorial we'll install some other daemons and for each one we'll have to enable them manually. I (and I reckon all other Archers :P) like this because everything that's running it's because you told the system to do so.

Now reboot just to check if everything is working (and it should be!)

11) Now remove the init=/bin/systemd entry on /etc/default/grub and run:

grub-mkconfig -o /boot/grub/grub.cfg

12) Configure the package manager (pacman) by editing /etc/pacman.conf. I didn't change the default settings for now. I just ran:

pacman -Syy
pacman -Syu


13) Now, for a pure systemd system:

pacman -Rsn initscripts
pacman -S systemd-sysvcompat


Now reboot. If your computer booted (and it should have), then you're running a pure systemd system. Enjoy the full speed boot!

ADDING A USER, SOUND, VIDEO, ETC.

All right! Now he have a base system booting with grub and systemd. Now we can add a regular user (you shouldn't run as root!), sound, video, wifi, desktop environment / window manager, apps, etc.

14) Firstly, we add our usual user :P. Just run the command below and change the last word "username" for the username that you want.

useradd -m -g users -G audio,games,lp,optical,power,scanner,storage,video -s /bin/bash username

To add a password:

passwd username password

Of course, change "username" for your username and "password" for your password. :P

15) Ok, so you created your username, but having to change to root everytime you need root access is a pain. Let's install sudo:

pacman -S sudo

Now we have to edit the /etc/sudoers file and add the regular user's username to the list of sudoers. Simply run:

visudo

You should always edit the sudoers file using visudo because after editing it, it checks the file for any errors. Also, learn to use vi (or vim), I am begining to and I can already see why people like it so much.

Now, just below this line:

root ALL=(ALL) ALL

Add:

username ALL=(ALL) ALL

Again, change username to your username. Great, now we have sudo installed, so type:

exit

And login using your username and passy. Now we can use sudo everytime we need root access.

16) Ok, now we'll get sound working. But before that I'll explain the very basics of how to use pacman, Arch's awesome package manager. I'll just show the most basic commands: install packages, search packages, remove packages and do system upgrades. You'll get to learn how to use pacman by using it later. So, the basic commands:

To install packages:
pacman -S package1 package2 package3...
You can install any number of packages you want using a single line.

To search for packages to install:
pacman -Ss string
string can be the package name or discription. Each package has a brief discription and this command searches these discriptions. Any matches are then displayed.

To uninstall packages:
pacman -Rsn package1 package2 package3...
The -R is for removal, s for removing any unnecessary dependencies and n for removing the configuration files of all packages removed.

To fully upgrade the system:
pacman -Suy
Remember: Arch is a rolling release bleeding-edge distro. Before updating, check the forums to see if any new package is braking peoples systems. It NEVER happened to me, but some people have complained about it, so you never know.

Back to the tut: simply install the alsa packages by running the command below:

sudo pacman -S alsa-utils alsa-plugins alsa-oss
alsamixer


I can't remember if alsamixer has to be run as root or not. Try as your regular user, if that doesn't work, then sudo it. A ncurses user interface is shown to you, so set your volumes and unmute the channels. Now run:

sudo alsactl store

I had to reboot my laptop at this point so my channels would actually unmute.

17) Now we have to install X server and the video driver! Easy enough:

sudo pacman -S xorg-server xorg-xinit xorg-server-utils mesa mesa-demos

Now we need to find out which graphics card the computer has by doing:

lspci | grep -i vga

Mine is a ATI XPRESS 200M 5955 so I have to install the ATI driver. In my case:

sudo pacman -S xf86-video-ati

To get a list of available drivers do:

sudo pacman -Ss xf86-video | less

Hit q to quit. Now you probably know which driver to install. These are open-source drivers. If you want to install proprietary ones, check the Archwiki for the particular manufacturer of your graphics card.

18) Since I'm installing Arch on a laptop, I need synaptics for the touchpad:

sudo pacman -S xf86-input-synaptics

I used the "default" configuration listed on Archwiki. Simply add those lines to /etc/X11/xorg.conf.d/10-synaptics.conf:

To properly setup your keyboard on X, paste the contents of this link on /etc/X11/xorg.conf.d/10-evdev.conf

The "XkbLayout" and "XkbVariant" values depend on your keyboard mapping. Check Archwiki for more info, but everything you need to know is the /usr/share/X11/xkb/rules/base.lst file. You'll figure it out. At first I used "br" and "nodeadkeys" for "XkbLayout" and "XkbVariant", respectively. But the ^'~ type chacracters did not work well (for portuguese writng, that is). To fix it, I just took the "XkbVariant" out.

19) Now we install 3 more basic X packages and then we're ready to test X:

sudo pacman -S xorg-twm xorg-xclock xterm

Make sure there is no .xinitrc file on your user's home folder:

make sure: rm ~/.xinitrc

Now we can test X by running:

startx

You should see 3 terminals running. Exit the leftmost of them and you'll return to the CLI. If X failed, try to reboot and try again. If it still doesn't run, you (or me!) probably forgot to do (write) something. But everything should be ok.

20) Now we install some fonts to make our future desktop look better :)

sudo pacman -S ttf-dejavu ttf-inconsolata ttf-liberation ttf-ubuntu-font-family

21) Ok, so now I had to get AUR (Arch User Repository) working because my wifi card is really annoying and I need some aur packages to get it working. So, what is AUR you ask, it's a repository with packages made by fellow Archers that are good enough to help us less knownledgeable users to get software that's not on the main arch repos.

To get AUR working, just add this to end of your /etc/pacman.conf file:

[archlinuxfr]
Server = http://repo.archlinux.fr/$arch


Now run:

sudo pacman -S pacman-color yaourt

pacman-color is a cool program: it's pacman, with colors! :P

To use it more easily simply alias it to pacman so it gets executed instead of the regular pacman when you call pacman. Simply add this to the end of the ~/.bashrc file:

alias pacman='sudo pacman-color'

This way, everytime you type pacman, the shell interprets as being "sudo pacman-color". Cool right?

yaourt is the program used to install, update, search and remove aur packages. It has the same syntax of pacman but you should NEVER run it as root!

So, my wifi card is (just ran lspci | grep -i wireless):

Network controller: Broadcom Corporation BCM4318 [AirForce One 54g] 802.11g Wireless LAN Controller (rev 02)

I needed to install the package b43-firmware from aur:

pacman -Suy
yaourt -S b43-firmware


Also, I blacklisted b43legacy module by adding "blacklist b43legacy" (wthout the quotes) to the file /etc/modprobe.d/wifi.conf

Wifi cards are always a pain, I do expect that your wifi card setup isn't as bad as mine. Anyway, the wifi led on the laptop went on but configuring a wifi card on CLI is a pain so I waited till my window manager (Fluxbox!) was installed so I could do it on a graphical environment.

22) Now that we have a basic system with pacman and network we're ready to install Display Managers, Desktop Environments or Window Managers and all kinds of applications! Like I said in the very first paragraph of this post: this is a matter of personal taste. You can use any programs you feel comfortable. Wanna use KDE, install KDE. Wanna use Gnome, install Gnome.

For now, let's focus on the DE/WM and DM. As I already said, I'm gonna use Fluxbox as my WM. To install it:

pacman -S fluxbox

Secondly, let's install the Display Manager. I chose (as always) SLiM. As the name says, it's the slimmest DM I know, and since the only thing a DM does is manage your logins, I see no purpose on having a fancy DM. So, to install SLiM (and some themes that go well with it):

pacman -S slim slim-themes archlinux-themes-slim

Now, to configure SLiM (we will configure Fluxbox once we boot into it) we just have to edit /etc/slim.conf. It's all there, but I usually change just two lines (and remove the # from the begining of the lines, where applicable): default_user (change it to you own instead of the one written there) so that when SLiM boots your username is already typed and current_theme (you can choose themes from /usr/share/slim/themes, but always use the "archlinux-simplyblack" theme).

Next we copy the default .xinitrc file to your user's home dir:

cp /etc/skel/.xinitrc ~/.xinitrc

Then we have to add a line at the end of ~/.xinitrc so that SLiM can launch the WM/DE that we have installed. In this case:

exec ck-launch-session startfluxbox

We have to add the ck-launch-session to get automount to work (as in automounting USB keys, DVDs, etc.).

Only one more step to go, enable SLiM on systemd:

sudo systemctl enable slim.service

If we rebooted the computer now, then SLiM would boot and after logging in SLiM would execute Fluxbox. But, let's stick to command line some more.

23) Since I'm on a notebook, I need a wifi connection manager. I'll use wicd. To install it:

pacman -S wicd wicd-gtk

To make wicd starts after boot, well add it to systemd's services:

sudo systemctl enable wicd.service

24) Now let's make sure our clock will always be synced. Let's install ntpd (NTP Daemon):

pacman -S ntp

Now we edit /etc/ntp.conf

And since I'm in South-America I added the following to my ntp.conf:

server 0.south-america.pool.ntp.org iburst
server 1.south-america.pool.ntp.org iburst
server 2.south-america.pool.ntp.org iburst
server 3.south-america.pool.ntp.org iburst

To know the actual server of your continent check this out.

Now we add ntpd to systemd's services:

sudo systemctl enable ntpd.service

25) This step is optional though. There's one program I found out about recently called preload. This program "learns" which other programs you most often use and preloads some libraries they need to RAM, making them startup faster. Since I'm going for a "minimalistic" install (it could get more minimalistic, but for me this is minimalistic enough), I have some RAM to spare, and since the processor and hdd of this laptop are slow, preload comes in handy. To install it:

pacman -S preload

As usual, we add this to systemd's services:

sudo systemctl enable preload.service

I didn't mess with the config, but if you're willing, it's located in /etc/preload.conf

26) Fantastic! Now the only thing missing are the actual programs, icons, etc. we're going to use! Again, this is a matter of personal taste. If you want chromium as your browser instead of firefox, just install it and leave firefox out. To find out the name of the package of a certain program/icon them/font/etc just use:

pacman -Ss search_string

I'll list the programs I installed like this:

"Category" or "Why do I need it" - package(s) name

Also, Archwiki has a page that lists some common programs you may want. So, let's begin.

Makes it easier configuring the UI - lxappearance

Icon themes - gnome-icon-theme gnome-icon-theme-extras hicolor-icon-theme human-icon-theme tangerine-icon-theme azenis-icon-theme

Cursor themes - xcursor-vanilla-dmz xcursor-vanilla-dmz-aa xcursor-themes xcursor-bluecurve xcursor-flatbed xcursor-premium xcursor-flatbed xcursor-pinux

Bittorrent client - transmission-gtk

Web browser (Uzbl as main and Firefox as fallback) - uzbl-core uzbl-browser firefox

Download manager - fatrat

FTP client - filezilla

Picture viewer (feh can be used to set backgrounds easily) - gpicview feh

Take screenshots (just do import /path/to/file.jpg to take a screenshot, but actually, imagemagick does much more) - imagemagick

Music player - audacious

Video player - vlc

CD/DVD burning - xfburn

Un/compress utilities - p7zip file-roller unrar unzip

Run graphical programs as root - gksu

File manager (PCManFM) + ability to mount samba shares - pcmanfm gamin gvfs gvfs-smb smbclient

PDF reader - evince

Office suite - libreoffice

SSH client - putty

Calculator - galculator

Conky (needs no introduction I guess) - conky

Terminal emulator - roxterm

Text editor (like I said, I'm trying to learn vi(m), for a more usual program, you could get leafpad or mousepad) - gvim

NOTE: givm package now includes vim.

Programming IDE - geany

Task manager - lxtask

Screensaver (and lock screen!) - xscreensaver

Volume icon for the system tray (not needed if you install some fancy DE like gnome or KDE) - volumeicon

Battery indicator (form AUR) - sudo yaourt -S slimebattery-git

Java, flash and other plugins - jre7-openjdk jr7-openjdk-headless icedtea-web-java7 flashplugin gecko-mediaplayer gstreamer0.10-plugins

NOTE: I had to install jr7-openjdk-headless twice on the first time it was in conflict with some other package I can't remember.

Ok! That was a lot of packages. To install all that:

pacman -S lxappearance gnome-icon-theme gnome-icon-theme-extras hicolor-icon-theme human-icon-theme tangerine-icon-theme azenis-icon-theme xcursor-vanilla-dmz xcursor-vanilla-dmz-aa xcursor-themes xcursor-bluecurve xcursor-flatbed xcursor-premium xcursor-flatbed xcursor-pinux transmission-gtk uzbl-core uzbl-browser firefox fatrat filezilla gpicview feh imagemagick audacious vlc xfburn p7zip file-roller unrar unzip gksu pcmanfm gamin gvfs gvfs-smb smbclient evince libreoffice putty galculator conky roxterm gvim geany lxtask xscreensaver volumeicon jre7-openjdk jr7-openjdk-headless icedtea-web-java7 flashplugin gecko-mediaplayer gstreamer0.10-plugins

sudo yaourt -S slimebattery-git


27) One final thing before booting into Fluxbox: to get wicd's icon, slime's icon and volumeicon's icon to show on the system tray and to make xscreensaver launch on startup, one just has to add the following to ~/.fluxbox/startup file (to find out where it should go, just read the file):

wicd-client -t &
xscreensaver -nosplash &
slimebattery --change-icon --interval 60 &
volumeicon &


That "--interval 60" option on slime means that the battery charge level will be updated every 60 seconds.

28) Now we're ready to boot into Fluxbox (or whatever DE/WM ytou chose). Just:

sudo reboot

And login!

29) Great, now you logged in to you DE/WM. Congrats. Now the only thing that needs to be done is configuring your DE/WM. As for configuring Fluxbox, I did something very similar to my post "Fluxbox: I liked it! :)" (post before the previous one). To get more Fluxbox styles, check this page out. To install styles, simply copy them to ~/.fluxbox/styles.

Also, the default menu is very poor. To make a new one, firstly you can do the following:

pacman -S archlinux-xdg-menu
xdg_menu --fullmenu --format fluxbox --root-menu /etc/xdg/menus/arch-applications.menu >~/.fluxbox/menu


And then you edit your ~/.fluxbox/menu to include your custom entries.

30) One last optional thing: after configuring everything, I ran conky and the CPU's frequency was set to 800MHz, but the rated frequency of this laptop's CPU is 1600MHz. After some researching, I found out that CPU scaling is enabled by default in current kernels (remember Arch is bleeding edge!) and it works like this: until your CPU reaches a certain load, the kernel keeps it in a low frequency state and when the load increases, it increases the CPU's frequency, that's called the "on-demand" governor, and that's the default setting set by the kernel. I'm ok with that, since lower frequency means less energy spent. But I wanted to have a way to fix it anyway, I wanted to find a way to set my governor to "performance" (rated frequency at all times). All details are here. So I just needed to install the cpupower daemon and make sure that systemd was told to run it as startup. So, here are the commands:

sudo pacman -S cpupower
sudo systemclt enable cpupower.service


And to switch between "on-demand" and "performance" governors I just added the following to my ~/.fluxbox/keys file.

Mod4 p :ToggleCmd {Exec sudo cpupower frequency-set -g ondemand} {Exec sudo cpupower frequency-set -g performance}

That means that pressing the super key + p switches between the "on-demand" and "performance" governors. Of course, I had to add to add the following to my sudoers file:

myusername ALL=NOPASSWD:/sbin/shutdown,/sbin/reboot,/usr/bin/cpupower

Or else I'd have to keep inputting my password. The shutdown and reboot commands are there also so I can use those commands on Fluxbox's menu without supplying password (see my "Fluxbox: I liked it! :)" post)

31) One final tip: it's possible to issue Fluxbox commands through bash shell using the fluxbox-remote command. I used on a script that sets my VGA-out. Everytime I returned to the native resolution of my LCD screen Fluxbox would display the task bar in the middle of the screen. It can be easily set it back to it's right place by issuing the Reconfigure command on Fluxbox's menu, but I wanted to include this on the script so it would be done automatically. Anyway, here's the command I used on the script:

fluxbox-remote Reconfigure

It took me a while to find this command. I found it on the Arch Forum but I could not find it on the Fluxbox documentation.

32) I think that's it. That's the longest post I ever did, it took me around 4 nights (kinda) to get it done and I hope it helps someone. If you have any doubts about this "tutorial" (it's a lot of info!) you can drop a comment and I'll try to help.

In the end, here's my clean desktop :P


Arch is indeed fast. Not because it's actually faster than other distros, it's just because it runs what you tell it to run, no more, no less. Just so we can get a rough figure, on my post "Fluxbox: I liked it! :)" I wrote the RAM used just after logging in on Xubuntu and on my "Xubuntu turned Fluxbox" lappy. Just so you know, here are the number again:

Xubuntu (with compositing disabled) - 165.1 MB
"Xubuntu turned Fluxbox" - 95.8 MB
Archlinux with Fluxbox described above (and with preload running) - 69.3 MB

This old lappy is blazing fast again. :)

PS: I know that I said I was gonna try Slackware, and I was really gonna, but when I looked it up on the web, I found out that the Slackware team is already almost launching Slackware 14 (rememebr that was two-three weeks ago. Funny though, TODAY, Slackware 14 was released.

Wednesday, September 5, 2012

Arch update. (A.K.A Begone laziness!)

On july 20th, the Arch Linux developers announced that Grub legacy would not be supported anymore. On july 30th they announced that the default format of the main config file, /etc/rc.conf, has been changed. The reason of this change was to "unify the configuration of systemd and initscripts". Since I knew what initscripts were, I asked myself: wtf is systemd? A visit to the Arch wiki answered my question but I was too lazy to change anything. A few weeks passed and while I was watching a show I recently found out about, Linux Action Show, one of the news they were talking (season 23 episode 04) about was that Arch was probably gonna move to systemd. I went on the forums and there was a lot of talk about systemd. How fast it was, how many problems it was causing to some users, etc. I also read the arch-dev-public mailing list (this is the email that apparently started it all, the news that is) and well... I knew I had some work to do. I had to:

1) Ditch Grub legacy and install Grub2;
2) Update my rc.conf and create other needed files;
3) Switch to systemd.

As always, Arch wiki was a great source of information. Everything I needed was there. The switch from Grub legacy to Grub2 was very smooth (I even set a Arch wallpaper on the Grub screen). Updating my rc.conf (and creating the other files) was also smooth, just followed the wiki. I backed up all the files I had to alter but, like I said, these changes were very smooth and I ended up not using the back ups.

Now for systemd: followed the wiki and everything worked, except my samba server. But, 5 minutes later, using our good friend google, I found out that I needed to enable the nmbd daemon (the netbios name server). Easy enough: sudo systemctl enable nmbd.service. I had forgotten about it. A 5 minute fix, I'd also call this a smooth transition.

Arch Linux is a fantastic distro. Well documented and well "put-together". Not a single hitch in such a important upgrade.

One note on systemd: it is fast! My boot time got significantly faster. This is due to the fact that systemd knows which service (daemons) needs which service and starts what it can simultaneously.

And you fellow Archer, who's been lazy to adhere to the new configs Arch has been using, you should just get it over with. Took me around one afternoon to read and actually do all the stuff I described. And who knows when Arch will drop the support for the legacy rc.conf format and systemV initscripts?



Tuesday, September 4, 2012

Fluxbox: I liked it! :)

On my last post I said that I was gonna try Openbox and Fluxbox WMs. I'd install Fluxbox on my Xubuntu laptop (gotta keep it with Xubuntu so I can have a system like my wife's in case she needs it) and on my other laptop I'd install Archbang, a preconfigured Arch Linux that comes with Openbox as WM.

Firstly, I tried to install Archbang but I'd always get the same error (crazy dump code on the screen a few seconds after the system is fully loaded). I tried it using a CD (actually, two, since my first guess was that I had a bad burn) and then wrote the CD image to a USB stick (see this) and tried booting from it (using plop, see my sixth post) but got the same error. The weird part is that I tried both the CD and USB stick on my other laptop and both worked without a hitch, but didn't go through with the Archbang installation though. I have no idea what is the issue, so I gave up on the idea of installing Archbang... for now.

The other part of my plan was to install Fluxbox on my Xubuntu laptop, which was easy enough to do: sudo apt-get install fluxbox, on a xfce terminal. Before trying Fluxbox, I watched this video on youtube that shows the basic configuration of Fluxbox. If you've never used it and want to try, I recommend watching this video, it's very didactic. After watching the video I figured it was time to actually try Fluxbox. Rebooted, marked "Fluxbox" on the session field of LighDM and logged in.

I should have taken a screenshot of the desktop just after I logged in. I forgot and I only have a screenshot of my current desktop. What I will do is describe my impressions of Fluxbox and what I had to do to have the desktop you see below.

Current desktop.
Before I write down how I got to this desktop, I have to say my feelings about this WM: like the title of the post says, I liked it. I actually liked it enough to keep it as my main WM on this laptop for just two reasons: it's fast and functional. The first thing you notice after logging in is that Fluxbox is very responsive, menus pop up instantly and it loads really fast, unlike the stock Xubuntu. The amount of RAM it takes is very small, making more room for other programs to run. After booting and logging in, only 95.8 MB of RAM is used. In the case of the stock Xubuntu (and with compositing disabled!), 165.1 MB of RAM is taken just after logging in on this same laptop! And that's with compositing disabled! I also liked the fact that using Fluxbox will make you go to the terminal sometimes, which to me is actually a good thing. Also, we'll see below that the most part of the configuration is done on text files. That's why it's such a fast WM: it has a simple text-based configuration scheme. It's a functional WM because it's easely configured and completely configurable. It may take sometime to make it look and feel just  the way you like it, but once you get to that point it's a fantastic WM. I plan to install some major distro (probably Slackware, since I always wanted to try it) on my other laptop and use the same configuration files I made on this Fluxbox setup. To sum up, for me, Fluxbox is fast and functional, but if you don't like the CLI or making configs on text files (*ahem* Unity *ahem*), Fluxbox may not be for you.

Now then, I'm ready to describe my experience, step by step. The first time I logged in I got a black wallpaper with a Ubuntu logo and a grey bar on the lower side of the screen, which is the toolbar. Also, there were no icons on the desktop, and to get any icons on it, a separate program is needed: idesk. Didn't install it though, I don't need stinking icons on the desktop. :)  The usual way you interact with Fluxbox is by right-clicking on the desktop. By doing that, you'll get a menu with a lot of options, from Applications menu to Configurations menus that will help you customize your Fluxbox environment. Now, in the beginning of the "config process" it's worth noting a few menus: Configuration, that lets you set transparency, toolbar options, etc, Styles that lets you set a visual style for the menus and Workspaces which lets you set how many workspaces you want.

After logging in, I opened thunar, the XFCE file manager, and found out that no icons appeared. I mean, I saw the directories, but no icons appeared. A bit of googling around pointed me to a little program called lxappearance. The program is very straight forward and it lets you choose the icon theme, mouse icons, etc.

With thunar configured, it was time to set the wallpaper. Like the guy shows on the video: fbsetbg -a /path/to/picture.jpg &. This, in my case, did not make this setting persistent, that is, after rebooting, the wallpaper that was up was the Ubuntu default one. To solve this, I had to put this command on the ~/.fluxbox/startup file (more on this file below). The weird part is that I commented this line I had added on the startup file and set a new wallpaper using the same command but a different picture. It just worked, I got a persistent wallpaper.

Having set the wallpaper I figured it was time to customize my right-click menu, the most important menu of Fluxbox! I did just like the guy on the video: edited ~/.fluxbox/menu file and added what I needed. The syntax is very straight forward and easy to pick up. The most difficult part was to find the icons I wanted to place beside the menu entries. I just added the programs I use the most, one menu just for the main Fluxbox configuration files (menu, startup, keys, init), a reboot entry and a shutdown entry. Here's how my menu file turned out:

[begin] (Fluxbox!)
[exec] (LeafPad) {/usr/bin/leafpad} </usr/share/icons/hicolor/32x32/apps/leafpad.png>
[exec] (Thunar) {/usr/bin/thunar} </usr/share/icons/hicolor/48x48/apps/Thunar.png>
[exec] (Spyder) {/usr/bin/spyder} </usr/share/app-install/icons/spyder.png>
[exec] (Audacious) {/usr/bin/audacious} </usr/share/icons/hicolor/48x48/apps/audacious.png>
[exec] (SMPlayer) {/usr/bin/smplayer} </usr/share/icons/hicolor/32x32/apps/smplayer.png>
[exec] (Xfce Application Finder) {xfce4-appfinder} </usr/share/icons/hicolor/48x48/apps/xfce4-appfinder.png>
[exec] (Task Manager) {xfce4-taskmanager} </usr/share/app-install/icons/utilities-system-monitor.png>
[exec] (Xfce Terminal) {/usr/bin/xfce4-terminal} </usr/share/app-install/icons/terminal-tango.png>
[exec] (Chromium) {/usr/bin/chromium-browser} </usr/share/icons/hicolor/32x32/apps/chromium-browser.png>
[exec] (Lock Screen) {/usr/bin/xscreensaver-command -lock} </usr/share/icons/gnome/48x48/status/changes-prevent.png>
[exec] (LibreOffice) {/usr/bin/libreoffice} </usr/share/icons/hicolor/32x32/apps/libreoffice-main.png>
[exec] (Calculator) {/usr/bin/galculator} </usr/share/app-install/icons/accessories-calculator.png>
[separator]
[submenu] (Fluxbox Config!) {}
   [exec] (Menu) {/usr/bin/leafpad ~/.fluxbox/menu} <>
   [exec] (Keys) {/usr/bin/leafpad ~/.fluxbox/keys} <>
   [exec] (Startup) {/usr/bin/leafpad ~/.fluxbox/startup} <>
   [exec] (Init) {/usr/bin/leafpad ~/.fluxbox/init} <>
[end]
[separator]
[include] (/etc/X11/fluxbox/fluxbox-menu)
[separator]
[exec] (Reboot) {sudo reboot} <>
[exec] (Shutdown) {sudo shutdown -h now} <>
[end]

This menu looks like this:
My Fluxbox menu!

To get the last two commands working without supplying the password (which would be kinda boring having to supply my password every time I wanted to shutdown or reboot) I added the following lines to my sudoers file:

%sudo   ALL=(ALL:ALL) ALL
%sudo   ALL=NOPASSWD: /sbin/shutdown,/sbin/reboot

The first line says that members of the group sudo can supply admin commands using sudo (duh!) and the second line says that members of the group sudo do not need to supply a password to execute the commands reboot and shutdown.

The next file I attacked was the ~/.fluxbox/keys. This file sets the keyboard shortcuts. It's also a very important part of the Fluxbox experience. Relying only on the right-click menu to run programs is not practical sometimes. Again, customizing the keys file is easy enough. Below are the lines I added myself to the default keys file:

# Functionalities
Mod4 Right :NextWorkspace
Mod4 Left :PrevWorkspace
Control 1 :Workspace 1
Control 2 :Workspace 2
Mod4 d :ShowDesktop
Mod4 l :Exec xscreensaver-command -lock

# Apps
Mod4 w :Exec chromium-browser
Mod4 e :Exec thunar
Mod4 t :Exec xfce4-terminal
Mod4 r :Exec xfce4-appfinder
Mod4 c :ToggleCmd {Exec pkill conky} {Exec conky -c ~/.conkyrc}

Control means the Ctrl key, Mod1 means Alt and Mod4 means the "super" (a.k.a Windows) key. The commands above are self explanatory, maybe except for the last one, which I'll explain. I set up conky to be started upon startup (see below), so that command toggles conky on/off. This ToggleCmd command is simple and brilliant, it simply commutes between two states. There are other Fluxbox commands like MacroCmd that executes several commands at once (see here for more details). Also, ToggleCmd, MacroCmd and others can be combined. There are many customizing possibilities.

Next: the ~/.fluxbox/startup file. This script is read and executed by the program /usr/bin/startfluxbox (which is the program that starts the Fluxbox session). Here are the lines I added:

xscreensaver &
nm-applet &
volumeicon &
conky -c ~/.conkyrc &

This is the stuff I run at startup. The first and the last probably don't need any explanation (just so you know, I based my .conkyrc file on this). As for the two in the middle, when you first log into Fluxbox, there are no icons on the task bar. So I needed icons for NetworkManager (for wifi) and a volume icon to appear, and that's how it's done. Easy or what?

After I put those icons on my toolbar, they were not on the corner like I wanted them to be. That brings me to the last file I edited:  ~/.fluxbox/init. This file sets the overall "look" of Fluxbox, including the toolbar. I only edited the line that sets what the toolbar must contain. It ended up like this:

session.screen0.toolbar.tools: iconbar, clock, systemtray

That line says that, from left to right, the toolbar contains an area for the iconbar, where the running windows are displayed, the clock (which you can configure how you want it by right-clicking on it) and the systemtray that, in my case, shows the NetworkManager and the volume icons.

After all that, I managed to get my desktop the way I showed in the beginning of the post. :)

There are a lot of other stuff that I didn't have time to explore, such as the ~/.fluxbox/apps file and the slit (there's even more stuff, of course). But from what I have already seen, I really liked this WM. For those willing to try it, the Fluxbox Wiki is a great source of information.

I'll see if I can get Slackware running with Fluxbox on my other laptop. In the mean time, I'll install Openbox on this "Xubuntu turned Fluxbox" laptop. Let's see how that turns out.