{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
-----------------------------------------------------------------------------
-- |
-- Module      :  XMonad.Config.Arossato
-- Description :  Andrea Rossato's xmonad configuration.
-- Copyright   :  (c) Andrea Rossato 2007
-- License     :  BSD3-style (see LICENSE)
--
-- Maintainer  :  andrea.rossato@unibz.it
-- Stability   :  stable
-- Portability :  portable
--
-- This module specifies my xmonad defaults.
--
------------------------------------------------------------------------

module XMonad.Config.Arossato
    {-# DEPRECATED "This module contains a personal configuration, to be removed from xmonad-contrib.  If you use this module, please copy the relevant parts to your configuration or obtain a copy of it on https://xmonad.org/configurations.html and include it as a local module." #-}
    ( -- * Usage
      -- $usage
      arossatoConfig
    ) where

import qualified Data.Map as M

import XMonad
import qualified XMonad.StackSet as W

import XMonad.Actions.CycleWS
import XMonad.Hooks.DynamicLog hiding (xmobar)
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ServerMode
import XMonad.Layout.Accordion
import XMonad.Layout.Magnifier
import XMonad.Layout.NoBorders
import XMonad.Layout.SimpleFloat
import XMonad.Layout.Tabbed
import XMonad.Layout.WindowArranger
import XMonad.Prompt.Shell
import XMonad.Prompt.Ssh
import XMonad.Prompt.Theme
import XMonad.Prompt.Window
import XMonad.Prompt.XMonad
import XMonad.Util.Run
import XMonad.Util.Themes

-- $usage
-- The simplest way to use this configuration module is to use an
-- @xmonad.hs@ like this:
--
-- > module Main (main) where
-- >
-- > import XMonad
-- > import XMonad.Config.Arossato (arossatoConfig)
-- >
-- > main :: IO ()
-- > main = xmonad =<< arossatoConfig
--
-- NOTE: that I'm using xmobar and, if you don't have xmobar in your
-- PATH, this configuration will produce an error and xmonad will not
-- start. If you don't want to install xmobar get rid of this line at
-- the beginning of 'arossatoConfig'.
--
-- You can use this module also as a starting point for writing your
-- own configuration module from scratch. Save it as your
-- @xmonad.hs@ and:
--
-- 1. Change the module name from
--
-- > module XMonad.Config.Arossato
-- >     ( -- * Usage
-- >       -- $usage
-- >       arossatoConfig
-- >     ) where
--
-- to
--
-- > module Main where
--
-- 2. Add a line like:
--
-- > main = xmonad =<< arossatoConfig
--
-- 3. Start playing with the configuration options...;)

arossatoConfig :: m (XConfig
     (ModifiedLayout
        AvoidStruts
        (Choose
           (ModifiedLayout
              (Decoration SimpleDecoration DefaultShrinker)
              (ModifiedLayout
                 MouseResize (ModifiedLayout WindowArranger SimpleFloat)))
           (Choose
              (ModifiedLayout
                 WithBorder
                 (ModifiedLayout
                    (Decoration TabbedDecoration DefaultShrinker) Simplest))
              (ModifiedLayout
                 WindowArranger
                 (Choose
                    (ModifiedLayout Magnifier Tall)
                    (Choose
                       (ModifiedLayout WithBorder Full)
                       (Choose (Mirror Tall) Accordion))))))))
arossatoConfig = do
    Handle
xmobar <- forall (m :: * -> *). MonadIO m => String -> m Handle
spawnPipe String
"xmobar" -- REMOVE this line if you do not have xmobar installed!
    forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. Default a => a
def
         { workspaces :: [String]
workspaces         = [String
"home",String
"var",String
"dev",String
"mail",String
"web",String
"doc"] forall a. [a] -> [a] -> [a]
++
                                forall a b. (a -> b) -> [a] -> [b]
map forall a. Show a => a -> String
show [Int
7 .. Int
9 :: Int]
         , logHook :: X ()
logHook            = Handle -> X ()
myDynLog Handle
xmobar -- REMOVE this line if you do not have xmobar installed!
         , manageHook :: ManageHook
manageHook         = forall {a} {s} {l} {sd}.
(Ord a, Eq s) =>
Query (Endo (StackSet String l a s sd))
newManageHook
         , layoutHook :: ModifiedLayout
  AvoidStruts
  (Choose
     (ModifiedLayout
        (Decoration SimpleDecoration DefaultShrinker)
        (ModifiedLayout
           MouseResize (ModifiedLayout WindowArranger SimpleFloat)))
     (Choose
        (ModifiedLayout
           WithBorder
           (ModifiedLayout
              (Decoration TabbedDecoration DefaultShrinker) Simplest))
        (ModifiedLayout
           WindowArranger
           (Choose
              (ModifiedLayout Magnifier Tall)
              (Choose
                 (ModifiedLayout WithBorder Full)
                 (Choose (Mirror Tall) Accordion))))))
  Window
layoutHook         = forall (l :: * -> *) a.
LayoutClass l a =>
l a -> ModifiedLayout AvoidStruts l a
avoidStruts forall a b. (a -> b) -> a -> b
$
                                forall {a}.
Eq a =>
ModifiedLayout
  (Decoration SimpleDecoration DefaultShrinker)
  (ModifiedLayout
     MouseResize (ModifiedLayout WindowArranger SimpleFloat))
  a
decorated        forall (l :: * -> *) a (r :: * -> *). l a -> r a -> Choose l r a
|||
                                forall (l :: * -> *).
LayoutClass l Window =>
l Window -> ModifiedLayout WithBorder l Window
noBorders forall {a}.
Eq a =>
ModifiedLayout
  (Decoration TabbedDecoration DefaultShrinker) Simplest a
mytabs forall (l :: * -> *) a (r :: * -> *). l a -> r a -> Choose l r a
|||
                                ModifiedLayout
  WindowArranger
  (Choose
     (ModifiedLayout Magnifier Tall)
     (Choose
        (ModifiedLayout WithBorder Full) (Choose (Mirror Tall) Accordion)))
  Window
otherLays
         , terminal :: String
terminal           = String
"urxvt +sb"
         , normalBorderColor :: String
normalBorderColor  = String
"white"
         , focusedBorderColor :: String
focusedBorderColor = String
"black"
         , keys :: XConfig Layout -> Map (ButtonMask, Window) (X ())
keys               = XConfig Layout -> Map (ButtonMask, Window) (X ())
newKeys
         , handleEventHook :: Event -> X All
handleEventHook    = Event -> X All
serverModeEventHook
         , focusFollowsMouse :: Bool
focusFollowsMouse  = Bool
False
         }
    where
      -- layouts
      mytabs :: ModifiedLayout
  (Decoration TabbedDecoration DefaultShrinker) Simplest a
mytabs    =       forall a s.
(Eq a, Shrinker s) =>
s
-> Theme
-> ModifiedLayout (Decoration TabbedDecoration s) Simplest a
tabbed DefaultShrinker
shrinkText (ThemeInfo -> Theme
theme ThemeInfo
smallClean)
      decorated :: ModifiedLayout
  (Decoration SimpleDecoration DefaultShrinker)
  (ModifiedLayout
     MouseResize (ModifiedLayout WindowArranger SimpleFloat))
  a
decorated = forall a s.
(Eq a, Shrinker s) =>
s
-> Theme
-> ModifiedLayout
     (Decoration SimpleDecoration s)
     (ModifiedLayout
        MouseResize (ModifiedLayout WindowArranger SimpleFloat))
     a
simpleFloat' DefaultShrinker
shrinkText (ThemeInfo -> Theme
theme ThemeInfo
smallClean)
      tiled :: Tall a
tiled     = forall a. Int -> Rational -> Rational -> Tall a
Tall Int
1 (Rational
3forall a. Fractional a => a -> a -> a
/Rational
100) (Rational
1forall a. Fractional a => a -> a -> a
/Rational
2)
      otherLays :: ModifiedLayout
  WindowArranger
  (Choose
     (ModifiedLayout Magnifier Tall)
     (Choose
        (ModifiedLayout WithBorder Full) (Choose (Mirror Tall) Accordion)))
  Window
otherLays = forall (l :: * -> *) a. l a -> ModifiedLayout WindowArranger l a
windowArrange   forall a b. (a -> b) -> a -> b
$
                  forall (l :: * -> *) a. l a -> ModifiedLayout Magnifier l a
magnifier forall {a}. Tall a
tiled forall (l :: * -> *) a (r :: * -> *). l a -> r a -> Choose l r a
|||
                  forall (l :: * -> *).
LayoutClass l Window =>
l Window -> ModifiedLayout WithBorder l Window
noBorders forall a. Full a
Full  forall (l :: * -> *) a (r :: * -> *). l a -> r a -> Choose l r a
|||
                  forall (l :: * -> *) a. l a -> Mirror l a
Mirror forall {a}. Tall a
tiled    forall (l :: * -> *) a (r :: * -> *). l a -> r a -> Choose l r a
|||
                  forall a. Accordion a
Accordion

      -- manageHook
      myManageHook :: Query (Endo (StackSet String l a s sd))
myManageHook  = forall m. Monoid m => [m] -> m
composeAll [ Query String
resource forall a. Eq a => Query a -> a -> Query Bool
=? String
"win"          forall (m :: * -> *) a. (Monad m, Monoid a) => m Bool -> m a -> m a
--> forall s. (s -> s) -> Query (Endo s)
doF (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
W.shift String
"doc") -- xpdf
                                 , Query String
resource forall a. Eq a => Query a -> a -> Query Bool
=? String
"firefox-bin"  forall (m :: * -> *) a. (Monad m, Monoid a) => m Bool -> m a -> m a
--> forall s. (s -> s) -> Query (Endo s)
doF (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
W.shift String
"web")
                                 ]
      newManageHook :: Query (Endo (StackSet String l a s sd))
newManageHook = forall {a} {s} {l} {sd}.
(Ord a, Eq s) =>
Query (Endo (StackSet String l a s sd))
myManageHook

      -- xmobar
      myDynLog :: Handle -> X ()
myDynLog    Handle
h = PP -> X ()
dynamicLogWithPP forall a. Default a => a
def
                      { ppCurrent :: String -> String
ppCurrent = String -> String -> String -> String
xmobarColor String
"yellow" String
"" forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String -> String -> String
wrap String
"[" String
"]"
                      , ppTitle :: String -> String
ppTitle   = String -> String -> String -> String
xmobarColor String
"green"  String
"" forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> String -> String
shorten Int
40
                      , ppVisible :: String -> String
ppVisible = String -> String -> String -> String
wrap String
"(" String
")"
                      , ppOutput :: String -> IO ()
ppOutput  = Handle -> String -> IO ()
hPutStrLn Handle
h
                      }

      -- key bindings stuff
      defKeys :: XConfig Layout -> Map (ButtonMask, Window) (X ())
defKeys    = forall (l :: * -> *).
XConfig l -> XConfig Layout -> Map (ButtonMask, Window) (X ())
keys forall a. Default a => a
def
      delKeys :: XConfig Layout -> Map (ButtonMask, Window) (X ())
delKeys XConfig Layout
x  = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr forall k a. Ord k => k -> Map k a -> Map k a
M.delete           (XConfig Layout -> Map (ButtonMask, Window) (X ())
defKeys XConfig Layout
x) (forall {l :: * -> *}. XConfig l -> [(ButtonMask, Window)]
toRemove XConfig Layout
x)
      newKeys :: XConfig Layout -> Map (ButtonMask, Window) (X ())
newKeys XConfig Layout
x  = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry forall k a. Ord k => k -> a -> Map k a -> Map k a
M.insert) (XConfig Layout -> Map (ButtonMask, Window) (X ())
delKeys XConfig Layout
x) (forall {l :: * -> *}. XConfig l -> [((ButtonMask, Window), X ())]
toAdd    XConfig Layout
x)
      -- remove some of the default key bindings
      toRemove :: XConfig l -> [(ButtonMask, Window)]
