    -- boilerplate {{{
    {-# LANGUAGE ExistentialQuantification, NoMonomorphismRestriction, TypeSynonymInstances #-}
    {-# OPTIONS_GHC -fno-warn-missing-signatures -fno-warn-type-defaults #-}
    module XMonad.Config.Dmwit where

    -- system imports
    import Control.Applicative
    import Control.Monad
    import Control.Monad.Trans
    import Data.Char
    import Data.List
    import Data.Map (Map, fromList)
    import Data.Ratio
    import Data.Word
    import GHC.Real
    import System.Environment
    import System.Exit
    import System.IO
    import System.Process

    -- xmonad core
    import XMonad
    import XMonad.StackSet hiding (workspaces)

    -- xmonad contrib
    import XMonad.Actions.SpawnOn
    import XMonad.Actions.Warp
    import XMonad.Hooks.DynamicLog
    import XMonad.Hooks.ManageDocks
    import XMonad.Hooks.ManageHelpers
    import XMonad.Layout.Grid
    import XMonad.Layout.IndependentScreens
    import XMonad.Layout.Magnifier
    import XMonad.Layout.NoBorders
    import XMonad.Util.Dzen hiding (x, y)
    import XMonad.Util.SpawnOnce
    -- }}}
    -- volume {{{
    outputOf :: String -> IO String
    outputOf :: String -> IO String
    outputOf s :: String
    s = do
        IO ()
    forall (m :: * -> *). MonadIO m => m ()
    uninstallSignalHandlers
        (hIn :: Handle
    hIn, hOut :: Handle
    hOut, hErr :: Handle
    hErr, p :: ProcessHandle
    p) <- String -> IO (Handle, Handle, Handle, ProcessHandle)
    runInteractiveCommand String
    s
        (Handle -> IO ()) -> [Handle] -> IO ()
    forall (t :: * -> *) (m :: * -> *) a b.
    (Foldable t, Monad m) =>
    (a -> m b) -> t a -> m ()
    mapM_ Handle -> IO ()
    hClose [Handle
    hIn, Handle
    hErr]
        Handle -> IO String
    hGetContents Handle
    hOut IO String -> IO ExitCode -> IO String
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ProcessHandle -> IO ExitCode
    waitForProcess ProcessHandle
    p IO String -> IO () -> IO String
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* IO ()
    forall (m :: * -> *). MonadIO m => m ()
    installSignalHandlers

    geomMean :: Floating a => [a] -> a
    geomMean :: [a] -> a
    geomMean xs :: [a]
    xs = [a] -> a
    forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
    product [a]
    xs a -> a -> a
    forall a. Floating a => a -> a -> a
    ** (a -> a
    forall a. Fractional a => a -> a
    recip (a -> a) -> ([a] -> a) -> [a] -> a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Int -> a
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (Int -> a) -> ([a] -> Int) -> [a] -> a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [a] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length ([a] -> a) -> [a] -> a
    forall a b. (a -> b) -> a -> b
    $ [a]
    xs)

    arithMean :: Floating a => [a] -> a
    arithMean :: [a] -> a
    arithMean xs :: [a]
    xs = [a] -> a
    forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
    sum [a]
    xs a -> a -> a
    forall a. Fractional a => a -> a -> a
    / Int -> a
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral ([a] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length [a]
    xs)

    namedNumbers :: String -> String -> [String]
    namedNumbers n :: String
    n s :: String
    s = do
        String
    l <- String -> [String]
    lines String
    s
        Bool -> [()]
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (String
    sentinel String -> String -> Bool
    forall a. Eq a => [a] -> [a] -> Bool
    `isPrefixOf` String
    l)
        String -> [String]
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Int -> String -> String
    forall a. Int -> [a] -> [a]
    drop (String -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length String
    sentinel) String
    l)
        where sentinel :: String
    sentinel = String
    n String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ " #"

    -- Data.List.Split.splitOn ":", but without involving an extra dependency
    splitColon :: String -> [String]
    splitColon xs :: String
    xs = case (Char -> Bool) -> String -> (String, String)
    forall a. (a -> Bool) -> [a] -> ([a], [a])
    break (Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    ==':') String
    xs of
        (a :: String
    a, ':':b :: String
    b) -> String
    a String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    : String -> [String]
    splitColon String
    b
        (a :: String
    a, _)     -> [String
    a]

    parse :: String -> a
    parse s :: String
    s = [a] -> a
    forall a. Floating a => [a] -> a
    arithMean ([a] -> a) -> [a] -> a
    forall a b. (a -> b) -> a -> b
    $ do
        String
    l <- String -> [String]
    lines String
    s
        Bool -> [()]
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard ("\tVolume: " String -> String -> Bool
    forall a. Eq a => [a] -> [a] -> Bool
    `isPrefixOf` String
    l)
        String
    part <- String -> [String]
    splitColon String
    l
        (n :: a
    n,'%':_) <- ReadS a
    forall a. Read a => ReadS a
    reads String
    part
        a -> [a]
    forall (m :: * -> *) a. Monad m => a -> m a
    return a
    n

    modVolume :: String -> Integer -> IO Double
    modVolume :: String -> Integer -> IO Double
    modVolume kind :: String
    kind n :: Integer
    n = do
        [String]
    is <- String -> String -> [String]
    namedNumbers String
    parseKind (String -> [String]) -> IO String -> IO [String]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> String -> IO String
    outputOf String
    listCommand
        [String] -> (String -> IO String) -> IO ()
    forall (t :: * -> *) (m :: * -> *) a b.
    (Foldable t, Monad m) =>
    t a -> (a -> m b) -> m ()
    forM_ [String]
    is (String -> IO String
    outputOf (String -> IO String) -> (String -> String) -> String -> IO String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> String
    setCommand)
        String -> Double
    forall a. (Floating a, Read a) => String -> a
    parse (String -> Double) -> IO String -> IO Double
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> String -> IO String
    outputOf String
    listCommand
        where
        sign :: String
    sign | Integer
    n Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    > 0 = "+" | Bool
    otherwise = "-"
        ctlKind :: String
    ctlKind      = (Char -> Char) -> String -> String
    forall a b. (a -> b) -> [a] -> [b]
    map (\c :: Char
    c -> if Char
    c Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    == ' ' then '-' else Char
    c) String
    kind
        parseKind :: String
    parseKind    = [String] -> String
    unwords ([String] -> String) -> (String -> [String]) -> String -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (String -> String) -> [String] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map (\(c :: Char
    c:cs :: String
    cs) -> Char -> Char
    toUpper Char
    c Char -> String -> String
    forall a. a -> [a] -> [a]
    : String
    cs) ([String] -> [String])
    -> (String -> [String]) -> String -> [String]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> [String]
    words (String -> String) -> String -> String
    forall a b. (a -> b) -> a -> b
    $ String
    kind
        setCommand :: String -> String
    setCommand i :: String
    i = "pactl set-" String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    ctlKind String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ "-volume " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    i String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ " -- " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    sign String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ Integer -> String
    forall a. Show a => a -> String
    show (Integer -> Integer
    forall a. Num a => a -> a
    abs Integer
    n) String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ "%"
        listCommand :: String
    listCommand  = "pactl list " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    ctlKind String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ "s"
    -- }}}
    -- convenient actions {{{
    centerMouse :: X ()
    centerMouse = Rational -> Rational -> X ()
    warpToWindow (1Rational -> Rational -> Rational
    forall a. Fractional a => a -> a -> a
    /2) (1Rational -> Rational -> Rational
    forall a. Fractional a => a -> a -> a
    /2)
    statusBarMouse :: X ()
    statusBarMouse = ScreenId -> Rational -> Rational -> X ()
    warpToScreen 0 (5Rational -> Rational -> Rational
    forall a. Fractional a => a -> a -> a
    /1600) (5Rational -> Rational -> Rational
    forall a. Fractional a => a -> a -> a
    /1200)
    withScreen :: ScreenId -> (String -> WindowSet -> WindowSet) -> X ()
    withScreen s :: ScreenId
    s f :: String -> WindowSet -> WindowSet
    f = ScreenId -> X (Maybe String)
    screenWorkspace ScreenId
    s X (Maybe String) -> (Maybe String -> X ()) -> X ()
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= (Maybe String -> (String -> X ()) -> X ())
    -> (String -> X ()) -> Maybe String -> X ()
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip Maybe String -> (String -> X ()) -> X ()
    forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
    whenJust ((WindowSet -> WindowSet) -> X ()
    windows ((WindowSet -> WindowSet) -> X ())
    -> (String -> WindowSet -> WindowSet) -> String -> X ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> WindowSet -> WindowSet
    f)

    makeLauncher :: String -> String -> String -> String -> String
    makeLauncher yargs :: String
    yargs run :: String
    run exec :: String
    exec close :: String
    close = [String] -> String
    forall (t :: * -> *) a. Foldable t => t [a] -> [a]
    concat
        ["exe=`yeganesh ", String
    yargs, "` && ", String
    run, " ", String
    exec, "$exe", String
    close]
    launcher :: String
    launcher     = String -> String -> String -> String -> String
    makeLauncher "" "eval" "\"exec " "\""
    termLauncher :: String
    termLauncher = String -> String -> String -> String -> String
    makeLauncher "-p withterm" "exec urxvt -e" "" ""
    viewShift :: i -> StackSet i l a s sd -> StackSet i l a s sd
    viewShift  i :: i
    i = i -> StackSet i l a s sd -> StackSet i l a s sd
    forall s i l a sd.
    (Eq s, Eq i) =>
    i -> StackSet i l a s sd -> StackSet i l a s sd
    view i
    i (StackSet i l a s sd -> StackSet i l a s sd)
    -> (StackSet i l a s sd -> StackSet i l a s sd)
    -> StackSet i l a s sd
    -> StackSet i l a s sd
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . i -> StackSet i l a s sd -> StackSet i l a s sd
    forall a s i l sd.
    (Ord a, Eq s, Eq i) =>
    i -> StackSet i l a s sd -> StackSet i l a s sd
    shift i
    i
    floatAll :: [String] -> Query (Endo WindowSet)
    floatAll     = [Query (Endo WindowSet)] -> Query (Endo WindowSet)
    forall m. Monoid m => [m] -> m
    composeAll ([Query (Endo WindowSet)] -> Query (Endo WindowSet))
    -> ([String] -> [Query (Endo WindowSet)])
    -> [String]
    -> Query (Endo WindowSet)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (String -> Query (Endo WindowSet))
    -> [String] -> [Query (Endo WindowSet)]
    forall a b. (a -> b) -> [a] -> [b]
    map (\s :: String
    s -> Query String
    className Query String -> String -> Query Bool
    forall a. Eq a => Query a -> a -> Query Bool
    =? String
    s Query Bool -> Query (Endo WindowSet) -> Query (Endo WindowSet)
    forall (m :: * -> *) a. (Monad m, Monoid a) => m Bool -> m a -> m a
    --> Query (Endo WindowSet)
    doFloat)
    sinkFocus :: StackSet i l a s sd -> StackSet i l a s sd
    sinkFocus    = StackSet i l a s sd -> Maybe a
    forall i l a s sd. StackSet i l a s sd -> Maybe a
    peek (StackSet i l a s sd -> Maybe a)
    -> (Maybe a -> StackSet i l a s sd -> StackSet i l a s sd)
    -> StackSet i l a s sd
    -> StackSet i l a s sd
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= (StackSet i l a s sd -> StackSet i l a s sd)
    -> (a -> StackSet i l a s sd -> StackSet i l a s sd)
    -> Maybe a
    -> StackSet i l a s sd
    -> StackSet i l a s sd
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe StackSet i l a s sd -> StackSet i l a s sd
    forall a. a -> a
    id a -> StackSet i l a s sd -> StackSet i l a s sd
    forall a i l s sd.
    Ord a =>
    a -> StackSet i l a s sd -> StackSet i l a s sd
    sink
    showMod :: String -> Integer -> X ()
    showMod  k :: String
    k n :: Integer
    n = IO Double -> X Double
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (String -> Integer -> IO Double
    modVolume String
    k Integer
    n) X Double -> (Double -> X ()) -> X ()
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= String -> X ()
    volumeDzen (String -> X ()) -> (Double -> String) -> Double -> X ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> String
    forall a. Show a => a -> String
    show (Integer -> String) -> (Double -> Integer) -> Double -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Double -> Integer
    forall a b. (RealFrac a, Integral b) => a -> b
    round
    volumeDzen :: String -> X ()
    volumeDzen   = DzenConfig -> String -> X ()
    dzenConfig (DzenConfig -> String -> X ()) -> DzenConfig -> String -> X ()
    forall a b. (a -> b) -> a -> b
    $ (ScreenId -> DzenConfig) -> DzenConfig
    onCurr (Int -> Int -> ScreenId -> DzenConfig
    center 170 66) DzenConfig -> DzenConfig -> DzenConfig
    forall (m :: * -> *) a b c.
    Monad m =>
    (a -> m b) -> (b -> m c) -> a -> m c
    >=> String -> DzenConfig
    font "-*-helvetica-*-r-*-*-64-*-*-*-*-*-*-*,-*-terminus-*-*-*-*-64-*-*-*-*-*-*-*"
    -- }}}
    altMask :: KeyMask
    altMask = KeyMask
    mod1Mask
    bright :: String
    bright  = "#80c0ff"
    dark :: String
    dark    = "#13294e"
    -- manage hooks for mplayer {{{
    fullscreen43on169 :: RationalRect
    fullscreen43on169 = RationalRect -> RationalRect
    expand (RationalRect -> RationalRect) -> RationalRect -> RationalRect
    forall a b. (a -> b) -> a -> b
    $ Rational -> Rational -> Rational -> Rational -> RationalRect
    RationalRect 0 (-1Rational -> Rational -> Rational
    forall a. Fractional a => a -> a -> a
    /6) 1 (4Rational -> Rational -> Rational
    forall a. Fractional a => a -> a -> a
    /3) where
        expand :: RationalRect -> RationalRect
    expand (RationalRect x :: Rational
    x y :: Rational
    y w :: Rational
    w h :: Rational
    h) = Rational -> Rational -> Rational -> Rational -> RationalRect
    RationalRect (Rational
    x Rational -> Rational -> Rational
    forall a. Num a => a -> a -> a
    - Rational
    forall a. Fractional a => a
    bwx) (Rational
    y Rational -> Rational -> Rational
    forall a. Num a => a -> a -> a
    - Rational
    forall a. Fractional a => a
    bwy) (Rational
    w Rational -> Rational -> Rational
    forall a. Num a => a -> a -> a
    + 2 Rational -> Rational -> Rational
    forall a. Num a => a -> a -> a
    * Rational
    forall a. Fractional a => a
    bwx) (Rational
    h Rational -> Rational -> Rational
    forall a. Num a => a -> a -> a
    + 2 Rational -> Rational -> Rational
    forall a. Num a => a -> a -> a
    * Rational
    forall a. Fractional a => a
    bwy)
        bwx :: a
    bwx = 2 a -> a -> a
    forall a. Fractional a => a -> a -> a
    / 1920 -- borderwidth
        bwy :: a
    bwy = 2 a -> a -> a
    forall a. Fractional a => a -> a -> a
    / 1080

    fullscreenMPlayer :: Query (Endo WindowSet)
    fullscreenMPlayer = Query String
    className Query String -> String -> Query Bool
    forall a. Eq a => Query a -> a -> Query Bool
    =? "MPlayer" Query Bool -> Query (Endo WindowSet) -> Query (Endo WindowSet)
    forall (m :: * -> *) a. (Monad m, Monoid a) => m Bool -> m a -> m a
    --> do
        Display
    dpy   <- X Display -> Query Display
    forall a. X a -> Query a
    liftX (X Display -> Query Display) -> X Display -> Query Display
    forall a b. (a -> b) -> a -> b
    $ (XConf -> Display) -> X Display
    forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
    asks XConf -> Display
    display
        Window
    win   <- Query Window
    forall r (m :: * -> *). MonadReader r m => m r
    ask
        SizeHints
    hints <- IO SizeHints -> Query SizeHints
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO SizeHints -> Query SizeHints)
    -> IO SizeHints -> Query SizeHints
    forall a b. (a -> b) -> a -> b
    $ Display -> Window -> IO SizeHints
    getWMNormalHints Display
    dpy Window
    win
        case (((Dimension, Dimension), (Dimension, Dimension)) -> Rational)
    -> Maybe ((Dimension, Dimension), (Dimension, Dimension))
    -> Maybe Rational
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ((Dimension, Dimension) -> Rational
    approx ((Dimension, Dimension) -> Rational)
    -> (((Dimension, Dimension), (Dimension, Dimension))
        -> (Dimension, Dimension))
    -> ((Dimension, Dimension), (Dimension, Dimension))
    -> Rational
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ((Dimension, Dimension), (Dimension, Dimension))
    -> (Dimension, Dimension)
    forall a b. (a, b) -> a
    fst) (SizeHints -> Maybe ((Dimension, Dimension), (Dimension, Dimension))
    sh_aspect SizeHints
    hints) of
            Just ( 4 :% 3)  -> ScreenId -> String -> Window -> Query (Endo WindowSet)
    forall a s l sd.
    (Ord a, Eq s) =>
    ScreenId -> String -> a -> Query (Endo (StackSet String l a s sd))
    viewFullOn 0 "5" Window
    win
            Just (16 :% 9)  -> ScreenId -> String -> Window -> Query (Endo WindowSet)
    forall a s l sd.
    (Ord a, Eq s) =>
    ScreenId -> String -> a -> Query (Endo (StackSet String l a s sd))
    viewFullOn 1 "5" Window
    win
            _               -> Query (Endo WindowSet)
    doFloat
        where
        fi :: Dimension -> Double
    fi               = Dimension -> Double
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral :: Dimension -> Double
        approx :: (Dimension, Dimension) -> Rational
    approx (n :: Dimension
    n, d :: Dimension
    d)    = Double -> Double -> Rational
    forall a. RealFrac a => a -> a -> Rational
    approxRational (Dimension -> Double
    fi Dimension
    n Double -> Double -> Double
    forall a. Fractional a => a -> a -> a
    / Dimension -> Double
    fi Dimension
    d) (1Double -> Double -> Double
    forall a. Fractional a => a -> a -> a
    /100)

    operationOn :: (a -> StackSet String l a s sd -> StackSet String l a s sd)
    -> ScreenId
    -> String
    -> a
    -> Query (Endo (StackSet String l a s sd))
    operationOn f :: a -> StackSet String l a s sd -> StackSet String l a s sd
    f s :: ScreenId
    s n :: String
    n w :: a
    w = do
        let ws :: String
    ws = ScreenId -> String -> String
    marshall ScreenId
    s String
    n
        Maybe String
    currws <- X (Maybe String) -> Query (Maybe String)
    forall a. X a -> Query a
    liftX (X (Maybe String) -> Query (Maybe String))
    -> X (Maybe String) -> Query (Maybe String)
    forall a b. (a -> b) -> a -> b
    $ ScreenId -> X (Maybe String)
    screenWorkspace ScreenId
    s
        (StackSet String l a s sd -> StackSet String l a s sd)
    -> Query (Endo (StackSet String l a s sd))
    forall s. (s -> s) -> Query (Endo s)
    doF ((StackSet String l a s sd -> StackSet String l a s sd)
     -> Query (Endo (StackSet String l a s sd)))
    -> (StackSet String l a s sd -> StackSet String l a s sd)
    -> Query (Endo (StackSet String l a s sd))
    forall a b. (a -> b) -> a -> b
    $ String -> StackSet String l a s sd -> StackSet String l a s sd
    forall s i l a sd.
    (Eq s, Eq i) =>
    i -> StackSet i l a s sd -> StackSet i l a s sd
    view String
    ws (StackSet String l a s sd -> StackSet String l a s sd)
    -> (StackSet String l a s sd -> StackSet String l a s sd)
    -> StackSet String l a s sd
    -> StackSet String l a s sd
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (StackSet String l a s sd -> StackSet String l a s sd)
    -> (String -> StackSet String l a s sd -> StackSet String l a s sd)
    -> Maybe String
    -> StackSet String l a s sd
    -> StackSet String l a s sd
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe StackSet String l a s sd -> StackSet String l a s sd
    forall a. a -> a
    id String -> StackSet String l a s sd -> StackSet String l a s sd
    forall s i l a sd.
    (Eq s, Eq i) =>
    i -> StackSet i l a s sd -> StackSet i l a s sd
    view Maybe String
    currws (StackSet String l a s sd -> StackSet String l a s sd)
    -> (StackSet String l a s sd -> StackSet String l a s sd)
    -> StackSet String l a s sd
    -> StackSet String l a s sd
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> a -> StackSet String l a s sd -> StackSet String l a s sd
    forall a s i l sd.
    (Ord a, Eq s, Eq i) =>
    i -> a -> StackSet i l a s sd -> StackSet i l a s sd
    shiftWin String
    ws a
    w (StackSet String l a s sd -> StackSet String l a s sd)
    -> (StackSet String l a s sd -> StackSet String l a s sd)
    -> StackSet String l a s sd
    -> StackSet String l a s sd
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . a -> StackSet String l a s sd -> StackSet String l a s sd
    f a
    w

    viewFullOn :: ScreenId -> String -> a -> Query (Endo (StackSet String l a s sd))
    viewFullOn = (a -> StackSet String l a s sd -> StackSet String l a s sd)
    -> ScreenId
    -> String
    -> a
    -> Query (Endo (StackSet String l a s sd))
    forall a s l sd.
    (Ord a, Eq s) =>
    (a -> StackSet String l a s sd -> StackSet String l a s sd)
    -> ScreenId
    -> String
    -> a
    -> Query (Endo (StackSet String l a s sd))
    operationOn a -> StackSet String l a s sd -> StackSet String l a s sd
    forall a i l s sd.
    Ord a =>
    a -> StackSet i l a s sd -> StackSet i l a s sd
    sink
    centerWineOn :: ScreenId -> String -> a -> Query (Endo (StackSet String l a s sd))
    centerWineOn = (a -> StackSet String l a s sd -> StackSet String l a s sd)
    -> ScreenId
    -> String
    -> a
    -> Query (Endo (StackSet String l a s sd))
    forall a s l sd.
    (Ord a, Eq s) =>
    (a -> StackSet String l a s sd -> StackSet String l a s sd)
    -> ScreenId
    -> String
    -> a
    -> Query (Endo (StackSet String l a s sd))
    operationOn (a
    -> RationalRect
    -> StackSet String l a s sd
    -> StackSet String l a s sd
    forall a i l s sd.
    Ord a =>
    a -> RationalRect -> StackSet i l a s sd -> StackSet i l a s sd
    `XMonad.StackSet.float` Rational -> Rational -> Rational -> Rational -> RationalRect
    RationalRect (79Rational -> Rational -> Rational
    forall a. Fractional a => a -> a -> a
    /960) (-1Rational -> Rational -> Rational
    forall a. Fractional a => a -> a -> a
    /540) (401Rational -> Rational -> Rational
    forall a. Fractional a => a -> a -> a
    /480) (271Rational -> Rational -> Rational
    forall a. Fractional a => a -> a -> a
    /270))
    -- }}}
    -- debugging {{{
    class Show a => PPrint a where
        pprint :: Int -> a -> String
        pprint _ = a -> String
    forall a. Show a => a -> String
    show

    data PPrintable = forall a. PPrint a => P a
    instance Show   PPrintable where show :: PPrintable -> String
    show     (P x :: a
    x) = a -> String
    forall a. Show a => a -> String
    show a
    x
    instance PPrint PPrintable where pprint :: Int -> PPrintable -> String
    pprint n :: Int
    n (P x :: a
    x) = Int -> a -> String
    forall a. PPrint a => Int -> a -> String
    pprint Int
    n a
    x

    record :: String -> Int -> [(String, PPrintable)] -> String
    record :: String -> Int -> [(String, PPrintable)] -> String
    record s :: String
    s n :: Int
    n xs :: [(String, PPrintable)]
    xs = String
    preamble String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String -> [String] -> String
    forall a. [a] -> [[a]] -> [a]
    intercalate String
    newline [String]
    fields String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    postlude where
        indentation :: String
    indentation = '\n' Char -> String -> String
    forall a. a -> [a] -> [a]
    : Int -> Char -> String
    forall a. Int -> a -> [a]
    replicate Int
    n '\t'
        preamble :: String
    preamble    = String
    s String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ " {" String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    indentation
        postlude :: String
    postlude    = String
    indentation String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ "}"
        newline :: String
    newline     = ',' Char -> String -> String
    forall a. a -> [a] -> [a]
    : String
    indentation
        fields :: [String]
    fields      = ((String, PPrintable) -> String)
    -> [(String, PPrintable)] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map (\(name :: String
    name, value :: PPrintable
    value) -> String
    name String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ " = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ Int -> PPrintable -> String
    forall a. PPrint a => Int -> a -> String
    pprint (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    +1) PPrintable
    value) [(String, PPrintable)]
    xs

    instance PPrint a => PPrint (Maybe a) where
        pprint :: Int -> Maybe a -> String
    pprint n :: Int
    n (Just x :: a
    x) = "Just (" String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ Int -> a -> String
    forall a. PPrint a => Int -> a -> String
    pprint Int
    n a
    x String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ ")"
        pprint _ x :: Maybe a
    x        = Maybe a -> String
    forall a. Show a => a -> String
    show Maybe a
    x

    instance PPrint a => PPrint [a] where
        pprint :: Int -> [a] -> String
    pprint _ [] = "[]"
        pprint n :: Int
    n xs :: [a]
    xs = String
    preamble String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String -> [String] -> String
    forall a. [a] -> [[a]] -> [a]
    intercalate String
    newline [String]
    allLines String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    postlude where
            indentation :: String
    indentation = '\n' Char -> String -> String
    forall a. a -> [a] -> [a]
    : Int -> Char -> String
    forall a. Int -> a -> [a]
    replicate Int
    n '\t'
            preamble :: String
    preamble    = "[" String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    indentation
            allLines :: [String]
    allLines    = (a -> String) -> [a] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map (Int -> a -> String
    forall a. PPrint a => Int -> a -> String
    pprint (Int
    nInt -> Int -> Int
    forall a. Num a => a -> a -> a
    +1)) [a]
    xs
            newline :: String
    newline     = ',' Char -> String -> String
    forall a. a -> [a] -> [a]
    : String
    indentation
            postlude :: String
    postlude    = String
    indentation String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ "]"

    instance PPrint Rectangle where
        pprint :: Int -> Rectangle -> String
    pprint n :: Int
    n x :: Rectangle
    x = String -> Int -> [(String, PPrintable)] -> String
    record "Rectangle" Int
    n [
            ("rect_x", Position -> PPrintable
    forall a. PPrint a => a -> PPrintable
    P (Rectangle -> Position
    rect_x Rectangle
    x)),
            ("rect_y", Position -> PPrintable
    forall a. PPrint a => a -> PPrintable
    P (Rectangle -> Position
    rect_y Rectangle
    x)),
            ("rect_width", Dimension -> PPrintable
    forall a. PPrint a => a -> PPrintable
    P (Rectangle -> Dimension
    rect_width Rectangle
    x)),
            ("rect_height", Dimension -> PPrintable
    forall a. PPrint a => a -> PPrintable
    P (Rectangle -> Dimension
    rect_height Rectangle
    x))
            ]

    instance PPrint a => PPrint (Stack a) where
        pprint :: Int -> Stack a -> String
    pprint n :: Int
    n x :: Stack a
    x = String -> Int -> [(String, PPrintable)] -> String
    record "Stack" Int
    n [
            ("focus", a -> PPrintable
    forall a. PPrint a => a -> PPrintable
    P (Stack a -> a
    forall a. Stack a -> a
    XMonad.StackSet.focus Stack a
    x)),
            ("up", [a] -> PPrintable
    forall a. PPrint a => a -> PPrintable
    P (Stack a -> [a]
    forall a. Stack a -> [a]
    up Stack a
    x)),
            ("down", [a] -> PPrintable
    forall a. PPrint a => a -> PPrintable
    P (Stack a -> [a]
    forall a. Stack a -> [a]
    down Stack a
    x))
            ]

    instance (PPrint i, PPrint l, PPrint a) => PPrint (Workspace i l a) where
        pprint :: Int -> Workspace i l a -> String
    pprint n :: Int
    n x :: Workspace i l a
    x = String -> Int -> [(String, PPrintable)] -> String
    record "Workspace" Int
    n [
            ("tag", i -> PPrintable
    forall a. PPrint a => a -> PPrintable
    P (Workspace i l a -> i
    forall i l a. Workspace i l a -> i
    tag Workspace i l a
    x)),
            ("layout", l -> PPrintable
    forall a. PPrint a => a -> PPrintable
    P (Workspace i l a -> l
    forall i l a. Workspace i l a -> l
    layout Workspace i l a
    x)),
            ("stack", Maybe (Stack a) -> PPrintable
    forall a. PPrint a => a -> PPrintable
    P (Workspace i l a -> Maybe (Stack a)
    forall i l a. Workspace i l a -> Maybe (Stack a)
    stack Workspace i l a
    x))
            ]

    instance PPrint ScreenDetail where
        pprint :: Int -> ScreenDetail -> String
    pprint n :: Int
    n x :: ScreenDetail
    x = String -> Int -> [(String, PPrintable)] -> String
    record "SD" Int
    n [("screenRect", Rectangle -> PPrintable
    forall a. PPrint a => a -> PPrintable
    P (ScreenDetail -> Rectangle
    screenRect ScreenDetail
    x))]

    instance (PPrint i, PPrint l, PPrint a, PPrint sid, PPrint sd) => PPrint (XMonad.StackSet.Screen i l a sid sd) where
        pprint :: Int -> Screen i l a sid sd -> String
    pprint n :: Int
    n x :: Screen i l a sid sd
    x = String -> Int -> [(String, PPrintable)] -> String
    record "Screen" Int
    n [
            ("workspace", Workspace i l a -> PPrintable
    forall a. PPrint a => a -> PPrintable
    P (Screen i l a sid sd -> Workspace i l a
    forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
    workspace Screen i l a sid sd
    x)),
            ("screen", sid -> PPrintable
    forall a. PPrint a => a -> PPrintable
    P (Screen i l a sid sd -> sid
    forall i l a sid sd. Screen i l a sid sd -> sid
    screen Screen i l a sid sd
    x)),
            ("screenDetail", sd -> PPrintable
    forall a. PPrint a => a -> PPrintable
    P (Screen i l a sid sd -> sd
    forall i l a sid sd. Screen i l a sid sd -> sd
    screenDetail Screen i l a sid sd
    x))
            ]

    instance (PPrint i, PPrint l, PPrint a, PPrint sid, PPrint sd) => PPrint (StackSet i l a sid sd) where
        pprint :: Int -> StackSet i l a sid sd -> String
    pprint n :: Int
    n x :: StackSet i l a sid sd
    x = String -> Int -> [(String, PPrintable)] -> String
    record "StackSet" Int
    n [
            ("current", Screen i l a sid sd -> PPrintable
    forall a. PPrint a => a -> PPrintable
    P (StackSet i l a sid sd -> Screen i l a sid sd
    forall i l a sid sd. StackSet i l a sid sd -> Screen i l a sid sd
    current StackSet i l a sid sd
    x)),
            ("visible", [Screen i l a sid sd] -> PPrintable
    forall a. PPrint a => a -> PPrintable
    P (StackSet i l a sid sd -> [Screen i l a sid sd]
    forall i l a sid sd. StackSet i l a sid sd -> [Screen i l a sid sd]
    visible StackSet i l a sid sd
    x)),
            ("hidden", [Workspace i l a] -> PPrintable
    forall a. PPrint a => a -> PPrintable
    P (StackSet i l a sid sd -> [Workspace i l a]
    forall i l a sid sd. StackSet i l a sid sd -> [Workspace i l a]
    hidden StackSet i l a sid sd
    x)),
            ("floating", Map a RationalRect -> PPrintable
    forall a. PPrint a => a -> PPrintable
    P (StackSet i l a sid sd -> Map a RationalRect
    forall i l a sid sd. StackSet i l a sid sd -> Map a RationalRect
    floating StackSet i l a sid sd
    x))
            ]

    instance PPrint (Layout a)
    instance PPrint Int
    instance PPrint XMonad.Screen
    instance PPrint Integer
    instance PPrint Position
    instance PPrint Dimension
    instance PPrint Char
    instance PPrint Word64
    instance PPrint ScreenId
    instance (Show a, Show b) => PPrint (Map a b)
    -- }}}
    -- main {{{
    dmwitConfig :: ScreenId
    -> XConfig
         (ModifiedLayout
            Magnifier
            (Choose
               (ModifiedLayout AvoidStruts Grid)
               (ModifiedLayout WithBorder Full)))
    dmwitConfig nScreens :: ScreenId
    nScreens = XConfig
      (ModifiedLayout
         Magnifier
         (Choose
            (ModifiedLayout AvoidStruts Grid)
            (ModifiedLayout WithBorder Full)))
    -> XConfig
         (ModifiedLayout
            Magnifier
            (Choose
               (ModifiedLayout AvoidStruts Grid)
               (ModifiedLayout WithBorder Full)))
    forall (a :: * -> *). XConfig a -> XConfig a
    docks (XConfig
       (ModifiedLayout
          Magnifier
          (Choose
             (ModifiedLayout AvoidStruts Grid)
             (ModifiedLayout WithBorder Full)))
     -> XConfig
          (ModifiedLayout
             Magnifier
             (Choose
                (ModifiedLayout AvoidStruts Grid)
                (ModifiedLayout WithBorder Full))))
    -> XConfig
         (ModifiedLayout
            Magnifier
            (Choose
               (ModifiedLayout AvoidStruts Grid)
               (ModifiedLayout WithBorder Full)))
    -> XConfig
         (ModifiedLayout
            Magnifier
            (Choose
               (ModifiedLayout AvoidStruts Grid)
               (ModifiedLayout WithBorder Full)))
    forall a b. (a -> b) -> a -> b
    $ XConfig (Choose Tall (Choose (Mirror Tall) Full))
    forall a. Default a => a
    def {
        borderWidth :: Dimension
    borderWidth             = 2,
        workspaces :: [String]
    workspaces              = ScreenId -> [String] -> [String]
    withScreens ScreenId
    nScreens ((Integer -> String) -> [Integer] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map Integer -> String
    forall a. Show a => a -> String
    show [1..5]),
        terminal :: String
    terminal                = "urxvt",
        normalBorderColor :: String
    normalBorderColor       = String
    dark,
        focusedBorderColor :: String
    focusedBorderColor      = String
    bright,
        modMask :: KeyMask
    modMask                 = KeyMask
    mod4Mask,
        keys :: XConfig Layout -> Map (KeyMask, Window) (X ())
    keys                    = XConfig Layout -> Map (KeyMask, Window) (X ())
    keyBindings,
        layoutHook :: ModifiedLayout
      Magnifier
      (Choose
         (ModifiedLayout AvoidStruts Grid) (ModifiedLayout WithBorder Full))
      Window
    layoutHook              = Choose
      (ModifiedLayout AvoidStruts Grid)
      (ModifiedLayout WithBorder Full)
      Window
    -> ModifiedLayout
         Magnifier
         (Choose
            (ModifiedLayout AvoidStruts Grid) (ModifiedLayout WithBorder Full))
         Window
    forall (l :: * -> *) a. l a -> ModifiedLayout Magnifier l a
    magnifierOff (Choose
       (ModifiedLayout AvoidStruts Grid)
       (ModifiedLayout WithBorder Full)
       Window
     -> ModifiedLayout
          Magnifier
          (Choose
             (ModifiedLayout AvoidStruts Grid) (ModifiedLayout WithBorder Full))
          Window)
    -> Choose
         (ModifiedLayout AvoidStruts Grid)
         (ModifiedLayout WithBorder Full)
         Window
    -> ModifiedLayout
         Magnifier
         (Choose
            (ModifiedLayout AvoidStruts Grid) (ModifiedLayout WithBorder Full))
         Window
    forall a b. (a -> b) -> a -> b
    $ Grid Window -> ModifiedLayout AvoidStruts Grid Window
    forall (l :: * -> *) a.
    LayoutClass l a =>
    l a -> ModifiedLayout AvoidStruts l a
    avoidStruts (Double -> Grid Window
    forall a. Double -> Grid a
    GridRatio 0.9) ModifiedLayout AvoidStruts Grid Window
    -> ModifiedLayout WithBorder Full Window
    -> Choose
         (ModifiedLayout AvoidStruts Grid)
         (ModifiedLayout WithBorder Full)
         Window
    forall (l :: * -> *) a (r :: * -> *). l a -> r a -> Choose l r a
    ||| Full Window -> ModifiedLayout WithBorder Full Window
    forall (l :: * -> *).
    LayoutClass l Window =>
    l Window -> ModifiedLayout WithBorder l Window
    noBorders Full Window
    forall a. Full a
    Full,
        manageHook :: Query (Endo WindowSet)
    manageHook              =     (Query String
    title Query String -> String -> Query Bool
    forall a. Eq a => Query a -> a -> Query Bool
    =? "CGoban: Main Window" Query Bool -> Query (Endo WindowSet) -> Query (Endo WindowSet)
    forall (m :: * -> *) a. (Monad m, Monoid a) => m Bool -> m a -> m a
    --> (WindowSet -> WindowSet) -> Query (Endo WindowSet)
    forall s. (s -> s) -> Query (Endo s)
    doF WindowSet -> WindowSet
    forall a i l s sd.
    Ord a =>
    StackSet i l a s sd -> StackSet i l a s sd
    sinkFocus)
                                  Query (Endo WindowSet)
    -> Query (Endo WindowSet) -> Query (Endo WindowSet)
    forall m. Monoid m => m -> m -> m
    <+> (Query String
    className Query String -> String -> Query Bool
    forall a. Eq a => Query a -> a -> Query Bool
    =? "Wine" Query Bool -> Query Bool -> Query Bool
    forall (m :: * -> *). Monad m => m Bool -> m Bool -> m Bool
    <&&> (Query String
    appName Query String -> String -> Query Bool
    forall a. Eq a => Query a -> a -> Query Bool
    =? "hl2.exe" Query Bool -> Query Bool -> Query Bool
    forall (m :: * -> *). Monad m => m Bool -> m Bool -> m Bool
    <||> Query String
    appName Query String -> String -> Query Bool
    forall a. Eq a => Query a -> a -> Query Bool
    =? "portal2.exe") Query Bool -> Query (Endo WindowSet) -> Query (Endo WindowSet)
    forall (m :: * -> *) a. (Monad m, Monoid a) => m Bool -> m a -> m a
    --> Query Window
    forall r (m :: * -> *). MonadReader r m => m r
    ask Query Window
    -> (Window -> Query (Endo WindowSet)) -> Query (Endo WindowSet)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= ScreenId -> String -> Window -> Query (Endo WindowSet)
    forall a s l sd.
    (Ord a, Eq s) =>
    ScreenId -> String -> a -> Query (Endo (StackSet String l a s sd))
    viewFullOn {-centerWineOn-} 1 "5")
                                  Query (Endo WindowSet)
    -> Query (Endo WindowSet) -> Query (Endo WindowSet)
    forall m. Monoid m => m -> m -> m
    <+> (Query String
    className Query String -> String -> Query Bool
    forall a. Eq a => Query a -> a -> Query Bool
    =? "VirtualBox" Query Bool -> Query (Endo WindowSet) -> Query (Endo WindowSet)
    forall (m :: * -> *) a. (Monad m, Monoid a) => m Bool -> m a -> m a
    --> Query Window
    forall r (m :: * -> *). MonadReader r m => m r
    ask Query Window
    -> (Window -> Query (Endo WindowSet)) -> Query (Endo WindowSet)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= ScreenId -> String -> Window -> Query (Endo WindowSet)
    forall a s l sd.
    (Ord a, Eq s) =>
    ScreenId -> String -> a -> Query (Endo (StackSet String l a s sd))
    viewFullOn 1 "5")
                                  Query (Endo WindowSet)
    -> Query (Endo WindowSet) -> Query (Endo WindowSet)
    forall m. Monoid m => m -> m -> m
    <+> (Query Bool
    isFullscreen Query Bool -> Query (Endo WindowSet) -> Query (Endo WindowSet)
    forall (m :: * -> *) a. (Monad m, Monoid a) => m Bool -> m a -> m a
    --> Query (Endo WindowSet)
    doFullFloat) -- TF2 matches the "isFullscreen" criteria, so its manage hook should appear after (e.g., to the left of a <+> compared to) this one
                                  Query (Endo WindowSet)
    -> Query (Endo WindowSet) -> Query (Endo WindowSet)
    forall m. Monoid m => m -> m -> m
    <+> (Query String
    appName Query String -> String -> Query Bool
    forall a. Eq a => Query a -> a -> Query Bool
    =? "huludesktop" Query Bool -> Query (Endo WindowSet) -> Query (Endo WindowSet)
    forall (m :: * -> *) a. (Monad m, Monoid a) => m Bool -> m a -> m a
    --> RationalRect -> Query (Endo WindowSet)
    doRectFloat RationalRect
    fullscreen43on169)
                                  Query (Endo WindowSet)
    -> Query (Endo WindowSet) -> Query (Endo WindowSet)
    forall m. Monoid m => m -> m -> m
    <+> Query (Endo WindowSet)
    fullscreenMPlayer
                                  Query (Endo WindowSet)
    -> Query (Endo WindowSet) -> Query (Endo WindowSet)
    forall m. Monoid m => m -> m -> m
    <+> [String] -> Query (Endo WindowSet)
    floatAll ["Gimp", "Wine"]
                                  Query (Endo WindowSet)
    -> Query (Endo WindowSet) -> Query (Endo WindowSet)
    forall m. Monoid m => m -> m -> m
    <+> Query (Endo WindowSet)
    manageSpawn,
        logHook :: X ()
    logHook                 = ScreenId -> X ()
    allPPs ScreenId
    nScreens,
        startupHook :: X ()
    startupHook             = X ()
    refresh
                               X () -> X () -> X ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> (ScreenId -> X ()) -> [ScreenId] -> X ()
    forall (t :: * -> *) (m :: * -> *) a b.
    (Foldable t, Monad m) =>
    (a -> m b) -> t a -> m ()
    mapM_ (String -> X ()
    spawnOnce (String -> X ()) -> (ScreenId -> String) -> ScreenId -> X ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ScreenId -> String
    xmobarCommand) [0 .. ScreenId
    nScreensScreenId -> ScreenId -> ScreenId
    forall a. Num a => a -> a -> a
    -1]
        }

    main :: IO ()
    main = IO ScreenId
    forall (m :: * -> *) i. (MonadIO m, Integral i) => m i
    countScreens IO ScreenId -> (ScreenId -> IO ()) -> IO ()
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= XConfig
      (ModifiedLayout
         Magnifier
         (Choose
            (ModifiedLayout AvoidStruts Grid)
            (ModifiedLayout WithBorder Full)))
    -> IO ()
    forall (l :: * -> *).
    (LayoutClass l Window, Read (l Window)) =>
    XConfig l -> IO ()
    xmonad (XConfig
       (ModifiedLayout
          Magnifier
          (Choose
             (ModifiedLayout AvoidStruts Grid)
             (ModifiedLayout WithBorder Full)))
     -> IO ())
    -> (ScreenId
        -> XConfig
             (ModifiedLayout
                Magnifier
                (Choose
                   (ModifiedLayout AvoidStruts Grid)
                   (ModifiedLayout WithBorder Full))))
    -> ScreenId
    -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ScreenId
    -> XConfig
         (ModifiedLayout
            Magnifier
            (Choose
               (ModifiedLayout AvoidStruts Grid)
               (ModifiedLayout WithBorder Full)))
    dmwitConfig
    -- }}}
    -- keybindings {{{
    keyBindings :: XConfig Layout -> Map (KeyMask, Window) (X ())
    keyBindings conf :: XConfig Layout
    conf = let m :: KeyMask
    m = XConfig Layout -> KeyMask
    forall (l :: * -> *). XConfig l -> KeyMask
    modMask XConfig Layout
    conf in [((KeyMask, Window), X ())] -> Map (KeyMask, Window) (X ())
    forall k a. Ord k => [(k, a)] -> Map k a
    fromList ([((KeyMask, Window), X ())] -> Map (KeyMask, Window) (X ()))
    -> ([((KeyMask, Window), X ())] -> [((KeyMask, Window), X ())])
    -> [((KeyMask, Window), X ())]
    -> Map (KeyMask, Window) (X ())
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [((KeyMask, Window), X ())] -> [((KeyMask, Window), X ())]
    forall b b. [((KeyMask, b), b)] -> [((KeyMask, b), b)]
    anyMask ([((KeyMask, Window), X ())] -> Map (KeyMask, Window) (X ()))
    -> [((KeyMask, Window), X ())] -> Map (KeyMask, Window) (X ())
    forall a b. (a -> b) -> a -> b
    $ [
        ((KeyMask
    m                , Window
    xK_BackSpace  ), String -> X ()
    spawnHere "urxvt"),
        ((KeyMask
    m                , Window
    xK_p          ), String -> X ()
    spawnHere String
    launcher),
        ((KeyMask
    m KeyMask -> KeyMask -> KeyMask
    forall a. Bits a => a -> a -> a
    .|. KeyMask
    shiftMask  , Window
    xK_p          ), String -> X ()
    spawnHere String
    termLauncher),
        ((KeyMask
    m KeyMask -> KeyMask -> KeyMask
    forall a. Bits a => a -> a -> a
    .|. KeyMask
    shiftMask  , Window
    xK_c          ), X ()
    kill),
        ((KeyMask
    m                , Window
    xK_q          ), String -> Bool -> X ()
    restart "xmonad" Bool
    True),
        ((KeyMask
    m KeyMask -> KeyMask -> KeyMask
    forall a. Bits a => a -> a -> a
    .|. KeyMask
    shiftMask  , Window
    xK_q          ), IO () -> X ()
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    io (ExitCode -> IO ()
    forall a. ExitCode -> IO a
    exitWith ExitCode
    ExitSuccess)),
        ((KeyMask
    m                , Window
    xK_grave      ), ChangeLayout -> X ()
    forall a. Message a => a -> X ()
    sendMessage ChangeLayout
    NextLayout),
        ((KeyMask
    m KeyMask -> KeyMask -> KeyMask
    forall a. Bits a => a -> a -> a
    .|. KeyMask
    shiftMask  , Window
    xK_grave      ), Layout Window -> X ()
    setLayout (Layout Window -> X ()) -> Layout Window -> X ()
    forall a b. (a -> b) -> a -> b
    $ XConfig Layout -> Layout Window
    forall (l :: * -> *). XConfig l -> l Window
    layoutHook XConfig Layout
    conf),
        ((KeyMask
    m                , Window
    xK_o          ), MagnifyMsg -> X ()
    forall a. Message a => a -> X ()
    sendMessage MagnifyMsg
    Toggle),
        ((KeyMask
    m                , Window
    xK_x          ), (Window -> X ()) -> X ()
    withFocused ((WindowSet -> WindowSet) -> X ()
    windows ((WindowSet -> WindowSet) -> X ())
    -> (Window -> WindowSet -> WindowSet) -> Window -> X ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Window -> WindowSet -> WindowSet
    forall a i l s sd.
    Ord a =>
    a -> StackSet i l a s sd -> StackSet i l a s sd
    sink)),
        ((KeyMask
    m                , Window
    xK_Home       ), (WindowSet -> WindowSet) -> X ()
    windows WindowSet -> WindowSet
    forall i l a s sd. StackSet i l a s sd -> StackSet i l a s sd
    focusUp),
        ((KeyMask
    m KeyMask -> KeyMask -> KeyMask
    forall a. Bits a => a -> a -> a
    .|. KeyMask
    shiftMask  , Window
    xK_Home       ), (WindowSet -> WindowSet) -> X ()
    windows WindowSet -> WindowSet
    forall i l a s sd. StackSet i l a s sd -> StackSet i l a s sd
    swapUp),
        ((KeyMask
    m                , Window
    xK_End        ), (WindowSet -> WindowSet) -> X ()
    windows WindowSet -> WindowSet
    forall i l a s sd. StackSet i l a s sd -> StackSet i l a s sd
    focusDown),
        ((KeyMask
    m KeyMask -> KeyMask -> KeyMask
    forall a. Bits a => a -> a -> a
    .|. KeyMask
    shiftMask  , Window
    xK_End        ), (WindowSet -> WindowSet) -> X ()
    windows WindowSet -> WindowSet
    forall i l a s sd. StackSet i l a s sd -> StackSet i l a s sd
    swapDown),
        ((KeyMask
    m                , Window
    xK_a          ), (WindowSet -> WindowSet) -> X ()
    windows WindowSet -> WindowSet
    forall i l a s sd. StackSet i l a s sd -> StackSet i l a s sd
    focusMaster),
        ((KeyMask
    m KeyMask -> KeyMask -> KeyMask
    forall a. Bits a => a -> a -> a
    .|. KeyMask
    shiftMask  , Window
    xK_a          ), (WindowSet -> WindowSet) -> X ()
    windows WindowSet -> WindowSet
    forall i l a s sd. StackSet i l a s sd -> StackSet i l a s sd
    swapMaster),
        ((KeyMask
    m                , Window
    xK_Control_L  ), ScreenId -> (String -> WindowSet -> WindowSet) -> X ()
    withScreen 0 String -> WindowSet -> WindowSet
    forall s i l a sd.
    (Eq s, Eq i) =>
    i -> StackSet i l a s sd -> StackSet i l a s sd
    view),
        ((KeyMask
    m KeyMask -> KeyMask -> KeyMask
    forall a. Bits a => a -> a -> a
    .|. KeyMask
    shiftMask  , Window
    xK_Control_L  ), ScreenId -> (String -> WindowSet -> WindowSet) -> X ()
    withScreen 0 String -> WindowSet -> WindowSet
    forall a s i l sd.
    (Ord a, Eq s, Eq i) =>
    i -> StackSet i l a s sd -> StackSet i l a s sd
    viewShift),
        ((KeyMask
    m                , Window
    xK_Alt_L      ), ScreenId -> (String -> WindowSet -> WindowSet) -> X ()
    withScreen 1 String -> WindowSet -> WindowSet
    forall s i l a sd.
    (Eq s, Eq i) =>
    i -> StackSet i l a s sd -> StackSet i l a s sd
    view),
        ((KeyMask
    m KeyMask -> KeyMask -> KeyMask
    forall a. Bits a => a -> a -> a
    .|. KeyMask
    shiftMask  , Window
    xK_Alt_L      ), ScreenId -> (String -> WindowSet -> WindowSet) -> X ()
    withScreen 1 String -> WindowSet -> WindowSet
    forall a s i l sd.
    (Ord a, Eq s, Eq i) =>
    i -> StackSet i l a s sd -> StackSet i l a s sd
    viewShift),
        ((KeyMask
    m                , Window
    xK_u          ), X ()
    centerMouse),
        ((KeyMask
    m KeyMask -> KeyMask -> KeyMask
    forall a. Bits a => a -> a -> a
    .|. KeyMask
    shiftMask  , Window
    xK_u          ), X ()
    statusBarMouse),
        ((KeyMask
    m                , Window
    xK_s          ), String -> X ()
    spawnHere "chromium --password-store=gnome"),
        ((KeyMask
    m                , Window
    xK_n          ), String -> X ()
    spawnHere "gvim todo"),
        ((KeyMask
    m                , Window
    xK_t          ), String -> X ()
    spawnHere "mpc toggle"),
        ((KeyMask
    m                , Window
    xK_h          ), String -> X ()
    spawnHere "urxvt -e alsamixer"),
        ((KeyMask
    m                , Window
    xK_d          ), String -> X ()
    spawnHere "wyvern"),
        ((KeyMask
    m                , Window
    xK_l          ), String -> X ()
    spawnHere "urxvt -e sup"),
        ((KeyMask
    m                , Window
    xK_r          ), String -> X ()
    spawnHere "urxvt -e ncmpcpp"),
        ((KeyMask
    m                , Window
    xK_c          ), String -> X ()
    spawnHere "urxvt -e ghci"),
        ((KeyMask
    m                , Window
    xK_g          ), String -> X ()
    spawnHere "slock" X () -> X () -> X ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> String -> X ()
    spawnHere "xscreensaver-command -lock"),
        ((KeyMask
    m                , Window
    xK_f          ), String -> X ()
    spawnHere "gvim ~/.xmonad/xmonad.hs"),
        ((      KeyMask
    noModMask  , Window
    xK_F8         ), String -> Integer -> X ()
    showMod "sink input" (-4)),
        ((      KeyMask
    noModMask  , Window
    xK_F9         ), String -> Integer -> X ()
    showMod "sink input"   4 ),
        ((      KeyMask
    shiftMask  , Window
    xK_F8         ), String -> Integer -> X ()
    showMod "sink"       (-4)),
        ((      KeyMask
    shiftMask  , Window
    xK_F9         ), String -> Integer -> X ()
    showMod "sink"         4 ),
        ((      KeyMask
    noModMask  , Window
    xK_Super_L    ), () -> X ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()) -- make VirtualBox ignore stray hits of the Windows key
        ] [((KeyMask, Window), X ())]
    -> [((KeyMask, Window), X ())] -> [((KeyMask, Window), X ())]
    forall a. [a] -> [a] -> [a]
    ++ [
        ((KeyMask
    m KeyMask -> KeyMask -> KeyMask
    forall a. Bits a => a -> a -> a
    .|. KeyMask
    e          , Window
    key           ), (WindowSet -> WindowSet) -> X ()
    windows ((String -> WindowSet -> WindowSet)
    -> String -> WindowSet -> WindowSet
    forall a. (String -> WindowSet -> a) -> String -> WindowSet -> a
    onCurrentScreen String -> WindowSet -> WindowSet
    f String
    ws))
        | (key :: Window
    key, ws :: String
    ws) <- [Window] -> [String] -> [(Window, String)]
    forall a b. [a] -> [b] -> [(a, b)]
    zip [Window
    xK_1..Window
    xK_9] (XConfig Layout -> [String]
    forall (l :: * -> *). XConfig l -> [String]
    workspaces' XConfig Layout
    conf)
        , (e :: KeyMask
    e, f :: String -> WindowSet -> WindowSet
    f)    <- [(0, String -> WindowSet -> WindowSet
    forall s i l a sd.
    (Eq s, Eq i) =>
    i -> StackSet i l a s sd -> StackSet i l a s sd
    view), (KeyMask
    shiftMask, String -> WindowSet -> WindowSet
    forall a s i l sd.
    (Ord a, Eq s, Eq i) =>
    i -> StackSet i l a s sd -> StackSet i l a s sd
    viewShift)]
        ]

    atSchool :: b -> b -> m b
    atSchool school :: b
    school home :: b
    home = do
        String
    host <- IO String -> m String
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (String -> IO String
    getEnv "HOST")
        b -> m b
    forall (m :: * -> *) a. Monad m => a -> m a
    return (b -> m b) -> b -> m b
    forall a b. (a -> b) -> a -> b
    $ case String
    host of
            "sorghum"   -> b
    home
            "buckwheat" -> b
    home
            _           -> b
    school

    anyMask :: [((KeyMask, b), b)] -> [((KeyMask, b), b)]
    anyMask xs :: [((KeyMask, b), b)]
    xs = do
        ((mask :: KeyMask
    mask, key :: b
    key), action :: b
    action) <- [((KeyMask, b), b)]
    xs
        KeyMask
    extraMask             <- [0, KeyMask
    controlMask, KeyMask
    altMask, KeyMask
    controlMask KeyMask -> KeyMask -> KeyMask
    forall a. Bits a => a -> a -> a
    .|. KeyMask
    altMask]
        ((KeyMask, b), b) -> [((KeyMask, b), b)]
    forall (m :: * -> *) a. Monad m => a -> m a
    return ((KeyMask
    mask KeyMask -> KeyMask -> KeyMask
    forall a. Bits a => a -> a -> a
    .|. KeyMask
    extraMask, b
    key), b
    action)
    -- }}}
    -- logHook {{{
    pipeName :: String -> a -> String
    pipeName n :: String
    n s :: a
    s = "/home/dmwit/.xmonad/pipe-" String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    n String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ "-" String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ a -> String
    forall a. Show a => a -> String
    show a
    s

    xmobarCommand :: ScreenId -> String
    xmobarCommand (S s :: Int
    s) = [String] -> String
    unwords ["xmobar",
        "-x", Int -> String
    forall a. Show a => a -> String
    show Int
    s,
        "-t", Int -> String
    forall a. (Eq a, Num a) => a -> String
    template Int
    s,
        "-C", String
    pipeReader
        ]
        where
        template :: a -> String
    template 0 = "}%focus%{%workspaces%"
        template _ = "%date%}%focus%{%workspaces%"
        pipeReader :: String
    pipeReader = "'[\
            \Run PipeReader \"" String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String -> Int -> String
    forall a. Show a => String -> a -> String
    pipeName "focus"      Int
    s String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ "\" \"focus\",\
            \Run PipeReader \"" String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String -> Int -> String
    forall a. Show a => String -> a -> String
    pipeName "workspaces" Int
    s String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ "\" \"workspaces\"\
            \]'"

    allPPs :: ScreenId -> X ()
    allPPs nScreens :: ScreenId
    nScreens = [X ()] -> X ()
    forall (t :: * -> *) (m :: * -> *) a.
    (Foldable t, Monad m) =>
    t (m a) -> m ()
    sequence_ [PP -> X ()
    dynamicLogWithPP (ScreenId -> PP
    pp ScreenId
    s) | ScreenId
    s <- [0..ScreenId
    nScreensScreenId -> ScreenId -> ScreenId
    forall a. Num a => a -> a -> a
    -1], ScreenId -> PP
    pp <- [ScreenId -> PP
    ppFocus, ScreenId -> PP
    ppWorkspaces]]
    color :: String -> String -> String
    color c :: String
    c = String -> String -> String -> String
    xmobarColor String
    c ""

    ppFocus :: ScreenId -> PP
    ppFocus s :: ScreenId
    s@(S s_ :: Int
    s_) = ScreenId -> PP -> PP
    whenCurrentOn ScreenId
    s PP
    forall a. Default a => a
    def {
        ppOrder :: [String] -> [String]
    ppOrder  = \(_:_:windowTitle :: String
    windowTitle:_) -> [String
    windowTitle],
        ppOutput :: String -> IO ()
    ppOutput = String -> String -> IO ()
    appendFile (String -> Int -> String
    forall a. Show a => String -> a -> String
    pipeName "focus" Int
    s_) (String -> IO ()) -> (String -> String) -> String -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ "\n")
        }

    ppWorkspaces :: ScreenId -> PP
    ppWorkspaces s :: ScreenId
    s@(S s_ :: Int
    s_) = ScreenId -> PP -> PP
    marshallPP ScreenId
    s PP
    forall a. Default a => a
    def {
        ppCurrent :: String -> String
    ppCurrent           = String -> String -> String
    color "white",
        ppVisible :: String -> String
    ppVisible           = String -> String -> String
    color "white",
        ppHiddenNoWindows :: String -> String
    ppHiddenNoWindows   = String -> String -> String
    color String
    dark,
        ppUrgent :: String -> String
    ppUrgent            = String -> String -> String
    color "red",
        ppSep :: String
    ppSep               = "",
        ppOrder :: [String] -> [String]
    ppOrder             = \(wss :: String
    wss:_layout :: String
    _layout:_title :: String
    _title:_) -> [String
    wss],
        ppOutput :: String -> IO ()
    ppOutput            = String -> String -> IO ()
    appendFile (String -> Int -> String
    forall a. Show a => String -> a -> String
    pipeName "workspaces" Int
    s_) (String -> IO ()) -> (String -> String) -> String -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++"\n")
        }
    -- }}}