Xmonad in LinuxMint 12 "Lisa"

There are rumors that Linux Mint is surpassing Ubuntu to become the most popular Linux distro around, that's why I had to take a look at LinuxMint 12 "Lisa" - the newest version of Linux Mint. And after few hours testing Linux Mint 12 I have to admit that Linux Mint is way better than Ubuntu. The default theme of Linux Mint is always beautiful and I really like Gnome3, more intuitive and easier to customize than Unity. And since I've fallen in love with xmonad, I decided to try xmonad in Linux Mint to get the best of the two worlds. And the result is really nice, here are some desktop screenshots of Linux Mint using xmonad as the window manager.

LinuxMint xmonad

LinuxMint xmonad

LinuxMint xmonad

LinuxMint xmonad

LinuxMint xmonad

As you can see in the images, when combining xmonad with Gnome3 of Linux Mint, you will have a Gnome3 desktop using xmonad as the window manager. The tiled windows fit really nice between the 2 panels and it's totally clickable when using xmonad with Gnome3. You can switch between workspaces in Xmonad either by using the keybindings or by clicking on the bottom panel. You also dont need to use dmenu or other launchers since you already have the Linux Mint menu on the top panel.

If you're using the new Linux Mint and want to try xmonad, here is how:

Step 1: Installing xmonad.

Just run
 sudo apt-get install xmonad  

Step 2: Creating the xmonad session.

First, you need to add the xmonad session to gnome session, the file you need to create is /usr/share/gnome-session/sessions/xmonad.session. Just open a terminal and run the following command:
 sudo gedit usr/share/gnome-session/sessions/xmonad.session  

After you enter the password, a gedit window will open, just copy-paste the following lines into it then save and quit:
 [GNOME Session]  
 Name=Xmonad Gnome  
 RequiredComponents=gnome-panel;gnome-settings-daemon;  
 RequiredProviders=windowmanager;  
 DefaultProvider-windowmanager=xmonad  

Next, you need to create an xmonad desktop file, the file would be /usr/share/xsessions/xmonad-gnome-session.desktop. Just do the same as the previous step, open a terminal and run this command:
 sudo gedit /usr/share/xsessions/xmonad-gnome-session.desktop  

After the gedit window appears, add the following lines into it then save and quit:
 [Desktop Entry]  
 Name=Xmonad GNOME  
 Comment=Tiling window manager  
 TryExec=/usr/bin/gnome-session  
 Exec=gnome-session --session=xmonad  
 Type=XSession  

Step 3: Configuring xmonad

This step is pretty easy, I've been writing in details about this in my tutorial about how to set up and configure xmonad in Arch Linux. I recommend you to read this article and the xmonad archives in the haskell homepage to know more about xmonad.

But if you only want to test, you just need to create the file ~/.xmonad/xmonad.hs. A simple xmonad.hs to use in Gnome3 would be like this:
 import XMonad  
 import XMonad.Config.Gnome  
   
 main = do  
    xmonad $ gnomeConfig     

The xmonad.hs I used to test Xmonad in my laptop with a frech keyboard is like this ( I also changed the mod key to the window key):
 import XMonad  
 import XMonad.Config.Gnome  
 import XMonad.Config.Azerty  
 import qualified Data.Map as M  
   
 main = do  
    xmonad $ gnomeConfig {  
         modMask = mod4Mask  
         , keys = \c -> azertyKeys c `M.union` keys gnomeConfig c   
         }  

After you save the xmonad.hs file, just open the terminal and run the following command:
 xmonad --recompile  

And everything is done, just log out and choose Xmonad Gnome as the login session and you can run Xmonad in Linux Mint like a cool Linux geek now.

How to install ATI driver in ArchBang

I got an email from a reader asking me about how to install the ATI driver in ArchBang Linux. Normally I would advice him to read the Arch Wiki but since the new update of ATI catalyst is quite troublesome, I decided to write this post instead. If you're inexperienced with Arch Linux, you may got a lot of troubles to install the new ATI catalyst inasmuch as it got compatibility problems with the Linux kernels and Xorg-server packages. Specifically, the new ATI driver (11.11) cannot work with the new xorg-server (1.11) when it can only work with the newest Linux kernel (3.1). All in all, if you got problems when installing the new ATI driver or feel overwhelmed by the article in the Arch Wiki, this blog post will be helpful for you.

Because the new ATI driver cannot work with xorg-server 1.11, when you update system you have to ignore the group xorg. The command to update system therefore must be:
 sudo pacman -Syu --ignoregroup xorg  

