xmonad.hs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import XMonad
  2. import XMonad.Config.Desktop
  3. import XMonad.Hooks.DynamicLog
  4. import XMonad.Hooks.ManageDocks
  5. import XMonad.Util.Run(spawnPipe, hPutStrLn, runProcessWithInput)
  6. -- Layouts
  7. import XMonad.Layout.Spacing(smartSpacing)
  8. import XMonad.Layout.Tabbed
  9. import XMonad.Layout.NoBorders
  10. -- Shutdown commands and keys
  11. import Data.Map(fromList)
  12. import XMonad.Prompt
  13. import XMonad.Prompt.XMonad
  14. import System.Exit(ExitCode(ExitSuccess), exitWith)
  15. import XMonad.Util.EZConfig(additionalKeys, removeKeys)
  16. -- Brightness and audio keys
  17. import Graphics.X11.ExtraTypes.XF86
  18. import Data.List(elemIndex, foldl1')
  19. -- kde
  20. import XMonad.Config.Kde
  21. import XMonad.Hooks.EwmhDesktops
  22. main = do
  23. xmonad $ ewmh $ docks kde4Config
  24. { manageHook = manageHook kdeConfig <+> myManageHook
  25. , layoutHook = smartBorders $ avoidStruts $
  26. (smartSpacing 5 $ withBorder 2 $ Tall 1 (3/100) (1/2)) |||
  27. (smartSpacing 5 $ withBorder 2 $ Mirror (Tall 1 (3/100) (1/2))) |||
  28. -- Full |||
  29. -- Tabs are bugged/don't work in ewmh. On the
  30. -- bright side, it makes a window float over KDE's
  31. -- bar, which is what I want fullscreen to do.
  32. -- It's not a bug, it's a feature.
  33. simpleTabbed
  34. , startupHook = startup
  35. , handleEventHook = handleEventHook def <+> fullscreenEventHook
  36. , modMask = mod4Mask
  37. } `additionalKeys` myKeys `removeKeys` myRemoveKeys
  38. myRemoveKeys =
  39. [ (mod4Mask, xK_Tab)
  40. , (mod4Mask .|. shiftMask, xK_Tab)
  41. , (mod4Mask, xK_p)
  42. ]
  43. myManageHook = composeAll . concat $
  44. [ [ className =? c --> doFloat | c <- myFloats]
  45. , [ title =? p --> doFloat | p <- plasmaWindows]
  46. ]
  47. where myFloats = ["Gimp"]
  48. plasmaWindows =
  49. [ "yakuake"
  50. , "Yakuake"
  51. , "Kmix"
  52. , "kmix"
  53. , "plasma"
  54. , "Plasma"
  55. , "plasma-desktop"
  56. , "Plasma-desktop"
  57. , "krunner"
  58. , "ksplashsimple"
  59. , "ksplashqml"
  60. , "ksplashx"
  61. ]
  62. startupList :: [String]
  63. startupList =
  64. [ "owncloud"
  65. , "compton"
  66. ]
  67. startup :: X ()
  68. startup = do
  69. foldl1' (>>) $ map (spawn . ifNotRunning) startupList
  70. -- Wrap a command in Bash that checks if it's running.
  71. ifNotRunning :: String -> String
  72. ifNotRunning s = "if [ `pgrep -c " ++ (basename s) ++ "` == 0 ]; then " ++ s ++ "; fi"
  73. -- Grab the program name from a command (everything up to the space,
  74. -- if there's a space). Doesn't work with escaped spaces.
  75. basename :: String -> String
  76. basename s = case elemIndex ' ' s of
  77. (Just n) -> take n s
  78. Nothing -> s
  79. myKeys = [
  80. -- extra programs
  81. ((mod4Mask, xK_x),
  82. spawn "emacsclient -c")
  83. , ((mod4Mask, xK_z),
  84. spawn "firefox-nightly")
  85. , ((mod4Mask, xK_m),
  86. spawn ":"
  87. -- TODO put social stuff here (Discord, Riot) and open it on a particular workspace
  88. )
  89. ]