xmonad.hs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. -- xmproc <- spawnPipe "xmobar"
  24. xmonad $ ewmh $ docks kde4Config
  25. { manageHook = manageHook kdeConfig <+> myManageHook
  26. -- { manageHook = manageDocks <+> manageHook kdeConfig <+> myManageHook
  27. , layoutHook = smartBorders $ avoidStruts $
  28. (smartSpacing 5 $ withBorder 2 $ Tall 1 (3/100) (1/2)) |||
  29. (smartSpacing 5 $ withBorder 2 $ Mirror (Tall 1 (3/100) (1/2))) |||
  30. -- Full |||
  31. -- Tabs are bugged/don't work in ewmh. On the
  32. -- bright side, it makes a window float over KDE's
  33. -- bar, which is what I want fullscreen to do.
  34. -- It's not a bug, it's a feature.
  35. simpleTabbed
  36. -- , logHook = dynamicLogWithPP xmobarPP
  37. -- { ppOutput = hPutStrLn xmproc
  38. -- , ppTitle = xmobarColor "green" "" . shorten 50
  39. -- }
  40. , startupHook = startup
  41. , handleEventHook = handleEventHook def <+> fullscreenEventHook
  42. , modMask = mod4Mask
  43. } `additionalKeys` myKeys `removeKeys` myRemoveKeys
  44. myRemoveKeys =
  45. [ (mod4Mask, xK_Tab)
  46. , (mod4Mask .|. shiftMask, xK_Tab)
  47. , (mod4Mask, xK_p)
  48. ]
  49. myManageHook = composeAll . concat $
  50. [ [ className =? c --> doFloat | c <- myFloats]
  51. , [ title =? p --> doFloat | p <- plasmaWindows]
  52. ]
  53. where myFloats = ["Gimp"]
  54. plasmaWindows =
  55. [ "yakuake"
  56. , "Yakuake"
  57. , "Kmix"
  58. , "kmix"
  59. , "plasma"
  60. , "Plasma"
  61. , "plasma-desktop"
  62. , "Plasma-desktop"
  63. , "krunner"
  64. , "ksplashsimple"
  65. , "ksplashqml"
  66. , "ksplashx"
  67. ]
  68. startupList :: [String]
  69. startupList =
  70. [ "feh --bg-scale ~/Owncloud/Backgrounds/Xmbindings.png"
  71. -- , "trayer --edge top --align right --SetDockType true --SetPartialStrut true --expand true --width 10 --transparent true --alpha 0 --tint 0x000000 --height 22"
  72. , "compton"
  73. , "owncloud"
  74. ]
  75. startup :: X ()
  76. startup = do
  77. foldl1' (>>) $ map (spawn . ifNotRunning) startupList
  78. -- Wrap a command in Bash that checks if it's running.
  79. ifNotRunning :: String -> String
  80. ifNotRunning s = "if [ `pgrep -c " ++ (basename s) ++ "` == 0 ]; then " ++ s ++ "; fi"
  81. -- Grab the program name from a command (everything up to the space,
  82. -- if there's a space). Doesn't work with escaped spaces.
  83. basename :: String -> String
  84. basename s = case elemIndex ' ' s of
  85. (Just n) -> take n s
  86. Nothing -> s
  87. myKeys = [
  88. -- extra programs
  89. ((mod4Mask, xK_x),
  90. spawn "emacsclient -c")
  91. , ((mod4Mask, xK_z),
  92. spawn "firefox-nightly")
  93. , ((mod4Mask, xK_m),
  94. spawn ":"
  95. -- TODO put social stuff here (Discord, Riot) and open it on a particular workspace
  96. )
  97. ]