The other way to update system without touching the xorg-server package is to include the repository of xorg-server 1.10 into the pacman repositories. To do so, just open (as root) the file /etc/pacman.conf and add the following lines right above the other repositories (i.e core, extra, community):

 [xorg110]  
 Server = http://catalyst.apocalypsus.net/repo/xorg110/$arch  

Next, you must get the newest ATI driver (11.11), and since packer is preinstalled in ArchBang, you just need to run the following command:
 sudo packer -S catalyst-utils catalyst  

Note: if you just installed ArchBang, you will have to remove some redundant packages to install catalyst-utils. There would be a command prompt asking you to remove libgl, just feel free to enter "yes" . In ArchBang, there are some preinstalled packages that depend on libgl (like xf86-video-intel, xf86-video-mach64...) , you have to remove them as well. It is totally safe because these packages are just the drivers for the other GPU cards. The creator of ArchBang included them in order to make ArchBang work out of the box in every computer)

After installing the ATI driver catalyst, to make it work, you have to configure some files. The first thing is you have to create the file /etc/X11/xorg.conf. To do so, just run:
 sudo aticonfig --initial  

Next, you have to blacklist radeon (the opensource driver for ATI cards) in the file /etc/modprobe.d/modprobe.conf. Just open the file and add the following line into it. This file in ArchBang would look like the image below:

install ati driver in archbang linux


Next you have to add fglrx into the MODULES part of the file /etc/rc.conf. Just open (as root) the file and add fglrx into the MODULES part.

The last file you need to edit is /boot/grub/menu.lst. Just open the file and add nomodeset in the kernel line, it would look like that:
 kernel /vmlinuz-linux root=/dev/disk/by-uuid/1cd9c0ef-0ed5-4248-9f71-5e4a0547ddac loglevel=3 ro nomodeset quiet resume=/dev/disk/by-uuid/a4d53579-e8fe-41ce-9778-a72f5e98a2ec  

Now, everything is done, you just have to reboot and enjoy the new ATI driver. To check if the driver works properly, you need to install the package mesa-demos
 sudo pacman -S mesa-demos  

then run:
 glxinfo | grep direct  

If you have the output saying: direct rendering: Yes then everything is successfully done.

Tips to use Archbang

Two days ago, a friend of mine (who was an Ubuntu user) asked me to instruct him how to install and configure Arch Linux. But because I was too busy with Skyrim, I told him to get Archbang instead (since it is easier to install Archbang). After helping him install Archbang, I had to answer many questions from him. So I think many other people would have the same questions about Archbang Linux, that's why today I write this article about some tips to use Archbang.

I already wrote an article about 10 things to do after installing Archbang and here is 10 more things to do. But if you're still confused with Archbang, this article will provide some more tips to use Archbang Linux and make it better, more productive and more beautiful.

1. How to install Archbang
2. Install applications in Archbang
3. Change themes and icons in Archbang
4. Change the login screen of Archbang
5. Right click on the terminal in Archbang
6. Adjust screen brightness in Archbang
7. Use laptop function keys in Archbang
8. Disable the system info when you open a terminal
9. Create a launcher on tint2 panel
10. Imbed the terminal transparently into the wallpaper

1 - How to install Archbang



Step 1: download Archbang from the hompage
Step 2: Burn the ISO to a CD or make a bootable USB stick (recommended). Here is my guide to use UnetBootin to create a bootable USB, it works well in every OS.
Step 3: Install Archbang. Here is a thorough and simple guide with a lot of pictures about how to install Archbang. Since Archbang is very light weight, installing it will be very fast. It took my friend less than 15 minutes to install Archbang

2 - Install applications in Archbang


If the apps are in the Arch Linux repository, just run a command like this:
 sudo pacman -S firefox chromium pidgin vlc  

If the packages you want are not in the Arch Linux repository, there will probably be aur packages. You can install these aur packages manually or use packer since it is preinstalled in Archbang. To use packer, just run:
 sudo packer -S name-of-the-package  

For example, to install minitube:
 sudo packer -S minitube  

Note: To get more info about pacman and packer, please run man pacman and man packer.

3 - Change themes and icons in Archbang


You can change themes and icons just like how you do so in Ubuntu. Just download the theme and icon packages and extract them into /usr/share/themes and /usr/share/icons ( you can also create ~/.themes and ~/.icons to use locally). After move the theme and icon folders to the right places, hit Alt+F2 then type "lxappearance" to change themes and icons.

Note: you may find that the new theme doesnt apply to some applications, these applications are usually Qt based. Qt and GTK+ based programs both use a different widget toolkit to render the graphical user interface. Each come with different themes, styles and icon sets by default, among other things, so the look may differ significantly. To apply theme to these apps, you should install the qt package
 sudo pacman -S qt  

