    {-# OPTIONS_GHC -fno-warn-missing-signatures #-}

    -----------------------------------------------------------------------------
    -- |
    -- Module       : XMonad.Config.Kde
    -- Copyright    : (c) Spencer Janssen <spencerjanssen@gmail.com>
    -- License      : BSD
    --
    -- Maintainer   : Spencer Janssen <spencerjanssen@gmail.com>
    -- Stability    :  unstable
    -- Portability  :  unportable
    --
    -- This module provides a config suitable for use with the KDE desktop
    -- environment.

    module XMonad.Config.Kde (
        -- * Usage
        -- $usage
        kdeConfig,
        kde4Config,
        desktopLayoutModifiers
        ) where

    import XMonad
    import XMonad.Config.Desktop

    import qualified Data.Map as M

    -- $usage
    -- To use this module, start with the following @~\/.xmonad\/xmonad.hs@:
    --
    -- > import XMonad
    -- > import XMonad.Config.Kde
    -- >
    -- > main = xmonad kdeConfig
    --
    -- For KDE 4, replace 'kdeConfig' with 'kde4Config'
    --
    -- For examples of how to further customize @kdeConfig@ see "XMonad.Config.Desktop".

    kdeConfig :: XConfig
      (ModifiedLayout
         AvoidStruts (Choose Tall (Choose (Mirror Tall) Full)))
    kdeConfig = XConfig
      (ModifiedLayout
         AvoidStruts (Choose Tall (Choose (Mirror Tall) Full)))
    desktopConfig
        { terminal :: String
    terminal = "konsole"
        , keys :: XConfig Layout -> Map (ButtonMask, KeySym) (X ())
    keys     = XConfig Layout -> Map (ButtonMask, KeySym) (X ())
    forall (m :: * -> *) (l :: * -> *).
    MonadIO m =>
    XConfig l -> Map (ButtonMask, KeySym) (m ())
    kdeKeys (XConfig Layout -> Map (ButtonMask, KeySym) (X ()))
    -> (XConfig Layout -> Map (ButtonMask, KeySym) (X ()))
    -> XConfig Layout
    -> Map (ButtonMask, KeySym) (X ())
    forall m. Monoid m => m -> m -> m
    <+> XConfig
      (ModifiedLayout
         AvoidStruts (Choose Tall (Choose (Mirror Tall) Full)))
    -> XConfig Layout -> Map (ButtonMask, KeySym) (X ())
    forall (l :: * -> *).
    XConfig l -> XConfig Layout -> Map (ButtonMask, KeySym) (X ())
    keys XConfig
      (ModifiedLayout
         AvoidStruts (Choose Tall (Choose (Mirror Tall) Full)))
    desktopConfig }

    kde4Config :: XConfig
      (ModifiedLayout
         AvoidStruts (Choose Tall (Choose (Mirror Tall) Full)))
    kde4Config = XConfig
      (ModifiedLayout
         AvoidStruts (Choose Tall (Choose (Mirror Tall) Full)))
    desktopConfig
        { terminal :: String
    terminal = "konsole"
        , keys :: XConfig Layout -> Map (ButtonMask, KeySym) (X ())
    keys     = XConfig Layout -> Map (ButtonMask, KeySym) (X ())
    forall (m :: * -> *) (l :: * -> *).
    MonadIO m =>
    XConfig l -> Map (ButtonMask, KeySym) (m ())
    kde4Keys (XConfig Layout -> Map (ButtonMask, KeySym) (X ()))
    -> (XConfig Layout -> Map (ButtonMask, KeySym) (X ()))
    -> XConfig Layout
    -> Map (ButtonMask, KeySym) (X ())
    forall m. Monoid m => m -> m -> m
    <+> XConfig
      (ModifiedLayout
         AvoidStruts (Choose Tall (Choose (Mirror Tall) Full)))
    -> XConfig Layout -> Map (ButtonMask, KeySym) (X ())
    forall (l :: * -> *).
    XConfig l -> XConfig Layout -> Map (ButtonMask, KeySym) (X ())
    keys XConfig
      (ModifiedLayout
         AvoidStruts (Choose Tall (Choose (Mirror Tall) Full)))
    desktopConfig }

    kdeKeys :: XConfig l -> Map (ButtonMask, KeySym) (m ())
    kdeKeys (XConfig {modMask :: forall (l :: * -> *). XConfig l -> ButtonMask
    modMask = ButtonMask
    modm}) = [((ButtonMask, KeySym), m ())] -> Map (ButtonMask, KeySym) (m ())
    forall k a. Ord k => [(k, a)] -> Map k a
    M.fromList ([((ButtonMask, KeySym), m ())] -> Map (ButtonMask, KeySym) (m ()))
    -> [((ButtonMask, KeySym), m ())]
    -> Map (ButtonMask, KeySym) (m ())
    forall a b. (a -> b) -> a -> b
    $
        [ ((ButtonMask
    modm,               KeySym
    xK_p), String -> m ()
    forall (m :: * -> *). MonadIO m => String -> m ()
    spawn "dcop kdesktop default popupExecuteCommand")
        , ((ButtonMask
    modm ButtonMask -> ButtonMask -> ButtonMask
    forall a. Bits a => a -> a -> a
    .|. ButtonMask
    shiftMask, KeySym
    xK_q), String -> m ()
    forall (m :: * -> *). MonadIO m => String -> m ()
    spawn "dcop kdesktop default logout")
        ]

    kde4Keys :: XConfig l -> Map (ButtonMask, KeySym) (m ())
    kde4Keys (XConfig {modMask :: forall (l :: * -> *). XConfig l -> ButtonMask
    modMask = ButtonMask
    modm}) = [((ButtonMask, KeySym), m ())] -> Map (ButtonMask, KeySym) (m ())
    forall k a. Ord k => [(k, a)] -> Map k a
    M.fromList ([((ButtonMask, KeySym), m ())] -> Map (ButtonMask, KeySym) (m ()))
    -> [((ButtonMask, KeySym), m ())]
    -> Map (ButtonMask, KeySym) (m ())
    forall a b. (a -> b) -> a -> b
    $
        [ ((ButtonMask
    modm,               KeySym
    xK_p), String -> m ()
    forall (m :: * -> *). MonadIO m => String -> m ()
    spawn "krunner")
        , ((ButtonMask
    modm ButtonMask -> ButtonMask -> ButtonMask
    forall a. Bits a => a -> a -> a
    .|. ButtonMask
    shiftMask, KeySym
    xK_q), String -> m ()
    forall (m :: * -> *). MonadIO m => String -> m ()
    spawn "dbus-send --print-reply --dest=org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout int32:1 int32:0 int32:1")
        ]