xmonad
Contents
- tiling Window-Manager written in Haskell
- minimal, stable, fast, light-weight
- maximizing desktop space
Install
1 aptitude install xmonad rxvt-unicode xmobar suckless-tools gmrun dzen2 gnome-session-flashback xloadimage feh
Start into Darkness
- xmonad is minimal and comes with nothing than defaults. That's great - so far.
To get started just press mod-Shift-Enter to launch a terminal.
You can Close/kill the focused window by pressing mod-Shift-c
- If no terminal shows up, check if you got the specified terminal installed.
Default Key-Bindings
The default modifier key is 'alt'. Default keybindings: -- launching and killing programs mod-Shift-Enter Launch xterminal mod-p Launch dmenu mod-Shift-p Launch gmrun mod-Shift-c Close/kill the focused window mod-Space Rotate through the available layout algorithms mod-Shift-Space Reset the layouts on the current workSpace to default mod-n Resize/refresh viewed windows to the correct size -- move focus up or down the window stack mod-Tab Move focus to the next window mod-Shift-Tab Move focus to the previous window mod-j Move focus to the next window mod-k Move focus to the previous window mod-m Move focus to the master window -- modifying the window order mod-Return Swap the focused window and the master window mod-Shift-j Swap the focused window with the next window mod-Shift-k Swap the focused window with the previous window -- resizing the master/slave ratio mod-h Shrink the master area mod-l Expand the master area -- floating layer support mod-t Push window back into tiling; unfloat and re-tile it -- increase or decrease number of windows in the master area mod-comma (mod-,) Increment the number of windows in the master area mod-period (mod-.) Deincrement the number of windows in the master area -- quit, or restart mod-Shift-q Quit xmonad mod-q Restart xmonad mod-[1..9] Switch to workSpace N -- Workspaces & screens mod-Shift-[1..9] Move client to workspace N mod-{w,e,r} Switch to physical/Xinerama screens 1, 2, or 3 mod-Shift-{w,e,r} Move client to screen 1, 2, or 3 -- Mouse bindings: default actions bound to mouse events mod-button1 Set the window to floating mode and move by dragging mod-button2 Raise the window to the top of the stack mod-button3 Set the window to floating mode and resize by dragging
Configuration
- To make your changes take effect press
-- quit, or restart mod-Shift-q Quit xmonad mod-q Restart xmonad
~/.xmonad/xmonad-session-rc
1 ### XMONAD SESSION RC
2
3 #xsetroot -xcf /usr/share/icons/Adwaita/cursors/left_ptr 16 -solid black
4 xloadimage -onroot -fullscreen /media/btrfs_space/btrfs_restore/home/phoenix/Bilder/waves_sunset-1920x1200.jpg
5 #feh --bg-scale /media/btrfs_space/btrfs_restore/home/phoenix/Bilder/waves_sunset-1920x1200.jpg &
6 xscreensaver -nosplash &
7 $(gnome-keyring-daemon --start --daemonize)
8 setxkbmap de nodeadkeys
9 xmodmap ~/.Xmodmap
~/.xmobarrc
1 Config { font = "xft:inconsolata:size=10:antialias=true"
2 , bgColor = "#002b36"
3 , fgColor = "#657b83"
4 , position = Top
5 , lowerOnStart = True
6 , commands = [ Run Network "wlan0" ["-L","0","-H","32","--normal","green","--high","red"] 10
7 , Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10
8 , Run Memory ["-t","Mem: <usedratio>%"] 10
9 , Run Date "<fc=#93a1a1>%a %b %_d %Y %H:%M</fc>" "date" 10
10 , Run DiskIO [("/", "IO: <total>"), ("sda4", "<total>")] [] 10
11 --, Run Com "ruby" ["/path/to/gmail_checker.rb"] "gmail" 3000
12 , Run StdinReader
13 ]
14 , sepChar = "%"
15 , alignSep = "}{"
16 --, template = "%StdinReader% }{ <fc=#93a1a1>%gmail%</fc> %cpu% %memory% %wlan0% %diskio% %date%"
17 , template = "%StdinReader% }{ %cpu% %memory% %wlan0% %diskio% %date%"}
~/.xmonad/xmonad.hs
1 -------------------------------------------------------------------------------
2 -- xmonad.hs for xmonad-darcs
3 -------------------------------------------------------------------------------
4 -- Compiler flags --
5 {-# LANGUAGE NoMonomorphismRestriction #-}
6
7 -- Imports --
8 -- stuff
9 import XMonad
10 import qualified XMonad.StackSet as W
11 import qualified Data.Map as M
12 import System.Exit
13 import XMonad.Util.Run (safeSpawn)
14 import Graphics.X11.ExtraTypes.XF86
15
16 -- actions
17 import XMonad.Actions.GridSelect
18 import XMonad.Actions.CycleWS
19
20 -- hooks
21 import XMonad.Hooks.DynamicLog
22 import XMonad.Hooks.ManageHelpers
23 import XMonad.Hooks.UrgencyHook
24 import XMonad.Hooks.InsertPosition
25 import XMonad.Hooks.EwmhDesktops
26 import XMonad.Hooks.ICCCMFocus
27
28 -- layouts
29 import XMonad.Layout.NoBorders
30 import XMonad.Layout.ResizableTile
31 import XMonad.Layout.Renamed
32 import XMonad.Layout.Tabbed
33
34 -------------------------------------------------------------------------------
35 -- Main --
36 main :: IO ()
37 main = xmonad =<< statusBar cmd pp kb conf
38 where
39 uhook = withUrgencyHookC NoUrgencyHook urgentConfig
40 --cmd = ""
41 cmd = "bash -c \"tee >(xmobar -x0) | xmobar -x1 | xmobar -x2\""
42 pp = customPP
43 kb = toggleStrutsKey
44 conf = uhook myConfig
45
46 -------------------------------------------------------------------------------
47 -- Configs --
48 myConfig = defaultConfig { workspaces = workspaces'
49 --, modMask = modMask'
50 , borderWidth = borderWidth'
51 , normalBorderColor = normalBorderColor'
52 , focusedBorderColor = focusedBorderColor'
53 , terminal = terminal'
54 -- , keys = keys'
55 -- , mouseBindings = mouseBindings'
56 -- , layoutHook = layoutHook'
57 , manageHook = manageHook'
58 -- , handleEventHook = fullscreenEventHook
59 -- , logHook = takeTopFocus
60 }
61
62 -------------------------------------------------------------------------------
63 -- Window Management --
64 manageHook' = composeAll [ isFullscreen --> doFullFloat
65 , className =? "MPlayer" --> doFloat
66 , className =? "Gimp" --> doFloat
67 , className =? "Vlc" --> doFloat
68 , className =? "feh" --> doFloat
69 , insertPosition Below Newer
70 , transience'
71 ]
72
73
74 -------------------------------------------------------------------------------
75 -- Looks --
76 -- bar
77 customPP = defaultPP { ppCurrent = xmobarColor "#B8860B" "" . wrap "<" ">"
78 , ppHidden = xmobarColor "#FAFFFF" ""
79 , ppHiddenNoWindows = xmobarColor "#FAFFFF" ""
80 , ppUrgent = xmobarColor "#FFFFAF" "" . wrap "[" "]"
81 , ppLayout = xmobarColor "#aaaaaa" ""
82 , ppTitle = xmobarColor "#aaaaaa" "" . shorten 80
83 , ppSep = xmobarColor "#aaaaaa" "" " | "
84 }
85 -- GridSelect
86 myGSConfig = defaultGSConfig { gs_cellwidth = 160 }
87
88 -- urgent notification
89 urgentConfig = UrgencyConfig { suppressWhen = Focused, remindWhen = Dont }
90
91 -- borders
92 borderWidth' = 1
93 normalBorderColor' = "#333333"
94 focusedBorderColor' = "#AFAF87"
95
96 -- tabs
97 tabTheme1 = defaultTheme { decoHeight = 16
98 , activeColor = "#a6c292"
99 , activeBorderColor = "#a6c292"
100 , activeTextColor = "#000000"
101 , inactiveBorderColor = "#000000"
102 }
103
104 -- workspaces
105 workspaces' = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
106
107 -- layouts
108 -- layoutHook' = tile ||| mtile ||| tab ||| full
109 layoutHook' = tile ||| full
110 where
111 rt = ResizableTall 1 (2/100) (1/2) []
112 tile = renamed [Replace "[]="] $ smartBorders rt
113 -- mtile = renamed [Replace "M[]="] $ smartBorders $ Mirror rt
114 -- tab = renamed [Replace "T"] $ noBorders $ tabbed shrinkText tabTheme1
115 full = renamed [Replace "[]"] $ noBorders Full
116
117 -------------------------------------------------------------------------------
118 -- Terminal --
119 terminal' :: String
120 terminal' = "urxvt"
121
122 -------------------------------------------------------------------------------
123 -- Keys/Button bindings --
124 -- modmask
125 modMask' = mod4Mask
126
127 -- keys
128 toggleStrutsKey :: XConfig Layout -> (KeyMask, KeySym)
129 toggleStrutsKey XConfig {XMonad.modMask = modMask} = (modMask .|. shiftMask, xK_b)
130
131 keys' :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ())
132 keys' conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
133 -- launching and killing programs
134 [ ((modMask, xK_Return), safeSpawn terminal' ["-e", "bash", "-c", "tmux attach-session -d || tmux new-session -s main"])
135 , ((modMask, xK_space ), safeSpawn "dmenu_run" ["-b", "-nb", "black"])
136 , ((modMask .|. shiftMask, xK_c ), kill)
137
138 -- multimedia
139 , ((0, xF86XK_AudioRaiseVolume ), safeSpawn "amixer" ["-q", "set", "Master", "1+"])
140 , ((0, xF86XK_AudioLowerVolume ), safeSpawn "amixer" ["-q", "set", "Master", "1-"])
141 , ((0, xF86XK_AudioMute ), safeSpawn "amixer" ["-q", "set", "Master", "toggle"])
142
143 -- , ((modMask .|. shiftMask, xK_z ), safeSpawn "i3lock" ["-c", "000000", "-n"])
144 -- grid
145 , ((modMask, xK_g ), goToSelected myGSConfig)
146
147 -- layouts
148 , ((modMask, xK_f ), sendMessage NextLayout)
149 -- , ((modMask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
150
151 -- floating layer stuff
152 , ((modMask .|. shiftMask, xK_f ), withFocused $ windows . W.sink)
153
154 -- refresh
155 , ((modMask, xK_r ), refresh)
156
157 -- focus
158 , ((modMask, xK_Tab ), windows W.focusDown)
159 , ((modMask, xK_j ), windows W.focusDown)
160 , ((modMask, xK_k ), windows W.focusUp)
161 , ((modMask, xK_m ), windows W.focusMaster)
162
163 -- workspaces
164 , ((modMask, xK_d ), toggleWS)
165 , ((modMask, xK_p ), prevWS)
166 , ((modMask, xK_n ), nextWS)
167 , ((modMask .|. shiftMask, xK_p ), shiftToPrev >> prevWS)
168 , ((modMask .|. shiftMask, xK_n ), shiftToNext >> nextWS)
169
170 -- screens
171 , ((modMask, xK_o ), nextScreen)
172 , ((modMask .|. shiftMask, xK_o ), shiftNextScreen >> nextScreen)
173
174 -- swapping
175 , ((modMask .|. shiftMask, xK_Return), windows W.swapMaster)
176 , ((modMask .|. shiftMask, xK_j ), windows W.swapDown )
177 , ((modMask .|. shiftMask, xK_k ), windows W.swapUp )
178
179 -- increase or decrease number of windows in the master area
180 , ((modMask , xK_comma ), sendMessage (IncMasterN 1))
181 , ((modMask , xK_period), sendMessage (IncMasterN (-1)))
182
183 -- resizing
184 , ((modMask, xK_h ), sendMessage Shrink)
185 , ((modMask, xK_l ), sendMessage Expand)
186 , ((modMask .|. shiftMask, xK_h ), sendMessage MirrorShrink)
187 , ((modMask .|. shiftMask, xK_l ), sendMessage MirrorExpand)
188
189 -- quit, or restart
190 , ((modMask .|. shiftMask, xK_q ), io exitSuccess)
191 , ((modMask , xK_q ), spawn "xmonad --recompile; xmonad --restart")
192 ]
193 ++
194 -- mod-[1..9] %! Switch to workspace N
195 -- mod-shift-[1..9] %! Move client to workspace N
196 [((m .|. modMask, k), windows $ f i)
197 | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
198 , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
199 -- ++
200 -- mod-[w,e] %! switch to twinview screen 1/2
201 -- mod-shift-[w,e] %! move window to screen 1/2
202 -- [((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))
203 -- | (key, sc) <- zip [xK_w, xK_e] [0..]
204 -- , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
205
206 -------------------------------------------------------------------------------
207 -- Mouse Bindings
208
209 mouseBindings' :: XConfig Layout -> M.Map (ButtonMask, Button) (Window -> X ())
210 mouseBindings' (XConfig {XMonad.modMask = modMask}) = M.fromList
211 [ ((modMask, 1 :: Button), \w -> focus w >> mouseMoveWindow w >> windows W.shiftMaster)
212 , ((modMask, 3 :: Button), \w -> focus w >> mouseResizeWindow w >> windows W.shiftMaster)
213 , ((0 , 6 :: Button), \w -> focus w >> prevWS)
214 , ((0 , 7 :: Button), \w -> focus w >> nextWS)
215 , ((modMask, 6 :: Button), \w -> focus w >> shiftToPrev >> prevWS)
216 , ((modMask, 7 :: Button), \w -> focus w >> shiftToNext >> nextWS)
217 ]
218
219 -------------------------------------------------------------------------------
Multihead
- Make sure to setup Xorg correctly (e.g. monitor1 ist left of monitor2).