After that, hit Alt+F2 to run qtconfig, choose GTK+ in the GUI style. Save and close the window.
Next, open the start up file ~/.xinitrc and add the following line:
 export GTK2_RC_FILES="/home/username/.gtkrc-2.0"  

4 - Change the login screen of Archbang


The login manager of Archbang is slim, to get more themes for slim, just run
 sudo pacman -S slim-themes  

The themes folder is located as /usr/share/slim/themes. You can also create your own themes then add to this folder.

To edit and configure slim, just edit (as root) the file /etc/slim.conf

5 - Right click on the terminal in Archbang


Many visitors have visited my blog by searching for this so I think this should be a tip. I'm not familiar with urxvt so I guess we just cannot right click on urxvt. My solution is to install another terminal emulator, my favorite terminal emulator is Terminator
 sudo pacman -S terminator  

6 - Adjust screen brightness in Archbang


The hard way is to edit the file /sys/class/backlight/acpi_video0/brightness. You can use either a text editor or the echo command. For example:
 sudo echo 6 > /sys/class/backlight/acpi_video0/brightness  

An easier way to adjust screen brightness is to use the xbacklight command:

For example, to increase screen brightness:
 xbaclklight +20  

To decrease:
 xbaclklight -20  

For more info about xbacklight, please run man xbacklight

7 - Use laptop function keys in Archbang


To use the laptop function keys in Archbang, you just need to add the keybindings into the file ~/.config/openbox/rc.xml

The important part is to find the name of these function keys. To do so, you need the package xorg-xev
 sudo pacman -S xorg-xev  

Next, open a terminal and run the following command
  xev | grep -A2 --line-buffered '^KeyRelease' | sed -n '/keycode /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p'   

A white window with a black square inside will appear. To find the name of a key, just move the cursor to the white window then hit the key, you will have the output of the names of the keys you just hit.

An example of a new keybinding using a laptop function key would be like this:
 <keybind key="XF86MonBrightnessUp"">  
    <action name="Execute">  
     <command>xbacklight +20</command>  
     <startupnotify>  
      <enabled>yes</enabled>  
      <name>Increase screen brightness</name>  
     </startupnotify>  
    </action>  
   </keybind>  

8 - Disable the system info when you open a terminal


This system info is originally called archey, but in Archbang, it got modified into archbey. To disable it, just comment out the archbey line in ~/.bashrc

9 - Create a launcher on tint2 panel


Read this guide if you want a tint2 panel with a launcher like the image below:


10 - Imbed the terminal transparently into the wallpaper


Read this guide to get a desktop like this

How to fix the problem: Failed to mount partitions - authentication is required

After several days busy with Skyrim, today I ran a system update for my Arch Linux machine. However a problem occurred that didnt allow me to mount my partitions (except the home and file system partitions) when I logged in as a normal user. Here is the image of this problem.

failed to mount partitions - authentication required

If you find this page via google, I believe you are having this problem as well. To fix this, open your favorite file manager and find the file
 /usr/share/polkit-1/actions/org.freedesktop.udisks.policy  
Open it with a text editor then find these lines (start at line 22 in my case):
  <action id="org.freedesktop.udisks.filesystem-mount-system-internal">  
   <description>Mount a system-internal device</description>  
   <description xml:lang="da">Montér en intern enhed</description>  
   <message>Authentication is required to mount the device</message>  
   <message xml:lang="da">Autorisering er påkrævet for at montere et fil system</message>  
   <defaults>  
    <allow_any>no</allow_any>  
    <allow_inactive>no</allow_inactive>  
    <allow_active>yes</allow_active>  
   </defaults>  
  </action>  

Edit the part
  <allow_active>auth_admin_keep</allow_active>  
into
  <allow_active>yes</allow_active>  

Then save the file and you can mount the internal partitions as a normal user again every time you need.

How to edit link colors in GTK themes

After trying several new themes today, I found out that many  gtk theme makers usually forgot to edit the link colors in their dark themes and it can be very annoying. Here are the two examples of these themes when I use firefox, the first is silent night II, the second is diehard 4. As you can see in the images, the link color combination seems to want our eyes to bleed out.
linuxandlife.com edit link colors in gtk themes
silent night II dark theme
linuxandlife.com edit link colors in gtk themes
diehard 4 theme
Fortunately, fixing this problem is pretty easy. You need to go to the themes folder (either /usr/share/themes/ or ~/.themes) then open the gtkrc file (in the gtk-2.0 folder) with a text editor of the theme you want to use. Just add the following lines right after the part style "default"

  GtkWidget::link-color = "#569cc1" # choose the color that you prefer   
  GtkWidget::visited-link-color = "#f2f2f2"  # choose the color that you prefer

