Personal tools

Xmonad/Config archive/skorpan's xmonad.hs

From HaskellWiki

< Xmonad | Config archive(Difference between revisions)
Jump to: navigation, search
(Updating.)
(Updating.)
 
Line 1: Line 1:
 
<haskell>import System.Exit
 
<haskell>import System.Exit
import System.IO (hPutStrLn)
 
 
import XMonad
 
import XMonad
import XMonad.Actions.FindEmptyWorkspace
 
import XMonad.Actions.FlexibleManipulate as Flex
 
 
import XMonad.Hooks.DynamicLog
 
import XMonad.Hooks.DynamicLog
 
import XMonad.Hooks.ManageDocks
 
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.UrgencyHook
 
 
import XMonad.Layout.NoBorders
 
import XMonad.Layout.NoBorders
import XMonad.Util.Dzen
+
import XMonad.Prompt (defaultXPConfig)
import XMonad.Util.Run (spawnPipe, unsafeSpawn)
+
import XMonad.Prompt.Shell (shellPrompt)
  +
import XMonad.Util.EZConfig
  +
import XMonad.Util.Run
   
 
import qualified XMonad.StackSet as W
 
import qualified XMonad.StackSet as W
Line 15: Line 11:
   
   
fontName = "'-*-fixed-medium-r-*-*-12-*-*-*-*-*-iso8859-*'"
+
myKeys c = mkKeymap c $
dmenu = "exe=`cat /home/deniz/.programs | sort | dmenu -b -nb '#060000' -nf '#333333' -sb '#777777' -sf '#ffffff' -fn " ++ fontName ++ "` && eval \"exec $exe\""
+
[ ("M-<Return>", spawn $ XMonad.terminal c)
myTerminal = "urxvtc"
+
, ("M-<Space>", sendMessage NextLayout)
myBorderWidth = 2
+
, ("M-<Tab>", windows W.focusDown)
myModMask = mod4Mask
+
, ("M-S-<Return>", windows W.swapMaster)
myNumlockMask = mod2Mask
+
, ("M-S-c", kill)
myWorkspaces = [ show x | x <- [1..9] ]
+
, ("M-S-q", io (exitWith ExitSuccess))
myNormalBorderColor = "#060000"
+
, ("M-b", sendMessage ToggleStruts)
myFocusedBorderColor = "#ff0000"
+
, ("M-h", sendMessage Shrink)
  +
, ("M-l", sendMessage Expand)
  +
, ("M-n", refresh)
  +
, ("M-q", broadcastMessage ReleaseResources >> restart "xmonad" True)
  +
, ("M-t", withFocused $ windows . W.sink)
  +
, ("M-x", shellPrompt defaultXPConfig)]
  +
++
  +
[(m ++ k, windows $ f w)
  +
| (w, k) <- zip (XMonad.workspaces c) (map show [1..9])
  +
, (m, f) <- [("M-",W.greedyView), ("M-S-",W.shift)]]
   
   
myKeys conf@(XConfig {XMonad.modMask = modMask}) =
+
myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
M.fromList $
+
[ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w))
[ ((modMask, xK_Return ), spawn $ XMonad.terminal conf)
+
, ((modMask, button2), (\w -> focus w >> windows W.swapMaster))
, ((modMask, xK_p ), spawn dmenu )
+
, ((modMask, button3), (\w -> focus w >> mouseResizeWindow w))
, ((modMask .|. shiftMask, xK_p ), spawn "gmrun")
+
]
, ((modMask .|. shiftMask, xK_c ), kill)
 
, ((modMask, xK_space ), sendMessage NextLayout)
 
