Xmonad is a tiling window manager written and configured in Haskell.
I got a new laptop and decided to use Xmonad without Gnome or any other desktop manager.
As said >>here<<: "The advantages of using xmonad in Ubuntu without a full DE are speed and reduced memory use."
It's not only the overall performance that will be better, but also your working speed once you got used to navigating the tiling windows. I tried xmonad the first time on Arch and I never want back to non-tiling windows since then.
You will need your mouse much less than before and you will get the most out of your screen as it isn't filled with unnecessary stuff, unless you want to.
You can use the following description to set up your own Xmonad or just to see what is possible.
Look at the end of my post for links to some other guides, i.e. using Xmonad in Gnome.
This is my current setup (screenshot):
For this you need to install:
xmonad
trayer
xmobar
gtk-theme-switch
xcompmgr
hsetroot
rxvt-unicode
suckless-tools (contains dmenu)
The configuration file for Xmonad is ~/.xmonad/xmonad.hs
Create this file. It looks like this for me:
import System.IO
import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.FadeInactive
import XMonad.Hooks.SetWMName
import XMonad.Util.Run (spawnPipe)
import XMonad.Util.EZConfig (additionalKeys)
import XMonad.Actions.GridSelect
import XMonad.Layout.Fullscreen
import XMonad.Layout.NoBorders (smartBorders)
myNormalBorderColor = "#cccccc"
myFocusedBorderColor = "#0000ff"
myManageHook = composeAll
[ (className =? "Firefox" <&&> resource =? "Dialog") --> doFloat
, className =? "Thunderbird" --> doShift "mail"
, className =? "Firefox" --> doShift "web"
, manageDocks
]
myLayout = Mirror tiled ||| 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 = 3/4
-- Percent of screen to increment by when resizing panes
delta = 3/100
--fades inactive windows, but is a bit distracting
--myLogHook :: X ()
--myLogHook = fadeInactiveLogHook fadeAmount
-- where fadeAmount = 0.8
main = do
xmproc <- spawnPipe "xmobar ~/.xmobarrctop"
xmbottom <- spawnPipe "xmobar ~/.xmobarrcbottom"
xmonad $ defaultConfig
{ manageHook = fullscreenManageHook <+> myManageHook <+> manageHook defaultConfig
, handleEventHook = fullscreenEventHook
-- add --depth 32 for transparency, you need xcompmgr for shadows and transparency effects
, terminal = "urxvt -bg rgba:0000/0000/0000/eeee -fg rgba:cc00/cc00/cc00/ffff +vb +sb"
-- spawn programs you want at startup
, startupHook = do
spawn "thunderbird"
spawn "firefox"
-- set your layout, smartborders removes window borders if not necessary
, layoutHook = fullscreenFull $ avoidStruts $ smartBorders myLayout
-- names and sequence of your workspaces
, workspaces = ["web", "shell", "mail", "coding", "irc"] ++ map show [6..9]
-- sets the windows key as mod key
, modMask = mod4Mask
-- pipe title information into top bar of xmobar
, logHook = dynamicLogWithPP xmobarPP
{ ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor "green" "" . shorten 50
}
-- set your border colors
, normalBorderColor = myNormalBorderColor
, focusedBorderColor = myFocusedBorderColor
}`additionalKeys`
[ -- use Ctrl + Alt + L to lock the screen
((mod1Mask .|. controlMask, xK_l), spawn "gnome-screensaver-command --lock")
-- use Ctrl + Print to make a delayed screenshot
, ((controlMask, xK_Print), spawn "sleep 0.2; scrot -s")
-- use Print to make a screenshot
, ((0, xK_Print), spawn "scrot")
-- Mod + g for gridselection for your workspaces
, ((mod4Mask, xK_g), goToSelected defaultGSConfig)
]
Make sure that the file compiles by typing on the command line:
ghc --make xmonad.hs
or
xmonad --recompile
Set up a custom xsession by creating a file in /usr/share/xsessions/custom.desktop that looks i.e. like this (Name can be whatever you like):
[Desktop Entry]
Name=MyCustomXsession
Exec=/etc/X11/Xsession
Edit or create your .xinitrc with the following contents, edit the path to the wallpaper you wish to have:
#!/bin/bash
#set trayer for applet icons
trayer --edge top --align right --SetDockType true --SetPartialStrut true \
--expand true --width 5 --transparent true --alpha 0 --tint 0x000000 --height 16 &
#start network-manager applet
nm-applet --sm-disable &
#show wallpaper
hsetroot -full ~/pathtowallpaper.jpg
#start composite manager
xcompmgr -C &
#start xmonad
exec xmonad
xmobar is a minimalistic text based status bar that works well with xmonad and is also written in Haskell.
Set up the config files for the bars on top and bottom.
top (.xmobarrctop):
Config { font = "-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*"
, bgColor = "black"
, fgColor = "grey"
, position = TopSize L 95 16
, lowerOnStart = True
, commands = [ Run Network "wlan0" ["-L","0","-H","300","--normal","green","--high","red"] 10
, Run Network "eth0" ["-L","0","-H","300","--normal","green","--high","red"] 10
, Run Memory ["-t","Mem: <usedratio>% (Cache: <cache>M)", "-L","3","-H","50","--normal","green","--high","red"] 10
, Run Swap [] 10
, Run StdinReader
, Run DiskU [("/", "DISK space: <used>/<size>")] ["-L", "20", "-H", "50", "-m", "1", "-p", "3"] 20
, Run DiskIO [("/", "read: <read> write: <write>")]
["-L","0","-H","5000","--normal","green","--high","red"] 10
]
, sepChar = "%"
, alignSep = "}{"
, template = "%memory% %swap% %disku% %diskio% } %StdinReader% { %wlan0%"
}
bottom (.xmobarrcbottom):
Config { font = "-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*"
, bgColor = "black"
, fgColor = "grey"
, position = Bottom
, lowerOnStart = True
, commands = [ Run Weather "EDDP" ["-t","<station>: <tempC> C","-L","10","-H","25","--normal","green","--high","red","--low","lightblue"] 36000
, Run MultiCpu ["-t", "CPU: <autobar>" , "-L","3","-H","50","--normal","green","--high","red", "-b", ":", "-f", ":"] 10
, Run StdinReader
, Run Com "uname" ["-s","-r"] "" 36000
, Run Date "%a %b %_d %Y %H:%M:%S" "date" 10
]
, sepChar = "%"
, alignSep = "}{"
, template = "%multicpu% } %uname% { %EDDP% | <fc=#ee9a00>%date%</fc>"
}
Now log out of your current session and log in into your custom xsession (switch the session by clicking on the icon in the default Ubuntu login screen).
Last but not least use the gtk-theme-switch2 command to set up a theme you like.
The tool lxappearance may work too, but it didn't for me.
For more information see the links below.
xmobar:http://projects.haskell.org/xmobar/xmonad:http://xmonad.org/xmonad in ubuntu:http://www.haskell.org/haskellwiki/Xmonad/Using_xmonad_in_Ubuntuxmonad and gnome:
http://www.haskell.org/haskellwiki/Xmonad/Using_xmonad_in_Gnomecustom xsession:https://wiki.ubuntu.com/CustomXSessionurxvt configuration:https://wiki.archlinux.org/index.php/Rxvt-unicode