The file should look like this

linuxandlife.com edit link colors in gtk themes

 Here are how the link colors look in the two example themes after I editted the gtkrc file. I believe it looks really better.

silent night II theme
diehard 4 theme

How to check hardware specification in Linux

You may at times need to check hardware information of you computer for many reasons, such as to find a correct driver or to check everything when you want to buy a used computer. In Windows, the only tool I know is Speccy but in Linux, I'm quite familiar to some different tools. In this article, I will introduce the tools that are used with the command line only, so you wont find any tool with a graphic interface here. Also, I assume that these tools are not preinstalled in your distro by default (since I'm using Arch Linux) so just skip the installation part if you already have these tools in your system.

1 - check the /proc/ folder

The /proc/ folder has many useful files to check hardware info. The most popular files are /proc/cpuinfo (about processor info), /proc/meminfo (about RAM memory) and /proc/partitions (a full list about all disk partitions). To check these files, you can go directly to the folder and open these files with the default text editor. You can also run the "cat" command to display these files on the terminal. For example, you can run the following command to display processor info on the terminal
 cat /proc/cpuinfo  

2 - lshw

lshw is a small tool (just about 1MB) to extract detailed information on the hardware configuration of the machine. It can report exact memory configuration, firmware version, mainboard configuration, CPU version and speed, cache configuration, bus speed, etc. Last time I checked, lshw is preinstalled in Ubuntu by default so you can skip the installation part (but I'm not so sure about that). To install lshw in Ubuntu and other Debian based distros, run this command:
 sudo apt-get install lshw  

If you use Arch Linux, run the following command to install it.
 sudo pacman -S lshw  

If you want lshw to give a full list of hardware info in details, just run this command (the list is quite long so it may take a little time to scan and display the info )
 sudo lshw  

If you just need a short list about hardware, you can use the following command
 sudo lshw -short  

The image below is the hardware info of my laptop after I run the short lshw command:

 how to check hardware info

To find the info of one specific class with lshw, say the processor, you can run the following command
 sudo lshw -class processor  

linux commands to check hardware info

3 - hwinfo

Hwinfo is another useful tool to get hardware info. It is used to probe for the hardware present in the system and can be used to generate a system log. Hwinfo is my favorite tool so far – it gives more detaiks about the system hardware specification than lshw and the report is very well organized and easily accessible through command line switches.

To install hwinfo in Ubuntu and other Debian based distros, run this command:
 sudo apt-get install hwinfo  

If you use Arch Linux, use the following command:
 sudo pacman -S hwinfo  

The way you use hwinfo is quite analogous to that of lshw (however, you dont need to use the command as root for hwinfo). To get a complete report in details about all hardware components, serial number, model number, device class, descriptions, vendor, features ..., you can run this command:
 hwinfo  

If you just want the info about a particular class of hardware such as memory, processor or bios you can run a command like this:
 hwinfo --bios  

linux commands to get hardware info

4 - dmidecode

Dmidecode is a very small tool (only 0.05MB) used for displaying table contents of a computer's DMI in an easy-to-read format. This table contains a description of the system’s hardware components, as well as other useful pieces of information such as serial numbers and BIOS revision.

To install dmidecode in Ubuntu and other Debian based distros, run the following command:
 sudo apt-get install dmidecode  

To install dmidecode in Arch Linux, run the following command:
 sudo pacman -S dmidecode  

To use dmidecode, just like lshw, you need to run the command as root. To get a full report about hardware info, you can run the following command:
 sudo dmidecode  

To get details about particular hardware classes you can run the commands like the example below

linux tools to find hardware info

How to change text font and colors in Pidgin

Although dark gtk themes can be very nice-looking, they may at times give you problems with text colors and font in some applications. One of the applications that are most likely to have troubles when using dark themes is Pidgin. This post will show you a simple tip to adjust the text font and colors in Pidgin via just a few clicks.

First, when Pidgin is opening, hit Control + U to open the plugins settings windows. To change the color of the message text, find the "Conversation Colors" plugin, tick on it then click on the Configure Plugin button. A new window will appear and you can adjust the color options there.


customize color pidgin


To change the font and color of text in Pidgin, you need to configure another plugin -  Pidgin Gtk + Theme control. Just scroll down the plugins settings window, you will find this one. Tick it then hit the Configure Plugin button, a window will appear for you to edit the color and font.

change gtk theme pidgin

dark gtk theme problem pidgin

How to configure xmonad in Arch Linux

As you may already know from my previous post, I've switched to xmonad after more than a year using Openbox. And since I got many compliments and questions for my xmonad config, I think everyone will be interested in a guide about how to set up and configure xmonad.

This guide, in fact, is based on John Goerzen's tutorial about how to set up and configure xmonad with xmobar. However, I think John's config is not very good-looking and quite outdated so you will see many new additional stuffs in my guide. I created my xmonad config with the aim of creating a simple and clean desktop with a status bar that has all the system infomation that I care about so xmobar and trayer are my chosen apps. Also, my laptop has a French keyboard layout so I will show you how to set up xmonad for this keyboard layout and how to incorporate special laptop keys into your xmonad keybindings.

Here is my full xmonad.hs file and the images below are the screenshots of my desktop in clean and busy (pretending) modes:

xmonad tutorial
my xmonad desktop in clean mode
xmonad how to
my xmonad desktop when busy


Table of contents

1. Installing and starting xmonad
2. The basic configurations
3. Setting the layout and workspaces
4. Keybindings
        4.a - Adding and removing key combinations
        4.b - Using laptop function keys in xmonad
5. Creating a status bar with xmobar and trayer


1 - Installing and starting Xmonad


This guide will work for every distro, but because I'm using Arch Linux, I will use Arch commands to install xmonad. The packages I'm using are xmonad, xmonad-contrib, xmobar and trayer.

To install them in Arch Linux, run this command:
sudo pacman -S xmonad xmonad-contrib xmobar trayer
To start xmonad automatically, simply add the command exec xmonad to your startup script ( ~/.xinitrc). To set a cursor for the xmonad desktop, add the following command
xsetroot -cursor_name left_ptr
If you are using a keyboard that doesnt have the default us layout, you also need to make xmonad recognize the keyboard. To do so, for example, with my French layout keyboard, I add this command:
setxkbmap -layout fr
My initial ~/.xinitrc file therefore looks like this
 # set cursor  
 xsetroot -cursor_name left_ptr  
 # French keyboard layout  
 setxkbmap -layout fr  
 # start xmonad  
 exec ck-launch-session xmonad  
After editing the startup script, you should check if you already have a ~/.xmonad folder. If you dont, just create it:
mkdir ~/.xmonad
Next, you need to create a config file for xmonad ( the xmonad.hs file). I will show you how to do so from scratch in the next parts of this guide but the easiest way is to copy the sample xmonad.hs to your ~/.xmonad folder. The sample xmonad.hs is located in /usr/share/your-xmonad-version/man/. For example, my xmonad version is xmonad-0.9.2 so my sample xmonad.hs will be /usr/share/xmonad-0.9.2/man/xmonad.hs. You can either use a text editor to copy-paste the file to your ~/.xmonad/xmonad.hs file or run this command:
sudo cp /usr/share/xmonad-0.9.2/xmonad.hs ~/.xmonad/xmonad.hs  
After that you can log out and log in again to use xmonad. You will see nothing but a blank screen at first but dont be panic, just hit Alt+p (Alt is the default modkey) to open the dmenu launcher and you can run applications from it. To know the default keybindings of xmonad, you can read about them in the sample xmonad.hs in /usr/share/xmonad/man/xmonad.hs.

You can actually use xmonad trouble-free with the default settings but if you want to customize your own xmonad.hs file, the following parts of this guide will show you how.

2 - The basic configurations


A working xmonad.hs could be very simple like this:
import XMonad  
main = do  
       xmonad $ defaultConfig  
If you want to incorperate xmonad with other desktop enviroment (DE) like Gnome or KDE (in other words you’ll still be running your DE but the window manager is replaced with XMonad) you have to import the modules for each DE. For example, if you want to use xmonad with Gnome, the xmonad.hs file will look like this:
import XMonad  
import XMonad.Config.Gnome  
main = do  
       xmonad $ gnomeConfig  
If you are using a french layout keyboard, you will have trouble with the workspaces in xmonad (if you have used awesome - another tiling window manager- you wont face this problem since awesome automatically recognizes the keyboard layout). To fix that problem, you need to import the XMonad.Config.Azerty, my xmonad.hs for a french layout will look like this:
import XMonad  
import XMonad.Config.Azerty  
main = do  
       xmonad $ azertyConfig  
To change the modkey (the default is the Alt key) to the window key, you add the line "modMask = mod4Mask". The xmonad.hs will be like this
import XMonad  
  
main = do  
       xmonad $ defaultConfig  
       {modMask = mod4Mask  
       }  
After saving the file, you can save the file, hit Alt+ q to recomplie and restart xmonad to change the settings. However, I recommend you to use the terminal to run "xmonad --recompile" then "xmonad --restart" to see if you got any error in the xmonad.hs.

That's the basic things you need to create a xmonad.hs file. With this minimal file, you still can use all the default settings of xmonads. The following part is about how to change the workspaces settings and customize the layout for eyecandy purpose.

3 - Setting the layout and workspaces


To change the color and width of the border, you can do like this:
 import XMonad  
   
 main = do  
      xmonad $ defaultConfig  
      {borderWidth = 2  
      ,normalBorderColor = "#abc123"  
      ,focusedBorderColor = "#456def"  
      }  
The default layout of xmonad is defined in the following lines:
 myLayout = tiled ||| Mirror tiled ||| Full  
 where  
      -- default tiling algorithm partitions the screen into two panes  
      tiled = Tall nmaster delta ratio  
   
      -- The default number of windows in the master pane  
      nmaster = 1  
   
      -- Default proportion of screen occupied by master pane  
      ratio = 1/2  
   
      -- Percent of screen to increment by when resizing panes  
      delta = 3/100  
To change the default layout, edit these lines then add them to the xmonad.hs file like this:
 import XMonad  
   
 myLayout = tiled ||| Mirror tiled ||| Full  
 where  
      -- default tiling algorithm partitions the screen into two panes  
      tiled = Tall nmaster delta ratio  
   
      -- The default number of windows in the master pane  
      nmaster = 1  
   
      -- Default proportion of screen occupied by master pane  
      ratio = 2/3  
   
      -- Percent of screen to increment by when resizing panes  
      delta = 5/100  
   
 main = do  
      xmonad $ defaultConfig  
      {layoutHook = myLayout  
      }  
To add some space between windows, you need to import the XMonad.Layout.Spacing module and edit your layout settings. For example, to have a space of 5 pixels between windows, my xmonad.hs will look like that:
 import XMonad  
 import XMonad.Layout.Spacing  
   
 myLayout = tiled ||| Mirror tiled ||| Full  
 where  
      -- default tiling algorithm partitions the screen into two panes  
      tiled = spacing 5 $ Tall nmaster delta ratio  
   
      -- The default number of windows in the master pane  
      nmaster = 1  
   
      -- Default proportion of screen occupied by master pane  
      ratio = 2/3  
   
      -- Percent of screen to increment by when resizing panes  
      delta = 5/100  
   
 main = do  
 xmonad $ defaultConfig  
      {layoutHook = myLayout  
      }  
To define the names and the amount of your workspaces (they will appear on the statusbar later on), you can do like this
 import XMonad  
   
 -- Define amount and names of workspaces  
 myWorkspaces = ["1:main","2:chat","3","whatever","5:media","6","7","8:web"]  
   
 main = do  
      xmonad $ defaultConfig   
      {workspaces = myWorkspaces  
      }  
You may also dont want to display the border of windows on some workspaces, to do so you need to import the XMonad.Layout.NoBorders and XMonad.Layout.PerWorkspace modules then change the layout settings like this:
 import XMonad  
 import XMonad.Layout.NoBorders  
 import XMonad.Layout.PerWorkspace  
   
 defaultLayouts = tiled ||| Mirror tiled ||| Full  
 where  
      -- default tiling algorithm partitions the screen into two panes  
      tiled = Tall nmaster delta ratio  
   
      -- The default number of windows in the master pane  
      nmaster = 1  
   
      -- Default proportion of screen occupied by master pane  
      ratio = 2/3  
   
      -- Percent of screen to increment by when resizing panes  
      delta = 3/100  
   
 -- Define layout for specific workspaces  
 nobordersLayout = noBorders $ Full  
   
 -- Put all layouts together  
 myLayout = onWorkspace "2:chat" nobordersLayout $ defaultLayouts  
   
 myWorkspaces = ["1:main","2:chat","3","4","5:media","6","7","8:web"]  
   
 main = do  
      xmonad $ defaultConfig  
      {workspaces = myWorkspaces  
      , lauoutHook = myLayout  
      }  
After defining the workspaces, you also want to attach some applications for specific workspaces. That means when you open an app, xmonad will automatically move it to a defined workspace. You can do like this:
 import XMonad  
   
 myWorkspaces = ["1:main","2:chat","3","whatever","5:media","6","7","8:web"]  
 myManageHook = composeAll  
      [ className =? "Iron" --> doShift "8:web"  
      , className =? "Xchat" --> doShift "2:chat"  
      ]  
   
 main = do  
      xmonad $ defaultConfig  
      { workspaces = myWorkspaces  
      , manageHook = myManageHook <+> manageHook defaultConfig  
      }  
If you dont want xmonad to tile some applications, you can do add the following lines to the myManageHook like this:
 myManageHook = composeAll  
      [ className =? "Gimp" --> doFloat  
      , className =? "Gnome-player" --> doFloat  
      ]  
Note: to know the className of an app, you can run the command "xprop" on the terminal, the cursor will change to the crosshair shape then use this crosshair to click on the app. The className of this app will appear on the terminal afterward.


4 - Keybindings in Xmonad


Because with a tiling window manager, you have to use the keyboard a lot so the next important thing you need to know is about the keybindings. You can find the default keybindings in the /usr/share/xmonad/man/xmonad.hs file. However, you may find these key combinations not very intuitive and redundant at times, that's why you need to set your own keybindings and remove the unnecessary keys.

4.a - Adding and removing key combinations

As far as I know, there are two ways to add new keys and remove unused keys in xmonad.

The first way is to use the XMonad.Util.EZConfig module. The format to define a key combination is:
((modkey, key), action)
Here is an example of xmonad.hs with some new keycombinations:
 import XMonad  
 import XMonad.Util.EZConfig  
   
 main = do  
      xmonad $ defaultConfig  
      {modMask = mod4Mask -- use the window key as the modkey  
      }`additionalKeys`  
      [(( mod4Mask, xK_f), spawn "firefox") -- to open firefox  
      ,(( mod4Mask .|. shiftMask, xK_F4), spawn "sudo shutdown -h now") -- window key + Shift + F4 to shutdown system  
      , (( mod4Mask, xK_F4), kill) -- to kill applications  
      ,(( controlMask, xK_KP_Add), sendMessage Expand) -- Ctrl + the plus (+) button to expand the master pane  
      , ((0, xK_Print), spawn "scrot") -- use the print key to capture screenshot with scrot  
      ,((mod4Mask, xk_y), spawn "home/user/scripts/somescript.sh" ) -- use mod4Mask + y to run a script  
      ]  
To remove existing key combinations with the EZConfig module, you just need to return the action of the keybindings to null. For example,if you already use mod4Mask+F4 to kill apps, you dont need the modMask+Shift+C anymore. To remove this keybinding, you add the following line to the additionalKeys array:
 ((mod4Mask .|. shiftMask , xK_c), return ()) -- return() means to do nothing  
The other way to add and remove key combinations is to define your own keys. To do so you need to include the module Data.Map. Here is an example of xmonad.hs using this method to add and remove keybindings:
 import XMonad  
 import qualified Data.Map as M  
   
 keysToAdd x = [((mod4Mask, xK_F4), kill)]  
   
 keysToDel x = [((mod4Mask .|. shiftMask), xK_c)]  
   
 newKeys x = M.union (keys defaultConfig x) (M.fromList (keysToAdd x)) -- to include new keys to existing keys  
   
 myKeys x = foldr M.delete (newKeys x) (keysToDel x) -- to delete the unused keys  
   
 main = do  
 xmonad $ defaultConfig  
      { modMask = mod4Mask  
      , keys = myKeys  
      }  
Both methods work well so it's up to you to choose your style.

Note:

It seems the default dmenu doenst have the command prompt anymore. To fix that and get some embellishments for the dmenu, you need to define a keybinding like this: (to know more options for dmenu, please run "man dmenu" in the terminal)
 ((mod4Mask, xK_p), spawn "exe=`dmenu_run -b -nb black -nf yellow -sf yellow` && eval \"exec $exe\"")   
You also need to include additional modules to execute some actions. For example, you have to import the module "qualified XMonad.StackSet as W" to define a new key combination to swap up and down the focused windows with the following keybindings:

 ((mod4Mask , xK_Up), W.swapUp)  

4.b - Including laptop function keys into keybindings

To find the names of every keyboard button you can use the program "xev". This is also helpful if you want to include the laptop function keys to your keybindings.

First, you need to install the package xorg-xev, if you're using Arch Linux, just run:
 sudo pacman -S xorg-xev  
Next, open the terminal and run the following command:
 xev | grep -A2 --line-buffered '^KeyRelease' | sed -n '/keycode /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p'  
A white window with a black square inside will appear. To find the name of a key, just move the cursor to the white window then hit the key, you will have the output of the names of the keys you just hit. An output example will be like this:

10 ampersand
24 a
127 Pause
133 Super_L
133 Super_L
213 XF86Suspend
233 XF86MonBrightnessUp
86 KP_Add
82 KP_Subtract
111 Up
84 KP_Begin
85 KP_Right
77 Num_Lock
89 KP_3
As you can see in the example above, I hit two of my laptop fucntion keys ( the suspend and increase brightness buttons). The names of these keys are XF86Suspend and XF86MonBrightnessUp. To include these buttons into your keybindings, you need to import the Graphics.X11.ExtraTypes.XF86 module. For example, in the xmonad.hs below, I use the  MonBrightnessUp button to increase the brightness of the laptop screen:
 import XMonad  
 import Graphics.X11.ExtraTypes.XF86  
 import XMonad.Util.EZConfig  
   
 main = do  
      { modMask = mod4Mask  
      }`additionalKeys`  
      [((mod4Mask, xF86XK_MonBrightnessUp), spawn "xbacklight +20")  
      ]  

5 - Creating a status bar with xmobar and trayer


Unlike awesome, xmonad doesnt come with status bar by default. To have a status bar in xmonad, the most popular choices are dzen2 and xmobar. I myself use xmobar and trayer as the status bar with a notification area and here I will show you how to set up and configure xmobar and trayer.

To install xmobar and trayer in Arch Linux, run
 sudo pacman -S xmobar trayer  
You can run xmobar from the startup script (~/.xinitrc) as well but I prefer launching xmobar from xmonad itself. A sample of xmonad.hs that uses xmobar will be like this:
 import XMonad  
 import XMonad.Hooks.DynamicLog  
 import XMonad.Hooks.ManageDocks  
 import XMonad.Util.Run  
 import System.IO  
   
 main = do  
 xmproc <- spawnPipe "/usr/bin/xmobar /path/to/your/config-file"   
 xmonad $ defaultConfig   
      { manageHook = manageDocks <+> manageHook defaultConfig  
      , layoutHook = avoidStruts $ layoutHook defaultConfig  
      , logHook = dynamicLogWithPP xmobarPP  
           { ppOutput = hPutStrLn xmproc  
           , ppTitle = xmobarColor "blue" "" . shorten 50   
           , ppLayout = const "" -- to disable the layout info on xmobar  
           }   
      }  
In the example above, to run xmobar with xmonad, you need to import some modules, DynamicLog and System.IO are to output status information to xmobar, ManageDocks is to make xmonad spare a space for the status bar and XMonad.Util.Run is for the spawnPipe command to launch xmobar. The line right after the main = do is to launch xmobar with the xmobarrc config file ( I will show you how to create one in the next part). I choose blue as the color of the info on xmobar and the info will be shortened to 50 characters. I also add the line ppLayout = const"" to disable the layout info.

The next thing you need to know is how to create a xmobarrc file. The Arch Wiki has a very nice and concise article about xmobar so I wont cover much about it. Here is my xmobar config file
 Config { font = "xft:Bitstream Vera Sans Mono:size=9:bold:antialias=true"  
     , bgColor = "#000000"  
     , fgColor = "grey"  
     , position = Static { xpos = 0 , ypos = 0, width = 1290, height = 16 }  
     , commands = [ Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10  
             , Run Network "eth0" ["-L","0","-H","70","--normal","green","--high","red"] 10   
             , Run Memory ["-t","Mem: <usedratio>%"] 10  
             , Run Com "/home/lulz/scripts/cputemp.sh" [] "cpuTemp" 10  
           , Run Date "%a %b %_d %l:%M" "date" 10  
             , Run Com "/home/lulz/scripts/volume.sh" [] "volume" 10  
           , Run StdinReader  
           ]  
     , sepChar = "%"  
     , alignSep = "}{"  
     , template = " %StdinReader%}{ <fc=grey>%cpu% </fc> <fc=red>%cpuTemp%</fc>°C<fc=grey> ~ %memory% ~ %eth0%</fc> ~ <fc=#ee9a00>%date%</fc> ~ Vol: <fc=green>%volume%</fc> "  
     }  
   
Note: Due to some unknown bugs, I couldn't get the default cputemp and volume of xmobar to work so I had to use my own scripts to display these info. Here are my scripts to display cpu temperature and volume.

Setting the trayer is easy. You just need to copy paste this line into the startup script (~/.xinitrc) and put it on the part to launch xmonad. The settings are pretty self-explained:
 trayer --edge top --align right --SetDockType true --SetPartialStrut true --expand true --width 6 --transparent true --alpha 0 --tint 0x000000 --height 16 &