Want more features on Pastebin? Sign Up, it's FREE!
Guest

xmonad with kde config

By: a guest on Mar 7th, 2013  |  syntax: Haskell  |  size: 5.52 KB  |  views: 188  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. -- XMonad configuration for use with KDE SC 4
  2. -- Features:
  3. --  * KDE integration (including minimizing via panel and floating plasma)
  4. --  * Switching between Tall and Fullscreen with M-f
  5. --  * Toggling Dock with M-<SPC>
  6. --  * Smart borders (i.e. only when needed)
  7. --  * Restoring tiling with M-a
  8. --  * Meta is "Super" or "Windows"
  9. -- TODO: Handle workspaces better
  10. -- TODO: Integrate krunner, too
  11. -- TODO: Improve floating (resizing, maybe even decorations)
  12. import XMonad
  13.  
  14. -- KDE integration
  15. import XMonad.Config.Kde          -- this also does the ewmh stuff
  16. import XMonad.Hooks.ManageDocks
  17. import XMonad.Hooks.SetWMName     -- needed for java stuff
  18.  
  19. -- Layouts and layout modifiers
  20. import XMonad.Layout.Fullscreen
  21. import XMonad.Layout.Minimize
  22. import XMonad.Hooks.Minimize
  23. import XMonad.Layout.NoBorders
  24.  
  25. -- Helpers
  26. import XMonad.Util.EZConfig
  27. import XMonad.Hooks.ManageHelpers -- needed for isFullscreen and doFullFloat
  28. import XMonad.Actions.WithAll     -- needed for sinkAll (i.e. restore tiling)
  29. import qualified XMonad.StackSet as W
  30. import qualified Data.Map        as M
  31.  
  32.  
  33. -- Some layouts to try out
  34. -- import XMonad.Layout.MosaicAlt
  35. import XMonad.Layout.IM
  36. import Data.Ratio ((%))
  37. import XMonad.Layout.Magnifier
  38.  
  39. -- Some layouts I've tried and rejected
  40. -- import XMonad.Layout.Circle        -- Wastes lots of screenspace
  41. -- import XMonad.Layout.Accordion     -- Unusable with more than 5 windows
  42. -- import XMonad.Layout.HintedTile    -- Can't see a difference (Defines Tall - needs hiding in XMonad)
  43. -- import XMonad.Layout.Spiral        -- Not resizable (bummer, since it's quite good)
  44. -- import XMonad.Layout.MagicFocus    -- Broken with KDE
  45. -- import XMonad.Layout.Tabbed        -- Better served with a panel at the side of the screen (more features and less screen waste on a widescreen)
  46. -- import XMonad.Layout.ToggleLayouts -- Not needed
  47.  
  48. --import XMonad.Layout.WindowSwitcherDecoration -- If only I could figure out how to use it without buttons
  49. --import XMonad.Layout.DraggingVisualizer
  50. --import XMonad.Layout.Decoration -- needed for wsd without buttons
  51. --import XMonad.Layout.DecorationAddons -- needed for wsd with buttons
  52. --import XMonad.Util.Themes
  53.  
  54.  
  55. main = do
  56.     xmonad $ kde4Config
  57.         {
  58.         -- TODO: Does order matter?
  59.             modMask = mod4Mask
  60.         ,   startupHook = setWMName "LG3D" <+> startupHook kde4Config
  61.         ,   manageHook = manageHook kde4Config <+> myManageHook <+> manageDocks
  62.         ,   layoutHook = myLayout
  63.         ,   handleEventHook = handleEventHook kde4Config <+> docksEventHook <+> minimizeEventHook
  64.         ,   borderWidth = 1
  65.         ,   mouseBindings = myMouseBindings
  66.         ,   normalBorderColor = myNormalBorderColor
  67.         ,   focusedBorderColor = myFocusedBorderColor
  68.         } `additionalKeysP`
  69.         [ ("M-m", withFocused minimizeWindow)
  70.           , ("M-n", sendMessage RestoreNextMinimizedWin)
  71.           , ("M-a", sinkAll) -- "retile"
  72.           , ("M-c", kill)
  73.           , ("M-x", kill)
  74.           , ("M-f", sendMessage ToggleStruts)
  75.           , ("M-b", spawn "firefox")
  76.           , ("M-e", spawn "dolphin")
  77.           -- This is done by KDE for now (as a dbus call bound to a global hotkey)
  78.           -- , ("M1-C-l", spawn "dbus-send --session --dest=org.freedesktop.ScreenSaver --type=method_call /ScreenSaver -- org.freedesktop.ScreenSaver.Lock")
  79.         ]  
  80.  
  81. myNormalBorderColor  = "#000033"
  82. myFocusedBorderColor = "#ffff00"
  83.  
  84. myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $
  85.  
  86.      -- mod-button1 (Left), Set the window to floating mode and move by dragging
  87.      [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
  88.                                         >> windows W.shiftMaster))
  89.  
  90.      -- mod-button2 (Middle) or mod-shift-button1, Set the window to floating mode and resize by dragging
  91.      , ((modm, button2), (\w -> focus w >> mouseResizeWindow w
  92.                                         >> windows W.shiftMaster))
  93.      , ((modm .|. shiftMask, button1), (\w -> focus w >> mouseResizeWindow w
  94.                                         >> windows W.shiftMaster))
  95.  
  96.      -- mod-button3 (Right), Swap the window with the master
  97.      , ((modm, button3), (\w -> focus w >> windows W.swapMaster))
  98.  
  99.      -- you may also bind events to the mouse scroll wheel (button4 and button5)
  100.      ]
  101.  
  102. myManageHook = composeAll . concat $
  103.     [ [ className   =? c --> doFloat           | c <- classFloats]
  104.     , [ title       =? t --> doFloat           | t <- titleFloats]
  105.     , [ isFullscreen --> doFullFloat ]
  106.     ]
  107.     where classFloats = ["MPlayer", "Gimp", "plasma-desktop", "Plasma-desktop", "plasma", "Plasma", "krunner", "yakuake", "Yakuake", "ksplashsimple", "ksplashqml", "ksplashx"]
  108.           titleFloats = []
  109.        
  110.  
  111. -- TODO: Find spiral with resizable master
  112. myLayout = modifiers (all)
  113.         where tiled = Tall nmaster delta ratio
  114.               nmaster = 1
  115.               delta = 1/100
  116.               ratio = 2/3
  117.               fullfull = fullscreenFull Full
  118.               im       = withIM(1%5) (ClassName "Skype") $ withIM (1%5) (ClassName "Ktp-text-ui") tiled
  119.               -- When I want fullscreen, I usually don't want the panel
  120.               -- TODO: Find a way to set avoidStruts to false (i.e. allow fullfull to toggle struts but have it disabled by default)
  121.               all = avoidStruts(tiled) ||| avoidStruts(im) ||| avoidStrutsOn [] fullfull
  122.               modifiers x = minimize(smartBorders(x))
  123.               --ws l = windowSwitcherDecorationWithButtons shrinkText defaultThemeWithButtons (draggingVisualizer l)
clone this paste RAW Paste Data