Personal tools

Xmonad/Config archive/Wraithan's xmonad.hs

From HaskellWiki

< Xmonad | Config archive(Difference between revisions)
Jump to: navigation, search
 
Line 4: Line 4:
 
import XMonad.Hooks.DynamicLog
 
import XMonad.Hooks.DynamicLog
 
import XMonad.Hooks.ManageDocks
 
import XMonad.Hooks.ManageDocks
import XMonad.Layout.HintedTile
+
import XMonad.Hooks.UrgencyHook
import XMonad.Layout.LayoutHints (layoutHints)
+
import XMonad.Layout.LayoutHints
  +
import XMonad.Layout.ResizableTile
 
import XMonad.Prompt
 
import XMonad.Prompt
 
import XMonad.Prompt.Shell
 
import XMonad.Prompt.Shell
Line 19: Line 19:
 
main = do
 
main = do
 
xmproc <- spawnPipe "xmobar"
 
xmproc <- spawnPipe "xmobar"
xmonad $ defaultConfig {
+
xmonad $ withUrgencyHook NoUrgencyHook
terminal = "urxvt -fg white",
+
$ defaultConfig {
modMask = mod4Mask,
+
terminal = "urxvt",
workspaces = ["1:Chat", "2:Web", "3:Code", "4:Terms", "5", "6", "7", "8", "9:Music"],
+
modMask = mod4Mask,
normalBorderColor = "#333333",
+
workspaces = ["1:Chat", "2:Web", "3:Code", "4:Terms", "5", "6", "7", "8", "9:Music"],
focusedBorderColor = "#333399",
+
normalBorderColor = "#333333",
manageHook = composeAll [],
+
focusedBorderColor = "#3399cc",
keys = myKeys,
+
manageHook = myManageHook,
mouseBindings = myMouseBindings,
+
keys = myKeys,
layoutHook = myLayout,
+
mouseBindings = myMouseBindings,
logHook = dynamicLogWithPP $ xmobarPP {
+
layoutHook = myLayout,
ppOutput = hPutStrLn xmproc,
+
logHook = dynamicLogWithPP $ xmobarPP {
ppTitle = xmobarColor "green" "" . shorten 50
+
ppOutput = hPutStrLn xmproc,
}
+
ppTitle = xmobarColor "green" "" . shorten 50
  +
}
 
}
 
}
   
Line 51: Line 51:
 
, ((modMask , xK_h ), sendMessage Shrink)
 
, ((modMask , xK_h ), sendMessage Shrink)
 
, ((modMask , xK_l ), sendMessage Expand)
 
, ((modMask , xK_l ), sendMessage Expand)
  +
, ((modMask .|. shiftMask, xK_h ), sendMessage MirrorShrink)
  +
, ((modMask .|. shiftMask, xK_l ), sendMessage MirrorExpand)
 
, ((modMask , xK_t ), withFocused $ windows . W.sink)
 
, ((modMask , xK_t ), withFocused $ windows . W.sink)
 
, ((modMask , xK_comma ), sendMessage (IncMasterN 1))
 
, ((modMask , xK_comma ), sendMessage (IncMasterN 1))
Line 57: Line 59:
 
, ((modMask , xK_q ), spawn "xmonad --recompile; xmonad --restart")
 
, ((modMask , xK_q ), spawn "xmonad --recompile; xmonad --restart")
 
, ((modMask , xK_F2 ), shellPrompt defaultXPConfig)
 
, ((modMask , xK_F2 ), shellPrompt defaultXPConfig)
, ((0 , 0x1008ff30 ), shellPrompt defaultXPConfig)
 
 
, ((0 , 0x1008ff13 ), spawn "amixer -q set Master 2dB+")
 
, ((0 , 0x1008ff13 ), spawn "amixer -q set Master 2dB+")
 
, ((0 , 0x1008ff11 ), spawn "amixer -q set Master 2dB-")
 
, ((0 , 0x1008ff11 ), spawn "amixer -q set Master 2dB-")
 
, ((0 , 0x1008ff12 ), spawn "amixer -q set Master toggle")
 
, ((0 , 0x1008ff12 ), spawn "amixer -q set Master toggle")
, ((0 , 0x1008ff16 ), spawn "cmus-remote --prev")
+
, ((0 , 0x1008ff16 ), spawn "mocp --prev")
, ((0 , 0x1008ff17 ), spawn "cmus-remote --next")
+
, ((0 , 0x1008ff17 ), spawn "mocp --next")
, ((0 , 0x1008ff14 ), spawn "cmus-remote --pause")
+
, ((0 , 0x1008ff14 ), spawn "mocp --toggle-pause")
, ((0 , 0x1008ff5b ), spawn "urxvt -e screen -rd cmus")
 
 
, ((modMask , xK_Print ), spawn "scrot -e 'mv $f ~/Screenshots'")
 
, ((modMask , xK_Print ), spawn "scrot -e 'mv $f ~/Screenshots'")
 
]
 
]
Line 86: Line 87:
 
]
 
]
   
