Personal tools

Xmonad/Config archive/skorpan's xmonad.hs

From HaskellWiki

< Xmonad | Config archive(Difference between revisions)
Jump to: navigation, search
(Updated for 0.7.)
(Updating.)
Line 1: Line 1:
<haskell>import XMonad
+
<haskell>import System.Exit
import System.Exit
+
import System.IO (hPutStrLn)
  +
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.Util.Run (spawnPipe)
+
import XMonad.Hooks.UrgencyHook
import System.IO (hPutStrLn)
+
import XMonad.Layout.NoBorders
  +
import XMonad.Util.Dzen
  +
import XMonad.Util.Run (spawnPipe, unsafeSpawn)
   
 
import qualified XMonad.StackSet as W
 
import qualified XMonad.StackSet as W
 
import qualified Data.Map as M
 
import qualified Data.Map as M
   
dmenuExec =
 
"exe=`dmenu_path | dmenu -b -nb black -nf white -sb gray -sf black` && eval \"exec $exe\""
 
   
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
+
fontName = "'-*-fixed-medium-r-*-*-12-*-*-*-*-*-iso8859-*'"
[ ((modMask, xK_Return), spawn $ XMonad.terminal conf)
+
dmenu = "exe=`cat /home/deniz/.programs | sort | dmenu -b -nb '#060000' -nf '#333333' -sb '#777777' -sf '#ffffff' -fn " ++ fontName ++ "` && eval \"exec $exe\""
, ((modMask, xK_p ), spawn dmenuExec)
+
myTerminal = "urxvtc"
, ((modMask .|. shiftMask, xK_c ), kill)
+
myBorderWidth = 2
, ((modMask, xK_space ), sendMessage NextLayout)
+
myModMask = mod4Mask
, ((modMask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
+
myNumlockMask = mod2Mask
, ((modMask, xK_n ), refresh)
+
myWorkspaces = [ show x | x <- [1..9] ]
, ((modMask, xK_Tab ), windows W.focusDown)
+
myNormalBorderColor = "#060000"
, ((modMask, xK_j ), windows W.focusDown)
+
myFocusedBorderColor = "#ff0000"
, ((modMask, xK_e ), windows W.focusDown)
 
, ((modMask, xK_Right ), windows W.focusDown)
 
, ((modMask, xK_k ), windows W.focusUp )
 
, ((modMask, xK_Left ), windows W.focusUp )
 
, ((modMask, xK_m ), windows W.focusMaster )
 
, ((modMask .|. shiftMask, xK_Return), windows W.swapMaster)
 
, ((modMask .|. shiftMask, xK_e ), windows W.swapDown )
 
, ((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)
 
, ((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)]]
 
   
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))
 
]
 
   
myLayout = avoidStruts (tall ||| Mirror tall ||| Full)
+
myKeys conf@(XConfig {XMonad.modMask = modMask}) =
where
+
M.fromList $
tall = Tall nmaster delta ratio
+
[ ((modMask, xK_Return ), spawn $ XMonad.terminal conf)
nmaster = 1
+
, ((modMask, xK_p ), spawn dmenu )
ratio = 1/2
+
, ((modMask .|. shiftMask, xK_p ), spawn "gmrun")
delta = 2/100
+
, ((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}) =
  +
M.fromList $
  +
[ ((modMask, button1), (\w -> focus w >> Flex.mouseWindow Flex.position w))
  +
, ((modMask, button3), (\w -> focus w >> Flex.mouseWindow Flex.resize w)) ]
  +
  +
  +
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
[ className =? "MPlayer" --> doFloat
+
[ floatC "MPlayer"
, className =? "Gimp" --> doFloat
+
, floatC "gimp"
, resource =? "desktop_window" --> doIgnore
+
, moveToC "Gran Paradiso" "2"
, resource =? "kdesktop" --> doIgnore ] <+> manageDocks
+
, moveToC "Sonata" "9"
  +
]
  +
<+>
  +
manageDocks
  +
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 h = dynamicLogWithPP $ defaultPP {
 
myLogHook h = dynamicLogWithPP $ defaultPP {
ppCurrent = dzenColor "black" "white" . pad
+
ppCurrent = dzenColor "black" "white" . pad
, ppVisible = dzenColor "white" "#333333" . pad
+
, ppVisible = dzenColor "white" "#333333" . pad
, ppHidden = dzenColor "white" "#333333" . pad
+
, ppHidden = dzenColor "white" "#333333" . pad
, ppHiddenNoWindows = dzenColor "#777777" "#333333" . pad
+
, ppHiddenNoWindows = dzenColor "#777777" "#333333" . pad
, ppUrgent = dzenColor "red" "yellow"
+
, ppUrgent = dzenColor "red" "yellow"
, ppWsSep = ""
+
, ppWsSep = "|"
, ppSep = ""
+
, ppSep = " - "
, ppLayout = dzenColor "white" "#333333" .
+
, ppLayout = id
(\ x -> fill (case x of
+
, ppTitle = ("^fg(white) " ++) . dzenEscape
"Tall" -> icon "tall.xbm"
+
, ppOutput = hPutStrLn h
"Mirror Tall" -> icon "mtall.xbm"
+
}
"Full" -> icon "full.xbm"
 
_ -> pad x) 4)
 
, ppTitle = ("^fg(white) " ++) . dzenEscape
 
, ppOutput = hPutStrLn h
 
}
 
where
 
icon h = "^i(/home/deniz/usr/share/dzen2/icons/" ++ h ++ ")"
 
fill :: String -> Int -> String
 
fill h i = "^p(" ++ show i ++ ")" ++ h ++ "^p(" ++ show i ++ ")"
 
   
myStatusBar = "dzen2 -fn '-*-terminus-*-*-*-*-12-*-*-*-*-*-*-*' -bg '#222222' -fg '#777777' -h 16 -w 1280 -sa c -e '' -ta l"
 
   
main = do din <- spawnPipe myStatusBar
+
firstDzenCommand = "dzen2 -fn " ++ fontName ++ " -bg '#060000' -fg '#777777' -h 16 -w 1280 -sa c -e '' -ta l"
xmonad $ defaultConfig {
+
secondDzenCommand = "conky -u 1 | dzen2 -fn " ++ fontName ++ " -bg '#060000' -fg '#777777' -h 16 -w 1280 -sa c -e '' -ta r -y 784"
 
terminal = "urxvtc",
 
focusFollowsMouse = True,
 
borderWidth = 1,
 
modMask = mod4Mask,
 
numlockMask = mod2Mask,
 
workspaces = ["irc","web","dev","4","5","6","7","warez","music"],
 
normalBorderColor = "#000000",
 
focusedBorderColor = "#ff0000",
 
   
-- key bindings
 
keys = myKeys,
 
mouseBindings = myMouseBindings,
 
   
-- hooks, layouts
+
main = do din <- spawnPipe firstDzenCommand
layoutHook = myLayout,
+
spawnPipe secondDzenCommand
manageHook = myManageHook,
+
xmonad $ withUrgencyHook NoUrgencyHook
logHook = myLogHook din
+
$ defaultConfig {
}
+
terminal = myTerminal,
  +
focusFollowsMouse = True,
  +
borderWidth = myBorderWidth,
  +
modMask = myModMask,
  +
numlockMask = myNumlockMask,
  +
workspaces = myWorkspaces,
  +
normalBorderColor = myNormalBorderColor,
  +
focusedBorderColor = myFocusedBorderColor,
  +
keys = myKeys,
  +
mouseBindings = myMouseBindings,
  +
layoutHook = myLayout,
  +
manageHook = myManageHook,
  +
logHook = myLogHook din
  +
}
 
</haskell>
 
</haskell>

Revision as of 22:48, 23 August 2008

import System.Exit
import System.IO (hPutStrLn)
import XMonad
import XMonad.Actions.FindEmptyWorkspace
import XMonad.Actions.FlexibleManipulate as Flex
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.UrgencyHook
import XMonad.Layout.NoBorders
import XMonad.Util.Dzen
import XMonad.Util.Run (spawnPipe, unsafeSpawn)
 
import qualified XMonad.StackSet as W
import qualified Data.Map        as M
 
 
fontName = "'-*-fixed-medium-r-*-*-12-*-*-*-*-*-iso8859-*'"
dmenu = "exe=`cat /home/deniz/.programs | sort | dmenu -b -nb '#060000' -nf '#333333' -sb '#777777' -sf '#ffffff' -fn " ++ fontName ++ "` && eval \"exec $exe\""
myTerminal      = "urxvtc"
myBorderWidth   = 2
myModMask       = mod4Mask
myNumlockMask   = mod2Mask
myWorkspaces    = [ show x | x <- [1..9] ]
myNormalBorderColor  = "#060000"
myFocusedBorderColor = "#ff0000"
 
 
myKeys conf@(XConfig {XMonad.modMask = modMask}) =
    M.fromList $
         [ ((modMask,               xK_Return    ), spawn $ XMonad.terminal conf)
         , ((modMask,               xK_p         ), spawn dmenu )
         , ((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}) =
    M.fromList $
         [ ((modMask, button1), (\w -> focus w >> Flex.mouseWindow Flex.position w))
         , ((modMask, button3), (\w -> focus w >> Flex.mouseWindow Flex.resize w)) ]
 
 
myLayout = avoidStruts . smartBorders $ tall ||| Mirror tall ||| Full
    where
      tall   = Tall nmaster delta ratio
      nmaster = 1
      ratio   = 1/2
      delta   = 1/100
 
 
myManageHook = composeAll
               [ floatC "MPlayer"
               , floatC "gimp"
               , moveToC "Gran Paradiso" "2"
               , moveToC "Sonata" "9"
               ]
               <+>
               manageDocks
    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 h = dynamicLogWithPP $ defaultPP {
                ppCurrent  = dzenColor "black" "white" . pad
              , ppVisible  = dzenColor "white" "#333333" . pad
              , ppHidden   = dzenColor "white"  "#333333" . pad
              , ppHiddenNoWindows = dzenColor "#777777"  "#333333" . pad
              , ppUrgent   = dzenColor "red" "yellow"
              , ppWsSep    = "|"
              , ppSep      = " - "
              , ppLayout   = id
              , ppTitle    = ("^fg(white) " ++) . dzenEscape
              , ppOutput   = hPutStrLn h
              }
 
 
firstDzenCommand = "dzen2 -fn " ++ fontName ++ " -bg '#060000' -fg '#777777' -h 16 -w 1280 -sa c -e '' -ta l"
secondDzenCommand = "conky -u 1 | dzen2 -fn " ++ fontName ++ " -bg '#060000' -fg '#777777' -h 16 -w 1280 -sa c -e '' -ta r -y 784"
 
 
main = do din <- spawnPipe firstDzenCommand
          spawnPipe secondDzenCommand
          xmonad $ withUrgencyHook NoUrgencyHook
                 $ defaultConfig {
                     terminal           = myTerminal,
                     focusFollowsMouse  = True,
                     borderWidth        = myBorderWidth,
                     modMask            = myModMask,
                     numlockMask        = myNumlockMask,
                     workspaces         = myWorkspaces,
                     normalBorderColor  = myNormalBorderColor,
                     focusedBorderColor = myFocusedBorderColor,
                     keys               = myKeys,
                     mouseBindings      = myMouseBindings,
                     layoutHook         = myLayout,
                     manageHook         = myManageHook,
                     logHook            = myLogHook din
                   }