Advertisement
Guest User

dusanx

a guest
Dec 24th, 2008
1,541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {- xmonad.hs
  2.  - Author: Øyvind 'Mr.Elendig' Heggstad <mrelendig AT har-ikkje DOT net>
  3.  - Version: 0.0.9
  4.  - Modified version
  5.  -}
  6.  
  7. -------------------------------------------------------------------------------
  8. -- Imports --
  9. -- stuff
  10. import XMonad
  11. import qualified XMonad.StackSet as W
  12. import qualified Data.Map as M
  13. import System.Exit
  14. import Graphics.X11.Xlib
  15. import IO (Handle, hPutStrLn)
  16. import XMonad.Actions.CycleWS
  17. import XMonad.Actions.DynamicWorkspaces
  18.  
  19. -- utils
  20. import XMonad.Util.Run (spawnPipe)
  21.  
  22. -- hooks
  23. import XMonad.Hooks.ManageDocks
  24. import XMonad.Hooks.DynamicLog
  25.  
  26. -- layouts
  27. import XMonad.Layout.NoBorders
  28. import XMonad.Layout.ResizableTile
  29.  
  30. -------------------------------------------------------------------------------
  31. -- Main --
  32. main = do
  33.        h <- spawnPipe "xmobar"
  34.        xmonad $ defaultConfig
  35.               { workspaces = workspaces'
  36.              , modMask = modMask'
  37.               , borderWidth = borderWidth'
  38.              , normalBorderColor = normalBorderColor'
  39.               , focusedBorderColor = focusedBorderColor'
  40.              , terminal = terminal'
  41.               , keys = keys'
  42.              , logHook = logHook' h
  43.               , layoutHook = layoutHook'
  44.              , manageHook = manageHook'
  45.               , focusFollowsMouse  = myFocusFollowsMouse
  46.               }
  47.  
  48. -------------------------------------------------------------------------------
  49. -- Hooks --
  50.  
  51. manageHook' :: ManageHook
  52. manageHook' = (doF W.swapDown) <+> manageHook defaultConfig <+> manageDocks
  53.  
  54. logHook' :: Handle ->  X ()
  55. logHook' h = dynamicLogWithPP $ customPP { ppOutput = hPutStrLn h }
  56.  
  57. layoutHook' = customLayout
  58.  
  59. -------------------------------------------------------------------------------
  60. -- Looks --
  61. -- bar
  62. customPP :: PP
  63. customPP = defaultPP { ppCurrent = xmobarColor "#AFAF87" "" . wrap "[" "]"
  64.                     , ppTitle =  shorten 80
  65.                     , ppSep =  "<fc=#AFAF87> :: </fc>"
  66.                     , ppHiddenNoWindows = xmobarColor "#404040" ""
  67.                     , ppUrgent = xmobarColor "#ff0000" "" . wrap "!" "!"
  68.                     }
  69.  
  70. -- Whether focus follows the mouse pointer.
  71. myFocusFollowsMouse :: Bool
  72. myFocusFollowsMouse = False
  73.  
  74. -- borders
  75. borderWidth' :: Dimension
  76. borderWidth' = 1
  77.  
  78. normalBorderColor', focusedBorderColor' :: String
  79. normalBorderColor'  = "#000000"
  80. focusedBorderColor' = "#999999"
  81.  
  82. -- workspaces
  83. workspaces' :: [WorkspaceId]
  84. workspaces' = ["1-Main", "2-Temp", "3-Work", "4-Misc", "5-Msg", "6-Media", "7", "8", "9"]
  85.  
  86. -- layouts
  87. customLayout = avoidStruts $ smartBorders tiled ||| smartBorders (Mirror tiled)  ||| smartBorders Full
  88.  where
  89.    tiled = ResizableTall 1 (2/100) (1/2) []
  90.  
  91. -------------------------------------------------------------------------------
  92. -- Terminal --
  93. terminal' :: String
  94. terminal' = "urxvt"
  95.  
  96. -------------------------------------------------------------------------------
  97. -- Keys/Button bindings --
  98. -- modmask
  99. modMask' :: KeyMask
  100. modMask' = mod1Mask
  101.  
  102. -- keys
  103. keys' :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ())
  104. keys' conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
  105.    -- launching and killing programs
  106.    [ ((modMask .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)
  107.    , ((modMask,               xK_p     ), spawn "exe=`dmenu_path | dmenu` && eval \"exec $exe\"")
  108.    , ((modMask .|. shiftMask, xK_p     ), spawn "gmrun")
  109.    , ((modMask .|. shiftMask, xK_c     ), kill)
  110.    , ((modMask .|. shiftMask, xK_m     ), spawn "claws-mail")
  111.  
  112.    -- layouts
  113.    , ((modMask,               xK_space ), sendMessage NextLayout)
  114.    , ((modMask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
  115.    , ((modMask .|. shiftMask, xK_b     ), sendMessage ToggleStruts)
  116.  
  117.    -- floating layer stuff
  118.    , ((modMask,               xK_t     ), withFocused $ windows . W.sink)
  119.  
  120.    -- refresh
  121.    , ((modMask,               xK_n     ), refresh)
  122.    
  123.     -- move focus between screens
  124.     , ((modMask .|. controlMask, xK_Right), prevScreen)
  125.    , ((modMask .|. controlMask, xK_Left),  nextScreen)
  126.    , ((modMask .|. controlMask, xK_o),  shiftNextScreen)
  127.  
  128.    -- focus
  129.    , ((modMask,               xK_Tab   ), windows W.focusDown)
  130.    , ((modMask,               xK_j     ), windows W.focusDown)
  131.    , ((modMask,               xK_k     ), windows W.focusUp)
  132.    , ((modMask,               xK_m     ), windows W.focusMaster)
  133.  
  134.    -- swapping
  135.    --, ((modMask .|. shiftMask, xK_Return), windows W.swapMaster)
  136.    , ((modMask .|. shiftMask, xK_j     ), windows W.swapDown  )
  137.    , ((modMask .|. shiftMask, xK_k     ), windows W.swapUp    )
  138.  
  139.    -- increase or decrease number of windows in the master area
  140.    , ((modMask              , xK_comma ), sendMessage (IncMasterN 1))
  141.    , ((modMask              , xK_period), sendMessage (IncMasterN (-1)))
  142.  
  143.    -- resizing
  144.    , ((modMask,               xK_h     ), sendMessage Shrink)
  145.    , ((modMask,               xK_l     ), sendMessage Expand)
  146.    , ((modMask .|. shiftMask, xK_h     ), sendMessage MirrorShrink)
  147.    , ((modMask .|. shiftMask, xK_l     ), sendMessage MirrorExpand)
  148.  
  149.    -- XF86AudioMute
  150.     , ((0 , 0x1008ff12), spawn "amixer -q set PCM toggle")
  151.     -- XF86AudioLowerVolume
  152.     , ((0 , 0x1008ff11), spawn "amixer -q set PCM 1- unmute")
  153.     -- XF86AudioRaiseVolume
  154.     , ((0 , 0x1008ff13), spawn "amixer -q set PCM 1+ unmute")
  155.     --XF86Launch1 :1008FF41
  156.     , ((0 , 0x1008FF41), windows $ W.greedyView "1-Main")
  157.     --XF86Launch2 :1008FF42
  158.     , ((0 , 0x1008FF42), windows $ W.greedyView "2-Temp")
  159.     --XF86Launch3 :1008FF43
  160.     , ((0 , 0x1008FF43), windows $ W.greedyView "3-Work")
  161.     --XF86Launch4 :1008FF44
  162.     , ((0 , 0x1008FF44), windows $ W.greedyView "4-Misc")
  163.     --XF86Launch5 :1008FF45
  164.     , ((0 , 0x1008FF45), windows $ W.greedyView "5-Msg")
  165.     --XF86Launch6 :1008FF46
  166.     , ((0 , 0x1008FF46), windows $ W.greedyView "6-Media")
  167.  
  168.  
  169.    -- quit, or restart
  170.    , ((modMask .|. shiftMask, xK_q     ), io (exitWith ExitSuccess))
  171.    , ((modMask              , xK_q     ), restart "xmonad" True)
  172.    ]
  173.    ++
  174.    -- mod-[1..9] %! Switch to workspace N
  175.    -- mod-shift-[1..9] %! Move client to workspace N
  176.    [((m .|. modMask, k), windows $ f i)
  177.        | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
  178.        , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  179.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement