xmonad.hs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. ]
  42. myManageHook = composeAll . concat $
  43. [ [ className =? c --> doFloat | c <- myFloats]
  44. , [ title =? p --> doFloat | p <- plasmaWindows]
  45. ]
  46. where myFloats = ["Gimp"]
  47. plasmaWindows =
  48. [ "yakuake"
  49. , "Yakuake"
  50. , "Kmix"
  51. , "kmix"
  52. , "plasma"
  53. , "Plasma"
  54. , "plasma-desktop"
  55. , "Plasma-desktop"
  56. , "krunner"
  57. , "ksplashsimple"
  58. , "ksplashqml"
  59. , "ksplashx"
  60. ]
  61. startupList :: [String]
  62. startupList =
  63. [ "owncloud"
  64. , "compton"
  65. ]
  66. startup :: X ()
  67. startup = do
  68. foldl1' (>>) $ map (spawn . ifNotRunning) startupList
  69. -- Wrap a command in Bash that checks if it's running.
  70. ifNotRunning :: String -> String
  71. ifNotRunning s = "if [ `pgrep -c " ++ (basename s) ++ "` == 0 ]; then " ++ s ++ "; fi"
  72. -- Grab the program name from a command (everything up to the space,
  73. -- if there's a space). Doesn't work with escaped spaces.
  74. basename :: String -> String
  75. basename s = case elemIndex ' ' s of
  76. (Just n) -> take n s
  77. Nothing -> s
  78. myKeys = [
  79. -- extra programs
  80. ((mod4Mask, xK_x),
  81. spawn "emacsclient -c")
  82. , ((mod4Mask, xK_z),
  83. spawn "firefox-nightly")
  84. , ((mod4Mask, xK_m),
  85. spawn ":"
  86. -- TODO put social stuff here (Discord, Riot) and open it on a particular workspace
  87. )
  88. ]