, ((modMask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
 
, ((modMask, xK_n ), refresh)
 
, ((modMask, xK_Left ), windows W.focusUp)
 
, ((modMask, xK_Right ), windows W.focusDown)
 
, ((modMask, xK_Tab ), windows W.focusDown)
 
, ((modMask, xK_m ), viewEmptyWorkspace)
 
, ((modMask .|. shiftMask, xK_j ), windows W.swapDown)
 
, ((modMask .|. shiftMask, xK_k ), windows W.swapUp)
 
, ((modMask .|. shiftMask, xK_Return ), windows W.swapMaster)
 
, ((modMask, xK_F9 ), spawn "mpc prev")
 
, ((modMask, xK_F10 ), spawn "mpc next")
 
, ((modMask, xK_h ), sendMessage Shrink)
 
, ((modMask, xK_l ), sendMessage Expand)
 
, ((modMask, xK_t ), withFocused $ windows . W.sink)
 
, ((modMask , xK_comma ), sendMessage (IncMasterN 1))
 
, ((modMask , xK_period ), sendMessage (IncMasterN (-1)))
 
, ((modMask, xK_BackSpace ), focusUrgent)
 
, ((modMask , xK_b ), sendMessage ToggleStruts)
 
, ((modMask .|. shiftMask, xK_q ), io (exitWith ExitSuccess))
 
, ((modMask , xK_q ), broadcastMessage ReleaseResources >> restart "xmonad" True)
 
]
 
++
 
[((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}) =
+
myLayoutHook = smartBorders $ avoidStruts $ tiled ||| Mirror tiled ||| Full
M.fromList $
+
where
[ ((modMask, button1), (\w -> focus w >> Flex.mouseWindow Flex.position w))
+
tiled = Tall nmaster delta ratio
, ((modMask, button3), (\w -> focus w >> Flex.mouseWindow Flex.resize w)) ]
+
nmaster = 1
+
ratio = 1/2
+
delta = 4/100
myLayout = avoidStruts . smartBorders $ tall ||| Mirror tall ||| Full
 
where
 
tall = Tall nmaster delta ratio
 
nmaster = 1
 
ratio = 1/2
 
delta = 1/100
 
   
   
 
myManageHook = composeAll
 
myManageHook = composeAll
 
[ floatC "MPlayer"
 
[ floatC "MPlayer"
, floatC "gimp"
+
, floatC "Gimp"
, moveToC "Gran Paradiso" "2"
+
, moveToC "Conkeror" "2"
, moveToC "Sonata" "9"
 
 
]
 
]
<+>
 
manageDocks
 
 
where moveToC c w = className =? c --> doF (W.shift w)
 
where moveToC c w = className =? c --> doF (W.shift w)
 
moveToT t w = title =? t --> doF (W.shift w)
 
moveToT t w = title =? t --> doF (W.shift w)
Line 53: Line 47:
   
   
myLogHook h = dynamicLogWithPP $ defaultPP {
+
myLogHook xmobar = dynamicLogWithPP $ defaultPP {
ppCurrent = dzenColor "black" "white" . pad
+
ppOutput = hPutStrLn xmobar
, ppVisible = dzenColor "white" "#333333" . pad
+
, ppTitle = xmobarColor "white" "" . shorten 110
, ppHidden = dzenColor "white" "#333333" . pad
+
, ppCurrent = xmobarColor "white" "black" . pad
, ppHiddenNoWindows = dzenColor "#777777" "#333333" . pad
+
, ppHidden = pad
, ppUrgent = dzenColor "red" "yellow"
+
, ppHiddenNoWindows = \w -> xmobarColor "#444" "" (" " ++ w ++ " ")
, ppWsSep = "|"
+
, ppSep = xmobarColor "#555" "" " / "
, ppSep = " - "
+
, ppWsSep = ""
, ppLayout = id
+
, ppLayout = \x -> case x of
, ppTitle = ("^fg(white) " ++) . dzenEscape
+
"Tall" -> "T"
, ppOutput = hPutStrLn h
+
"Mirror Tall" -> "M"
}
+
"Full" -> "F"
  +
_ -> "?"
  +
}
   
   
firstDzenCommand = "dzen2 -fn " ++ fontName ++ " -bg '#060000' -fg '#777777' -h 16 -w 1280 -sa c -e '' -ta l"
+
main = do xmobar <- spawnPipe "xmobar"
secondDzenCommand = "conky -u 1 | dzen2 -fn " ++ fontName ++ " -bg '#060000' -fg '#777777' -h 16 -w 1280 -sa c -e '' -ta r -y 784"
+
xmonad $ defaultConfig {
+
terminal = "urxvtc",
+
focusFollowsMouse = True,
main = do din <- spawnPipe firstDzenCommand
+
borderWidth = 2,
spawnPipe secondDzenCommand
+
modMask = mod4Mask,
xmonad $ withUrgencyHook NoUrgencyHook
+
numlockMask = 0,
$ defaultConfig {
+
workspaces = [ show x | x <- [1..9] ],
terminal = myTerminal,
+
normalBorderColor = "#444",
focusFollowsMouse = True,
+
focusedBorderColor = "#f00",
borderWidth = myBorderWidth,
+
keys = myKeys,
modMask = myModMask,
+
mouseBindings = myMouseBindings,
numlockMask = myNumlockMask,
+
layoutHook = myLayoutHook,
workspaces = myWorkspaces,
+
manageHook = myManageHook,
normalBorderColor = myNormalBorderColor,
+
logHook = myLogHook xmobar
focusedBorderColor = myFocusedBorderColor,
+
}
keys = myKeys,
 
mouseBindings = myMouseBindings,
 
layoutHook = myLayout,
 
manageHook = myManageHook,
 
logHook = myLogHook din
 
}
 
 
</haskell>
 
</haskell>

Latest revision as of 17:28, 25 January 2009

import System.Exit
import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Layout.NoBorders
import XMonad.Prompt (defaultXPConfig)
import XMonad.Prompt.Shell (shellPrompt)
import XMonad.Util.EZConfig
import XMonad.Util.Run
 
import qualified XMonad.StackSet as W
import qualified Data.Map        as M
 
 
myKeys c = mkKeymap c $
           [ ("M-<Return>",   spawn $ XMonad.terminal c)
           , ("M-<Space>",    sendMessage NextLayout)
           , ("M-<Tab>",      windows W.focusDown)
           , ("M-S-<Return>", windows W.swapMaster)
           , ("M-S-c",        kill)
           , ("M-S-q",        io (exitWith ExitSuccess))
           , ("M-b",          sendMessage ToggleStruts)
           , ("M-h",          sendMessage Shrink)
           , ("M-l",          sendMessage Expand)
           , ("M-n",          refresh)
           , ("M-q",          broadcastMessage ReleaseResources >> restart "xmonad" True)
           , ("M-t",          withFocused $ windows . W.sink)
           , ("M-x",          shellPrompt defaultXPConfig)]
           ++
           [(m ++ k, windows $ f w)
                | (w, k) <- zip (XMonad.workspaces c) (map show [1..9])
           , (m, f) <- [("M-",W.greedyView), ("M-S-",W.shift)]]
 
 
myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
    [ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w))
    , ((modMask, button2), (\w -> focus w >> windows W.swapMaster))
    , ((modMask, button3), (\w -> focus w >> mouseResizeWindow w))
    ]
 
 
