haskellxmonadxmobar

How to join those two config parts together?


In my xmonad config I have the following:

main = do 
  xmproc <- spawnPipe "xmobar -x 0 ~.config/xmobar/xmobar.config"
  xmonad $ docks defaults

But having problems with chrome, I need to add this:

import XMonad
import XMonad.Hooks.EwmhDesktops

main = xmonad $ ewmh def{ handleEventHook =
           handleEventHook def <+> fullscreenEventHook }

I am not sure how to combine those two. So to keep the xmobar config, the docks defaults and the ewmh

I tried this

main = do 
  xmproc <- spawnPipe "xmobar -x 0 ~.config/xmobar/xmobar.config"
  xmonad $ ewmh def{ handleEventHook =
           handleEventHook def <+> fullscreenEventHook }

But I need to add docks too.

UPDATE:

Thank you for your suggestion Li-yao Xia. I tried this:

  xmproc <- spawnPipe "xmobar -x 0 ~/.config/xmobar/xmobar.config"
  xmonad $ docks defaults $ ewmh def{ handleEventHook =
     handleEventHook def <+> fullscreenEventHook }

But that gives error

XMonad will use ghc to recompile, because "/home/adam/.xmonad/build" does not exist.
Error detected while loading xmonad configuration file: /home/adam/.xmonad/xmonad.hs

xmonad.hs:273:12: error:
    • Couldn't match expected type ‘XConfig
                                      (Choose Tall (Choose (Mirror Tall) Full))
                                    -> XConfig l0’
                  with actual type ‘XConfig
                                      (XMonad.Layout.LayoutModifier.ModifiedLayout
                                         AvoidStruts (Choose Tall (Choose (Mirror Tall) Full)))’
    • The first argument of ($) takes one argument,
      but its type ‘XConfig
                      (XMonad.Layout.LayoutModifier.ModifiedLayout
                         AvoidStruts (Choose Tall (Choose (Mirror Tall) Full)))’
      has none
      In the second argument of ‘($)’, namely
        ‘docks defaults
           $ ewmh
               def
                 {handleEventHook = handleEventHook def <+> fullscreenEventHook}’
      In a stmt of a 'do' block:
        xmonad
          $ docks defaults
              $ ewmh
                  def {handleEventHook = handleEventHook def <+> fullscreenEventHook}
    |
273 |   xmonad $ docks defaults $ ewmh def{ handleEventHook =
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...

Please check the file for errors.

xmonad: xmessage: executeFile: does not exist (No such file or directory)

Solution

  • Note that docks and ewmh both take a config

    docks :: XConfig a -> XConfig a
    ewmh  :: XConfig a -> XConfig a
    

    they are functions, that can be composed

      xmonad $ docks $ ewmh def{ handleEventHook =
               handleEventHook def <+> fullscreenEventHook }
    

    You also appear to have a custom config defaults :: XConfig a, which you can probably use in place of def (which is the default provided by XMonad itself)

      xmonad $ docks $ ewmh defaults{ handleEventHook =
               handleEventHook defaults <+> fullscreenEventHook }
    
      -- note there are two occurrences of "defaults" here (you definitely want the first one, and the second one matters if defaults and def have different definitions of handleEventHook)