myLayout = avoidStruts $ tiled ||| wideTiled ||| Full
+
myLayout = avoidStruts $ layoutHints (tall ||| Mirror tall ||| Full)
 
where
 
where
tiled = HintedTile nmaster delta ratio Center Tall
+
tall = ResizableTall nmaster delta ratio []
wideTiled = HintedTile nmaster delta ratio Center Wide
 
 
nmaster = 1
 
nmaster = 1
ratio = 1/2
 
 
delta = 3/100
 
delta = 3/100
  +
ratio = 1/2
  +
  +
myManageHook :: ManageHook
  +
myManageHook = composeAll
  +
[ className =? "Pidgin" --> doShift "1:Chat"
  +
, className =? "Shiretoko" --> doShift "2:Web"]
 
</haskell>
 
</haskell>

Latest revision as of 22:43, 14 December 2009

import XMonad hiding (Tall)
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.UrgencyHook
import XMonad.Layout.LayoutHints
import XMonad.Layout.ResizableTile
import XMonad.Prompt
import XMonad.Prompt.Shell
import XMonad.Util.Run(spawnPipe)
 
import System.Exit
import System.IO
import Data.Monoid
 
import qualified XMonad.StackSet as W
import qualified Data.Map        as M
 
main = do
    xmproc <- spawnPipe "xmobar"
    xmonad $ withUrgencyHook NoUrgencyHook
           $ defaultConfig {
                terminal           = "urxvt",
                modMask            = mod4Mask,
                workspaces         = ["1:Chat", "2:Web", "3:Code", "4:Terms", "5", "6", "7", "8", "9:Music"],
                normalBorderColor  = "#333333",
                focusedBorderColor = "#3399cc",
                manageHook         = myManageHook,
                keys               = myKeys,
                mouseBindings      = myMouseBindings,
                layoutHook         = myLayout,
                logHook            = dynamicLogWithPP $ xmobarPP { 
                                         ppOutput = hPutStrLn xmproc,
                                         ppTitle = xmobarColor "green" "" . shorten 50
                                     }
    }
 
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
 
    [ ((modMask              , xK_Return   ), spawn $ XMonad.terminal conf)
    , ((modMask .|. shiftMask, xK_c        ), kill)
    , ((modMask              , xK_space    ), sendMessage NextLayout)
    , ((modMask .|. shiftMask, xK_space    ), setLayout $ XMonad.layoutHook conf)
    , ((modMask              , xK_n        ), refresh)
    , ((modMask              , xK_Tab      ), windows W.focusDown)
    , ((modMask              , xK_j        ), windows W.focusDown)
    , ((modMask              , xK_k        ), windows W.focusUp)
    , ((modMask              , xK_m        ), windows W.focusMaster)
    , ((modMask .|. shiftMask, 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 .|. shiftMask, xK_h        ), sendMessage MirrorShrink)
    , ((modMask .|. shiftMask, xK_l        ), sendMessage MirrorExpand)
    , ((modMask              , xK_t        ), withFocused $ windows . W.sink)
    , ((modMask              , xK_comma    ), sendMessage (IncMasterN 1))
    , ((modMask              , xK_period   ), sendMessage (IncMasterN (-1)))
    , ((modMask .|. shiftMask, xK_q        ), io (exitWith ExitSuccess))
    , ((modMask              , xK_q        ), spawn "xmonad --recompile; xmonad --restart")
    , ((modMask              , xK_F2       ), shellPrompt defaultXPConfig)
    , ((0                    , 0x1008ff13  ), spawn "amixer -q set Master 2dB+")
    , ((0                    , 0x1008ff11  ), spawn "amixer -q set Master 2dB-")
    , ((0                    , 0x1008ff12  ), spawn "amixer -q set Master toggle")
    , ((0                    , 0x1008ff16  ), spawn "mocp --prev")
    , ((0                    , 0x1008ff17  ), spawn "mocp --next")
    , ((0                    , 0x1008ff14  ), spawn "mocp --toggle-pause")
    , ((modMask              , xK_Print    ), spawn "scrot -e 'mv $f ~/Screenshots'")
    ]
    ++
 
    [((m .|. modMask, k), windows $ f i)
        | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
        , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
 
    ++
 
    [((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))
        | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
        , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
 
myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
    [ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w
                                          >> windows W.shiftMaster))
    , ((modMask, button2), (\w -> focus w >> windows W.shiftMaster))
    , ((modMask, button3), (\w -> focus w >> mouseResizeWindow w
                                          >> windows W.shiftMaster))
    ]
 
myLayout = avoidStruts $ layoutHints (tall ||| Mirror tall ||| Full)
  where
     tall = ResizableTall nmaster delta ratio []
     nmaster = 1
     delta   = 3/100
     ratio   = 1/2
 
myManageHook :: ManageHook
myManageHook = composeAll
    [ className =? "Pidgin"    --> doShift "1:Chat"
    , className =? "Shiretoko" --> doShift "2:Web"]