toRemove XConfig l
x =
          [ (forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x              , Window
xK_j)
          , (forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x              , Window
xK_k)
          , (forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x              , Window
xK_p)
          , (forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x forall a. Bits a => a -> a -> a
.|. ButtonMask
shiftMask, Window
xK_p)
          , (forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x forall a. Bits a => a -> a -> a
.|. ButtonMask
shiftMask, Window
xK_q)
          , (forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x              , Window
xK_q)
          ] forall a. [a] -> [a] -> [a]
++
          -- I want modMask .|. shiftMask 1-9 to be free!
          [(ButtonMask
shiftMask forall a. Bits a => a -> a -> a
.|. forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x, Window
k) | Window
k <- [Window
xK_1 .. Window
xK_9]]
      -- These are my personal key bindings
      toAdd :: XConfig l -> [((ButtonMask, Window), X ())]
toAdd XConfig l
x   =
          [ ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x              , Window
xK_F12   ), XPConfig -> X ()
xmonadPrompt      forall a. Default a => a
def                 )
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x              , Window
xK_F3    ), XPConfig -> X ()
shellPrompt       forall a. Default a => a
def                 )
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x              , Window
xK_F4    ), XPConfig -> X ()
sshPrompt         forall a. Default a => a
def                 )
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x              , Window
xK_F5    ), XPConfig -> X ()
themePrompt       forall a. Default a => a
def                 )
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x              , Window
xK_F6    ), XPConfig -> WindowPrompt -> XWindowMap -> X ()
windowPrompt forall a. Default a => a
def WindowPrompt
Goto  XWindowMap
allWindows     )
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x              , Window
xK_F7    ), XPConfig -> WindowPrompt -> XWindowMap -> X ()
windowPrompt forall a. Default a => a
def WindowPrompt
Bring XWindowMap
allWindows     )
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x              , Window
xK_comma ), X ()
prevWS                                )
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x              , Window
xK_period), X ()
nextWS                                )
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x              , Window
xK_Right ), (WindowSet -> WindowSet) -> X ()
windows forall i l a s sd. StackSet i l a s sd -> StackSet i l a s sd
W.focusDown                   )
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x              , Window
xK_Left  ), (WindowSet -> WindowSet) -> X ()
windows forall i l a s sd. StackSet i l a s sd -> StackSet i l a s sd
W.focusUp                     )
          -- other stuff: launch some useful utilities
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x              , Window
xK_F2    ), forall (m :: * -> *). MonadIO m => String -> m ()
spawn String
"urxvt -fg white -bg black +sb" )
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x forall a. Bits a => a -> a -> a
.|. ButtonMask
shiftMask, Window
xK_F4    ), forall (m :: * -> *). MonadIO m => String -> m ()
spawn String
"~/bin/dict.sh"                 )
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x forall a. Bits a => a -> a -> a
.|. ButtonMask
shiftMask, Window
xK_F5    ), forall (m :: * -> *). MonadIO m => String -> m ()
spawn String
"~/bin/urlOpen.sh"              )
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x forall a. Bits a => a -> a -> a
.|. ButtonMask
shiftMask, Window
xK_t     ), forall (m :: * -> *). MonadIO m => String -> m ()
spawn String
"~/bin/teaTime.sh"              )
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x              , Window
xK_c     ), X ()
kill                                  )
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x forall a. Bits a => a -> a -> a
.|. ButtonMask
shiftMask, Window
xK_comma ), forall a. Message a => a -> X ()
sendMessage (Int -> IncMasterN
IncMasterN   Int
1 )         )
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x forall a. Bits a => a -> a -> a
.|. ButtonMask
shiftMask, Window
xK_period), forall a. Message a => a -> X ()
sendMessage (Int -> IncMasterN
IncMasterN (-Int
1))         )
          -- commands fo the Magnifier layout
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x forall a. Bits a => a -> a -> a
.|. ButtonMask
controlMask              , Window
xK_plus ), forall a. Message a => a -> X ()
sendMessage MagnifyMsg
MagnifyMore)
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x forall a. Bits a => a -> a -> a
.|. ButtonMask
controlMask              , Window
xK_minus), forall a. Message a => a -> X ()
sendMessage MagnifyMsg
MagnifyLess)
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x forall a. Bits a => a -> a -> a
.|. ButtonMask
controlMask              , Window
xK_o    ), forall a. Message a => a -> X ()
sendMessage MagnifyMsg
ToggleOff  )
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x forall a. Bits a => a -> a -> a
.|. ButtonMask
controlMask forall a. Bits a => a -> a -> a
.|. ButtonMask
shiftMask, Window
xK_o    ), forall a. Message a => a -> X ()
sendMessage MagnifyMsg
ToggleOn   )
          -- windowArranger
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x forall a. Bits a => a -> a -> a
.|. ButtonMask
controlMask              , Window
xK_a    ), forall a. Message a => a -> X ()
sendMessage  WindowArrangerMsg
Arrange           )
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x forall a. Bits a => a -> a -> a
.|. ButtonMask
controlMask forall a. Bits a => a -> a -> a
.|. ButtonMask
shiftMask, Window
xK_a    ), forall a. Message a => a -> X ()
sendMessage  WindowArrangerMsg
DeArrange         )
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x forall a. Bits a => a -> a -> a
.|. ButtonMask
controlMask              , Window
xK_Left ), forall a. Message a => a -> X ()
sendMessage (Int -> WindowArrangerMsg
DecreaseLeft   Int
10))
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x forall a. Bits a => a -> a -> a
.|. ButtonMask
controlMask              , Window
xK_Up   ), forall a. Message a => a -> X ()
sendMessage (Int -> WindowArrangerMsg
DecreaseUp     Int
10))
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x forall a. Bits a => a -> a -> a
.|. ButtonMask
controlMask              , Window
xK_Right), forall a. Message a => a -> X ()
sendMessage (Int -> WindowArrangerMsg
IncreaseRight  Int
10))
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x forall a. Bits a => a -> a -> a
.|. ButtonMask
controlMask              , Window
xK_Down ), forall a. Message a => a -> X ()
sendMessage (Int -> WindowArrangerMsg
IncreaseDown   Int
10))
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x forall a. Bits a => a -> a -> a
.|. ButtonMask
shiftMask                , Window
xK_Left ), forall a. Message a => a -> X ()
sendMessage (Int -> WindowArrangerMsg
MoveLeft       Int
10))
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x forall a. Bits a => a -> a -> a
.|. ButtonMask
shiftMask                , Window
xK_Right), forall a. Message a => a -> X ()
sendMessage (Int -> WindowArrangerMsg
MoveRight      Int
10))
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x forall a. Bits a => a -> a -> a
.|. ButtonMask
shiftMask                , Window
xK_Down ), forall a. Message a => a -> X ()
sendMessage (Int -> WindowArrangerMsg
MoveDown       Int
10))
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x forall a. Bits a => a -> a -> a
.|. ButtonMask
shiftMask                , Window
xK_Up   ), forall a. Message a => a -> X ()
sendMessage (Int -> WindowArrangerMsg
MoveUp         Int
10))
          -- gaps
          , ((forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x                              , Window
xK_b    ), forall a. Message a => a -> X ()
sendMessage  ToggleStruts
ToggleStruts      )

          ] forall a. [a] -> [a] -> [a]
++
          -- Use modMask .|. shiftMask .|. controlMask 1-9 instead
          [( (ButtonMask
m forall a. Bits a => a -> a -> a
.|. forall (l :: * -> *). XConfig l -> ButtonMask
modMask XConfig l
x, Window
k), (WindowSet -> WindowSet) -> X ()
windows forall a b. (a -> b) -> a -> b
$ String -> WindowSet -> WindowSet
f String
i)
           | (String
i, Window
k) <- forall a b. [a] -> [b] -> [(a, b)]
zip (forall (l :: * -> *). XConfig l -> [String]
workspaces XConfig l
x) [Window
xK_1 .. Window
xK_9]
          ,  (String -> WindowSet -> WindowSet
f, ButtonMask
m) <- [(forall s i l a sd.
(Eq s, Eq i) =>
i -> StackSet i l a s sd -> StackSet i l a s sd
W.greedyView, ButtonMask
0), (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
W.shift, ButtonMask
shiftMask forall a. Bits a => a -> a -> a
.|. ButtonMask
controlMask)]
          ]