myLayoutHook = smartBorders $ avoidStruts $ tiled ||| Mirror tiled ||| Full
  where
     tiled   = Tall nmaster delta ratio
     nmaster = 1
     ratio   = 1/2
     delta   = 4/100
 
 
myManageHook = composeAll
               [ floatC "MPlayer"
               , floatC "Gimp"
               , moveToC "Conkeror" "2"
               ]
    where moveToC c w = className =? c --> doF (W.shift w)
          moveToT t w = title     =? t --> doF (W.shift w)
          floatC  c   = className =? c --> doFloat
 
 
myLogHook xmobar = dynamicLogWithPP $ defaultPP {
                     ppOutput = hPutStrLn xmobar
                   , ppTitle = xmobarColor "white" "" . shorten 110
                   , ppCurrent = xmobarColor "white" "black" . pad
                   , ppHidden = pad
                   , ppHiddenNoWindows = \w -> xmobarColor "#444" "" (" " ++ w ++ " ")
                   , ppSep = xmobarColor "#555" "" " / "
                   , ppWsSep = ""
                   , ppLayout = \x -> case x of
                                        "Tall" -> "T"
                                        "Mirror Tall" -> "M"
                                        "Full" -> "F"
                                        _ -> "?"
                   }
 
 
main = do xmobar <- spawnPipe "xmobar"
          xmonad $ defaultConfig {
                       terminal           = "urxvtc",
                       focusFollowsMouse  = True,
                       borderWidth        = 2,
                       modMask            = mod4Mask,
                       numlockMask        = 0,
                       workspaces         = [ show x | x <- [1..9] ],
                       normalBorderColor  = "#444",
                       focusedBorderColor = "#f00",
                       keys               = myKeys,
                       mouseBindings      = myMouseBindings,
                       layoutHook         = myLayoutHook,
                       manageHook         = myManageHook,
                       logHook            = myLogHook xmobar
                     }