summary refs log tree commit diff stats
path: root/tag-xmonad/xmonad/xmonad.hs
blob: 21e197d2fd7b2f03522bdb1bd6faeed9d25f59c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import XMonad
import qualified XMonad.StackSet as W
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Layout.NoBorders
import XMonad.Layout.WindowNavigation
import XMonad.Util.EZConfig
import XMonad.Util.Run(spawnPipe)
import System.Exit
import System.IO
import Data.List(isPrefixOf)

myManageHook :: ManageHook
myManageHook = composeOne
               [ className =? "Firefox" -?> doShift "2"
               , className =? "Pidgin" -?> doShift "3"
               , className =? "nuvolaplayer" -?> doShift "8"
               , className =? "Transmission-gtk" -?> doShift "9"
               , isFullscreen -?> doFullFloat
               , fmap ("mpv" `isPrefixOf`) title -?> doFullFloat
               ]

myKeys c = mkKeymap c $
           [ ("M-S-<Return>", spawn $ XMonad.terminal c)
           , ("M-k", kill)

           , ("M-<Space>", spawn "exec $(dmenu_path | dmenu)")
           , ("M-x M-e", spawn "emacsclient -c")

           , ("M-t",  withFocused $ windows . W.sink)
           , ("M-m",  windows W.focusMaster)
           , ("M-S-m",  windows W.swapMaster)

           , ("M-<R>",    sendMessage $ Go R)
           , ("M-<L>",    sendMessage $ Go L)
           , ("M-<U>",    sendMessage $ Go U)
           , ("M-<D>",    sendMessage $ Go D)
           , ("M-M1-<R>", sendMessage $ Swap R)
           , ("M-M1-<L>", sendMessage $ Swap L)
           , ("M-M1-<U>", sendMessage $ Swap U)
           , ("M-M1-<D>", sendMessage $ Swap D)
           , ("M-C-<R>",  sendMessage $ Move R)
           , ("M-C-<L>",  sendMessage $ Move L)
           , ("M-C-<U>",  sendMessage $ Move U)
           , ("M-C-<D>",  sendMessage $ Move D)

           , ("M-n", windows W.focusDown)
           , ("M-p", windows W.focusUp)
           , ("M-S-n", windows W.swapDown)
           , ("M-S-p", windows W.swapUp)

           , ("M-,", sendMessage (IncMasterN 1))
           , ("M-.", sendMessage (IncMasterN (-1)))

           , ("M-\\", sendMessage NextLayout)
           , ("M-S-\\", setLayout $ XMonad.layoutHook c)

           , ("M-+", sendMessage Shrink)
           , ("M--", sendMessage Expand)

           , ("M-q", broadcastMessage ReleaseResources
                         >> restart "xmonad" True)
           , ("C-M-q", io (exitWith ExitSuccess))
           ] ++

             -- mod-[1..9], Switch to workspace N
             -- mod-shift-[1..9], Move client to workspace N
           [(m ++ k, windows $ f w)
            | (w, k) <- zip (XMonad.workspaces c) (map show [1..9])
            , (m, f) <- [("M-",W.greedyView), ("M-S-",W.shift)]]


main :: IO ()
main = do
  xmproc <-spawnPipe "/usr/bin/xmobar /home/alan/.xmobarrc"
  xmonad $ defaultConfig
             { manageHook = myManageHook <+> manageDocks <+> manageHook defaultConfig
             , layoutHook = smartBorders . avoidStruts  $  layoutHook defaultConfig
             , logHook = dynamicLogWithPP xmobarPP
                         { ppOutput = hPutStrLn xmproc
                         , ppTitle  = xmobarColor "#859900" "" . shorten 200
                         , ppCurrent = xmobarColor "#b58900" "". wrap "[" "]"
                         , ppHiddenNoWindows = xmobarColor "#93a1a1" ""
                         , ppUrgent  = xmobarColor "#dc322f" "#b58900"
                         }
             , terminal = "urxvt"
             , modMask = mod4Mask
             , handleEventHook = fullscreenEventHook
             , keys = myKeys
  }