Skip to content

Instantly share code, notes, and snippets.

@tzbob
Created January 21, 2012 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tzbob/1652393 to your computer and use it in GitHub Desktop.
Save tzbob/1652393 to your computer and use it in GitHub Desktop.
xmonad.hs
--
-- File : ~/.xmonad/xmonad.hs (for Xmonad >= 0.9)
-- Adapted by: Bob Reynders
-- Author : Thayer Williams
-- Website : http://cinderwick.ca/
-- Desc : A simple, mouse-friendly xmonad config geared towards
-- netbooks and other low-resolution devices.
--
-- dzen is used for statusbar rendering, with optional mouse
-- integration provided by xdotool:
--
-- * left-click workspace num to go to that ws
-- * left-click layout to cycle next layout
-- * left-click window title to cycle next window
-- * middle-click window title to kill focused window
--
import XMonad
import XMonad.Actions.CycleWindows -- classic alt-tab
import XMonad.Actions.CycleWS -- cycle thru WS', toggle last WS
import XMonad.Actions.DwmPromote -- swap master like dwm
import XMonad.Hooks.DynamicLog -- statusbar
import XMonad.Hooks.EwmhDesktops -- fullscreenEventHook fixes chrome fullscreen
import XMonad.Hooks.ManageDocks -- dock/tray mgmt
import XMonad.Hooks.UrgencyHook -- window alert bells
import XMonad.Layout.Named -- custom layout names
import XMonad.Layout.NoBorders -- smart borders on solo clients
import XMonad.Util.Run(spawnPipe) -- spawnPipe and hPutStrLn
import qualified Data.Map as M
import System.IO -- hPutStrLn scope
import qualified XMonad.StackSet as W -- manageHook rules
main = do
status <- spawnPipe myDzenStatus -- xmonad status on the left
conky <- spawnPipe myDzenBar -- detailbar on the right
xmonad $ withUrgencyHook NoUrgencyHook $ defaultConfig
{ modMask = mod1Mask
, terminal = "urxvtc"
, borderWidth = 2
, normalBorderColor = "#586E75"
, focusedBorderColor = "#CB4B16"
, handleEventHook = fullscreenEventHook
, workspaces = myWorkspaces
, layoutHook = myLayoutHook
, manageHook = manageDocks <+> myManageHook <+> manageHook defaultConfig
, logHook = myLogHook status
, keys = myKeys
}
-- Tags/Workspaces
-- clickable workspaces via dzen/xdotool
myWorkspaces :: [String]
myWorkspaces =
let wsl = ["a","s","d","f","g"]
in [ "^ca(1,xdotool key alt+" ++ ws ++ ")" ++ ws ++ "^ca()" | ws <- wsl ]
-- Layouts
-- the default layout is fullscreen with smartborders applied to all
myLayoutHook = avoidStruts $ smartBorders ( tiled ||| mtiled ||| full )
where
tiled = named "T" $ Tall 1 (5/100) (2/(1+(toRational(sqrt(5)::Double))))
mtiled = named "M" $ Mirror tiled
full = named "F" $ Full
-- sets default tile as: Tall nmaster (delta) (golden ratio)
-- Window management
--
myManageHook = composeAll
[
className =? "Transmission" --> doF (W.shift "d") -- send to ws 2
]
-- Statusbar
--
myLogHook h = dynamicLogWithPP $ myDzenPP { ppOutput = hPutStrLn h }
myDzenStatus = "dzen2 -w '320' -ta 'l'" ++ myDzenStyle
myDzenBar = "~/.xmonad/statusbar | dzen2 -x '320' -w '1660' -ta 'r'" ++ myDzenStyle
myDzenStyle = " -h '18' -fg '#839496' -bg '#fdf6e3' -fn 'bitbuntu'"
myDzenPP = dzenPP
{ ppCurrent = dzenColor "#cb4b16" "" . wrap " " " "
, ppHidden = dzenColor "#073642" "" . wrap " " " "
, ppHiddenNoWindows = dzenColor "#839496" "" . wrap " " " "
, ppUrgent = dzenColor "#ff0000" "" . wrap " " " "
, ppSep = " "
, ppLayout = dzenColor "#cb4b16" "" . wrap "^ca(1,xdotool key alt+space)" "^ca()" . dzenEscape
, ppTitle = dzenColor "#839496" ""
. wrap "^ca(1,xdotool key alt+k)^ca(2,xdotool key alt+shift+c)"
"^ca()^ca()" . shorten 40 . dzenEscape
}
-- Key bindings
--
myKeys :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ())
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
[ ((modMask .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)
, ((modMask, xK_p ), spawn "dmenu_run -b")
, ((modMask, xK_m ), spawn "dmount")
, ((modMask .|. controlMask, xK_j ), spawn "amixer set Master 5%- unmute")
, ((modMask .|. controlMask, xK_k ), spawn "amixer set Master 5%+ unmute")
, ((modMask .|. controlMask, xK_m ), spawn "amixer set Master toggle")
, ((modMask .|. shiftMask, xK_c ), kill)
, ((mod4Mask, xK_t ), spawn "transmission-gtk")
, ((mod4Mask, xK_l ), spawn "luakit")
, ((mod4Mask, xK_c ), spawn "chromium --incognito")
, ((mod4Mask, xK_v ), spawn "virtualbox --startvm Windows7")
, ((mod4Mask, xK_i ), spawn "urxvtc -e sh -c irssi")
, ((mod4Mask, xK_d ), spawn "dropbox start")
, ((modMask, xK_space ), sendMessage NextLayout)
, ((modMask, xK_j ), windows W.focusDown)
, ((modMask, xK_k ), windows W.focusUp )
, ((modMask, xK_Return), windows W.swapMaster)
, ((modMask .|. shiftMask, xK_j ), windows W.swapDown )
, ((modMask .|. shiftMask, xK_k ), windows W.swapUp )
, ((modMask, xK_h ), sendMessage Shrink)
, ((modMask, xK_l ), sendMessage Expand)
, ((modMask, xK_t ), withFocused $ windows . W.sink)
-- increase or decrease number of windows in the master area
, ((modMask .|. shiftMask, xK_h ), sendMessage (IncMasterN 1))
, ((modMask .|. shiftMask, xK_l ), sendMessage (IncMasterN (-1)))
-- toggle the status bar gap
, ((modMask , xK_b ), sendMessage ToggleStruts)
-- quit, or restart
, ((modMask , xK_q ), spawn "killall statusbar && xmonad --recompile && xmonad --restart")
]
++
-- mod-[a..g] %! Switch to workspace N
-- mod-shift-[a..g] %! Move client to workspace N
[((m .|. modMask, k), windows $ f i)
| (i, k) <- zip (XMonad.workspaces conf) [xK_a, xK_s, xK_d, xK_f, xK_g]
, (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment