Personal tools

Xmonad/Config archive/skorpan's xmonad.hs

From HaskellWiki

Jump to: navigation, search
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
                   }