Personal tools

Xmonad/Config archive/Nnoell's xmonad.hs

From HaskellWiki

< Xmonad | Config archive(Difference between revisions)
Jump to: navigation, search
(update version)
(12 intermediate revisions by one user not shown)
Line 3: Line 3:
 
<haskell>
 
<haskell>
 
--------------------------------------------------------------------------------------------
 
--------------------------------------------------------------------------------------------
-- ~/.xmonad/xmonad.hs --
+
-- File : ~/.xmonad/xmonad.hs --
-- Author: Nnoell <nnoell3[at]gmail.com> --
+
-- Author : Nnoell <nnoell3[at]gmail.com> --
  +
-- Deps : DzenBoxLogger.hs --
  +
-- Desc : My XMonad config --
  +
-- Note : Do not use "xmonad --recompile", it will throw errors because of non-official --
  +
-- modules. Compile it manually with "ghc -o <outputName> xmonad.hs". EG: --
  +
-- $ cd ~/.xmonad/ --
  +
-- $ ghc -o xmonad-x86_64-linux xmonad.hs --
 
--------------------------------------------------------------------------------------------
 
--------------------------------------------------------------------------------------------
   
-- Language
+
-- Options
{-# LANGUAGE DeriveDataTypeable, NoMonomorphismRestriction, TypeSynonymInstances, MultiParamTypeClasses, ImplicitParams, PatternGuards #-}
+
{-# LANGUAGE DeriveDataTypeable, NoMonomorphismRestriction, MultiParamTypeClasses, ImplicitParams #-}
   
 
-- Modules
 
-- Modules
 
import XMonad
 
import XMonad
import XMonad.Core
+
import XMonad.StackSet (RationalRect(..), currentTag)
 
import XMonad.Layout
 
import XMonad.Layout
 
import XMonad.Layout.IM
 
import XMonad.Layout.IM
import XMonad.Layout.Gaps
 
 
import XMonad.Layout.Named
 
import XMonad.Layout.Named
 
import XMonad.Layout.Tabbed
 
import XMonad.Layout.Tabbed
Line 24: Line 23:
 
import XMonad.Layout.NoFrillsDecoration
 
import XMonad.Layout.NoFrillsDecoration
 
import XMonad.Layout.SimplestFloat
 
import XMonad.Layout.SimplestFloat
import XMonad.Layout.NoBorders (noBorders,smartBorders,withBorder)
+
import XMonad.Layout.NoBorders
 
import XMonad.Layout.ResizableTile
 
import XMonad.Layout.ResizableTile
 
import XMonad.Layout.MultiToggle
 
import XMonad.Layout.MultiToggle
Line 31: Line 30:
 
import XMonad.Layout.Minimize
 
import XMonad.Layout.Minimize
 
import XMonad.Layout.Maximize
 
import XMonad.Layout.Maximize
  +
import XMonad.Layout.ToggleLayouts
  +
import XMonad.Layout.ComboP
  +
import XMonad.Layout.MagicFocus
 
import XMonad.Layout.WindowNavigation
 
import XMonad.Layout.WindowNavigation
import XMonad.StackSet (RationalRect (..), currentTag)
+
import XMonad.Layout.WindowSwitcherDecoration
  +
import XMonad.Layout.DraggingVisualizer
 
import XMonad.Hooks.DynamicLog
 
import XMonad.Hooks.DynamicLog
 
import XMonad.Hooks.DynamicHooks
 
import XMonad.Hooks.DynamicHooks
Line 47: Line 49:
 
import XMonad.Util.Cursor
 
import XMonad.Util.Cursor
 
import XMonad.Util.Loggers
 
import XMonad.Util.Loggers
import XMonad.Util.EZConfig
 
 
import XMonad.Util.Run (spawnPipe)
 
import XMonad.Util.Run (spawnPipe)
 
import XMonad.Util.Scratchpad
 
import XMonad.Util.Scratchpad
Line 55: Line 56:
 
import XMonad.Actions.GridSelect
 
import XMonad.Actions.GridSelect
 
import XMonad.Actions.MouseResize
 
import XMonad.Actions.MouseResize
import Data.IORef
+
import XMonad.Actions.FloatKeys
 
import Data.Monoid
 
import Data.Monoid
 
import Data.List
 
import Data.List
Line 61: Line 62:
 
import System.Exit
 
import System.Exit
 
import System.IO (Handle, hPutStrLn)
 
import System.IO (Handle, hPutStrLn)
  +
import Control.Concurrent (threadDelay)
 
import Control.Exception as E
 
import Control.Exception as E
 
import qualified XMonad.StackSet as W
 
import qualified XMonad.StackSet as W
Line 67: Line 69:
 
import qualified XMonad.Util.ExtensibleState as XS
 
import qualified XMonad.Util.ExtensibleState as XS
   
  +
-- Non-official modules
  +
import DzenBoxLoggers
  +
  +
  +
--------------------------------------------------------------------------------------------
  +
-- MAIN --
  +
--------------------------------------------------------------------------------------------
   
-- Main
 
 
main :: IO ()
 
main :: IO ()
 
main = do
 
main = do
spawn "/home/nnoell/bin/cpuUsage.sh 0"
+
topLeftBar <- spawnPipe $ dzenFlagsToStr dzenTopLeftFlags
spawn "/home/nnoell/bin/cpuUsage.sh 1"
+
topRightBar <- spawnPipe $ dzenFlagsToStr dzenTopRightFlags
spawn "/home/nnoell/bin/cpuUsage.sh 2"
+
botLeftBar <- spawnPipe $ dzenFlagsToStr dzenBotLeftFlags
spawn "/home/nnoell/bin/cpuUsage.sh 3"
+
botRightBar <- spawnPipe $ dzenFlagsToStr dzenBotRightFlags
topLeftBar <- spawnPipe myTopLeftBar
 
topRightBar <- spawnPipe myTopRightBar
 
botLeftBar <- spawnPipe myBotLeftBar
 
botRightBar <- spawnPipe myBotRightBar
 
focusFollow <- newIORef True; let ?focusFollow = focusFollow
 
 
xmonad $ myUrgencyHook $ defaultConfig
 
xmonad $ myUrgencyHook $ defaultConfig
{ terminal = "urxvtc"
+
{ terminal = "urxvtc" --default terminal
, modMask = mod4Mask
+
, modMask = mod4Mask --default modMask
, focusFollowsMouse = False
+
, focusFollowsMouse = True --focus follow config
, borderWidth = 1
+
, clickJustFocuses = True --focus click config
, normalBorderColor = myNormalBorderColor
+
, borderWidth = 1 --border width
, focusedBorderColor = myFocusedBorderColor
+
, normalBorderColor = colorBlackAlt --border color
, layoutHook = myLayoutHook
+
, focusedBorderColor = colorWhiteAlt2 --focused border color
, workspaces = myWorkspaces
+
, workspaces = myWorkspaces --workspace names
, manageHook = myManageHook <+> manageScratchPad <+> manageDocks <+> dynamicMasterHook
+
, startupHook = myStartupHook --autostart config
, logHook = myLogHook botLeftBar <+> myLogHook1 botRightBar <+> myLogHook2 topLeftBar <+> myLogHook3 topRightBar <+> ewmhDesktopsLogHook >> setWMName "LG3D"
+
, handleEventHook = myHandleEventHook --event config
, handleEventHook = myHandleEventHook
+
, layoutHook = myLayoutHook --layout config
, keys = myKeys
+
, manageHook = myManageHook --xprop config
, mouseBindings = myMouseBindings
+
, logHook = do --status bar config
, startupHook = (startTimer 1 >>= XS.put . TID) <+> setDefaultCursor xC_left_ptr >> setWMName "LG3D"
+
myTopLeftLogHook topLeftBar --top left dzen
  +
myTopRightLogHook topRightBar --top right dzen
  +
myBotLeftLogHook botLeftBar --bottom left dzen
  +
myBotRightLogHook botRightBar --bottom right dzen
  +
ewmhDesktopsLogHook
  +
setWMName "LG3D"
  +
, keys = myKeys --key bindings config
  +
, mouseBindings = myMouseBindings --mouse bindings config
 
}
 
}
`additionalKeysP`
 
[ ("<XF86TouchpadToggle>", spawn $ myBinPath ++ "touchpadtoggle.sh") --because xF86XK_TouchpadToggle doesnt exist
 
, ("M-v", io $ modifyIORef ?focusFollow not) --Toggle focus follow moouse
 
]
 
   
   
 
--------------------------------------------------------------------------------------------
 
--------------------------------------------------------------------------------------------
-- APPEARANCE CONFIG --
+
-- LOOK AND FEEL CONFIG --
 
--------------------------------------------------------------------------------------------
 
--------------------------------------------------------------------------------------------
   
 
-- Colors, fonts and paths
 
-- Colors, fonts and paths
dzenFont = "-*-montecarlo-medium-r-normal-*-11-*-*-*-*-*-*-*"
+
dzenFont = "-*-montecarlo-medium-r-normal-*-11-*-*-*-*-*-*-*"
colorBlack = "#020202" --Background (Dzen_BG)
+
colorBlack = "#020202" --Background
colorBlackAlt = "#1c1c1c" --Black Xdefaults
+
colorBlackAlt = "#1c1c1c" --Black Xdefaults
colorGray = "#444444" --Gray (Dzen_FG2)
+
colorGray = "#444444" --Gray
colorGrayAlt = "#101010" --Gray dark
+
colorGrayAlt = "#101010" --Gray dark
colorWhite = "#a9a6af" --Foreground (Shell_FG)
+
colorGrayAlt2 = "#404040"
colorWhiteAlt = "#9d9d9d" --White dark (Dzen_FG)
+
colorGrayAlt3 = "#252525"
colorMagenta = "#8e82a2"
+
colorWhite = "#a9a6af" --Foreground
colorBlue = "#44aacc"
+
colorWhiteAlt = "#9d9d9d" --White dark
colorBlueAlt = "#3955c4"
+
colorWhiteAlt2 = "#b5b3b3"
colorRed = "#e0105f"
+
colorWhiteAlt3 = "#707070"
colorGreen = "#66ff66"
+
colorMagenta = "#8e82a2"
colorGreenAlt = "#558965"
+
colorBlue = "#44aacc"
myNormalBorderColor = colorBlackAlt
+
colorBlueAlt = "#3955c4"
myFocusedBorderColor = colorGray
+
colorRed = "#f7a16e"
myIconPath = "/home/nnoell/.icons/xbm_icons/subtle/"
+
colorRedAlt = "#e0105f"
myBinPath = "/home/nnoell/bin/"
+
colorGreen = "#66ff66"
xRes = 1366
+
colorGreenAlt = "#558965"
yRes = 768
+
boxLeftIcon = "/home/nnoell/.icons/xbm_icons/subtle/boxleft.xbm" --left icon of dzen logger boxes
panelHeight = 16
+
boxLeftIcon2 = "/home/nnoell/.icons/xbm_icons/subtle/boxleft2.xbm" --left icon2 of dzen logger boxes
panelBoxHeight = 12
+
boxRightIcon = "/home/nnoell/.icons/xbm_icons/subtle/boxright.xbm" --right icon of dzen logger boxes
  +
xRes = 1366
  +
yRes = 768
  +
panelHeight = 14 --height of top and bottom panels
  +
boxHeight = 14 --height of dzen logger box
  +
topPanelSepPos = 950 --left-right alignment pos of top panel
  +
botPanelSepPos = 400 --left-right alignment pos of bottom panel
   
 
-- Title theme
 
-- Title theme
Line 128: Line 132:
 
myTitleTheme = defaultTheme
 
myTitleTheme = defaultTheme
 
{ fontName = dzenFont
 
{ fontName = dzenFont
, inactiveBorderColor = colorBlackAlt
+
, inactiveBorderColor = colorGrayAlt2
, inactiveColor = colorBlack
+
, inactiveColor = colorGrayAlt3
, inactiveTextColor = colorGray
+
, inactiveTextColor = colorWhiteAlt3
, activeBorderColor = colorGray
+
, activeBorderColor = colorGrayAlt2
, activeColor = colorBlackAlt
+
, activeColor = colorGrayAlt2
, activeTextColor = colorWhiteAlt
+
, activeTextColor = colorWhiteAlt2
 
, urgentBorderColor = colorGray
 
, urgentBorderColor = colorGray
 
, urgentTextColor = colorGreen
 
, urgentTextColor = colorGreen
Line 142: Line 146:
 
myXPConfig :: XPConfig
 
myXPConfig :: XPConfig
 
myXPConfig = defaultXPConfig
 
myXPConfig = defaultXPConfig
{ font = dzenFont
+
{ font = dzenFont
, bgColor = colorBlack
+
, bgColor = colorBlack
, fgColor = colorWhite
+
, fgColor = colorWhite
, bgHLight = colorBlue
+
, bgHLight = colorBlue
, fgHLight = colorBlack
+
, fgHLight = colorBlack
, borderColor = colorGrayAlt
+
, borderColor = colorGrayAlt
, promptBorderWidth = 1
+
, promptBorderWidth = 1
, height = 16
+
, height = panelHeight
, position = Top
+
, position = Top
, historySize = 100
+
, historySize = 100
, historyFilter = deleteConsecutive
+
, historyFilter = deleteConsecutive
, autoComplete = Nothing
+
, autoComplete = Nothing
 
}
 
}
   
Line 159: Line 163:
 
myColorizer :: Window -> Bool -> X (String, String)
 
myColorizer :: Window -> Bool -> X (String, String)
 
myColorizer = colorRangeFromClassName
 
myColorizer = colorRangeFromClassName
(0x00,0x00,0x00) -- lowest inactive bg
+
(0x00,0x00,0x00) --lowest inactive bg
(0x1C,0x1C,0x1C) -- highest inactive bg
+
(0x1C,0x1C,0x1C) --highest inactive bg
(0x44,0xAA,0xCC) -- active bg
+
(0x44,0xAA,0xCC) --active bg
(0xBB,0xBB,0xBB) -- inactive fg
+
(0xBB,0xBB,0xBB) --inactive fg
(0x00,0x00,0x00) -- active fg
+
(0x00,0x00,0x00) --active fg
   
 
-- GridSelect theme
 
-- GridSelect theme
Line 174: Line 178:
 
}
 
}
   
  +
-- Flash text config
 
myTextConfig :: ShowTextConfig
 
myTextConfig :: ShowTextConfig
 
myTextConfig = STC
 
myTextConfig = STC
 
{ st_font = dzenFont
 
{ st_font = dzenFont
, st_bg = colorBlack
+
, st_bg = colorBlack
, st_fg = colorWhite
+
, st_fg = colorWhite
}
+
}
   
-- Workspaces
+
-- Dzen logger box pretty printing themes
  +
gray2BoxPP :: BoxPP
  +
gray2BoxPP = BoxPP
  +
{ bgColorBPP = colorBlack
  +
, fgColorBPP = colorGray
  +
, boxColorBPP = colorGrayAlt
  +
, leftIconBPP = boxLeftIcon2
  +
, rightIconBPP = boxRightIcon
  +
, boxHeightBPP = boxHeight
  +
}
  +
  +
blueBoxPP :: BoxPP
  +
blueBoxPP = BoxPP
  +
{ bgColorBPP = colorBlack
  +
, fgColorBPP = colorBlue
  +
, boxColorBPP = colorGrayAlt
  +
, leftIconBPP = boxLeftIcon
  +
, rightIconBPP = boxRightIcon
  +
, boxHeightBPP = boxHeight
  +
}
  +
  +
blue2BoxPP :: BoxPP
  +
blue2BoxPP = BoxPP
  +
{ bgColorBPP = colorBlack
  +
, fgColorBPP = colorBlue
  +
, boxColorBPP = colorGrayAlt
  +
, leftIconBPP = boxLeftIcon2
  +
, rightIconBPP = boxRightIcon
  +
, boxHeightBPP = boxHeight
  +
}
  +
  +
whiteBoxPP :: BoxPP
  +
whiteBoxPP = BoxPP
  +
{ bgColorBPP = colorBlack
  +
, fgColorBPP = colorWhiteAlt
  +
, boxColorBPP = colorGrayAlt
  +
, leftIconBPP = boxLeftIcon
  +
, rightIconBPP = boxRightIcon
  +
, boxHeightBPP = boxHeight
  +
}
  +
  +
blackBoxPP :: BoxPP
  +
blackBoxPP = BoxPP
  +
{ bgColorBPP = colorBlack
  +
, fgColorBPP = colorBlack
  +
, boxColorBPP = colorGrayAlt
  +
, leftIconBPP = boxLeftIcon
  +
, rightIconBPP = boxRightIcon
  +
, boxHeightBPP = boxHeight
  +
}
  +
  +
white2BBoxPP :: BoxPP
  +
white2BBoxPP = BoxPP
  +
{ bgColorBPP = colorBlack
  +
, fgColorBPP = colorBlack
  +
, boxColorBPP = colorWhiteAlt
  +
, leftIconBPP = boxLeftIcon2
  +
, rightIconBPP = boxRightIcon
  +
, boxHeightBPP = boxHeight
  +
}
  +
  +
blue2BBoxPP :: BoxPP --current workspace
  +
blue2BBoxPP = BoxPP
  +
{ bgColorBPP = colorBlack
  +
, fgColorBPP = colorBlack
  +
, boxColorBPP = colorBlue
  +
, leftIconBPP = boxLeftIcon2
  +
, rightIconBPP = boxRightIcon
  +
, boxHeightBPP = boxHeight
  +
}
  +
  +
green2BBoxPP :: BoxPP --urgent workspace
  +
green2BBoxPP = BoxPP
  +
{ bgColorBPP = colorBlack
  +
, fgColorBPP = colorBlack
  +
, boxColorBPP = colorGreen
  +
, leftIconBPP = boxLeftIcon2
  +
, rightIconBPP = boxRightIcon
  +
, boxHeightBPP = boxHeight
  +
}
  +
  +
-- Dzen logger clickable areas
  +
calendarCA :: CA
  +
calendarCA = CA
  +
{ leftClickCA = "/home/nnoell/bin/dzencal.sh"
  +
, middleClickCA = "/home/nnoell/bin/dzencal.sh"
  +
, rightClickCA = "/home/nnoell/bin/dzencal.sh"
  +
, wheelUpCA = "/home/nnoell/bin/dzencal.sh"
  +
, wheelDownCA = "/home/nnoell/bin/dzencal.sh"
  +
}
  +
  +
layoutCA :: CA
  +
layoutCA = CA
  +
{ leftClickCA = "/usr/bin/xdotool key super+space"
  +
, middleClickCA = "/usr/bin/xdotool key super+v"
  +
, rightClickCA = "/usr/bin/xdotool key super+shift+space"
  +
, wheelUpCA = "/usr/bin/xdotool key super+f"
  +
, wheelDownCA = "/usr/bin/xdotool key super+control+f"
  +
}
  +
  +
workspaceCA :: CA
  +
workspaceCA = CA
  +
{ leftClickCA = "/usr/bin/xdotool key super+1"
  +
, middleClickCA = "/usr/bin/xdotool key super+g"
  +
, rightClickCA = "/usr/bin/xdotool key super+0"
  +
, wheelUpCA = "/usr/bin/xdotool key ctrl+alt+Right"
  +
, wheelDownCA = "/usr/bin/xdotool key ctrl+alt+Left"
  +
}
  +
  +
focusCA :: CA
  +
focusCA = CA
  +
{ leftClickCA = "/usr/bin/xdotool key super+m"
  +
, middleClickCA = "/usr/bin/xdotool key super+c"
  +
, rightClickCA = "/usr/bin/xdotool key super+shift+m"
  +
, wheelUpCA = "/usr/bin/xdotool key super+shift+j"
  +
, wheelDownCA = "/usr/bin/xdotool key super+shift+k"
  +
}
  +
  +
-- Workspace index
 
myWorkspaces :: [WorkspaceId]
 
myWorkspaces :: [WorkspaceId]
myWorkspaces = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
+
myWorkspaces = map show $ [1..9] ++ [0]
  +
  +
-- Workspace names
  +
workspaceNames :: [WorkspaceId]
  +
workspaceNames = ["Terminal"
  +
, "Network"
  +
, "Development"
  +
, "Graphics"
  +
, "Chatting"
  +
, "Video"
  +
, "Alternate"
  +
, "Alternate"
  +
, "Alternate"
  +
, "Alternate"
  +
]
  +
  +
-- Layout names (must be one word name and not equal to: Mirror, ReflectX, ReflectY, Switcher, Normal and Unique)
  +
myTileName = "Tiled"
  +
myMirrName = "Mirror"
  +
myMosAName = "Mosaic"
  +
myOneBName = "OneBig"
  +
myMTabName = "MstrTab"
  +
myChatName = "Chat"
  +
myTabbName = "Tabbed"
  +
myTTabName = "TwoTab"
  +
myFTabName = "Full"
  +
myFloaName = "Float"
   
   
 
--------------------------------------------------------------------------------------------
 
--------------------------------------------------------------------------------------------
-- LAYOUT CONFIG --
+
-- STARTUP HOOK CONFIG --
  +
--------------------------------------------------------------------------------------------
  +
  +
-- Startup Hook
  +
myStartupHook = do
  +
setDefaultCursor xC_left_ptr
  +
spawn "/usr/bin/killall haskell-cpu-usage.out"
  +
liftIO $ threadDelay 1000000 --needed so that xmonad can be recompiled and launched on the fly without crashing
  +
spawn "/home/nnoell/.xmonad/apps/haskell-cpu-usage.out 5"
  +
startTimer 1 >>= XS.put . TID
  +
  +
  +
--------------------------------------------------------------------------------------------
  +
-- HANDLE EVENT HOOK CONFIG --
 
--------------------------------------------------------------------------------------------
 
--------------------------------------------------------------------------------------------
   
-- Layouts (name must be diferent of Minimize, Maximize and Mirror)
+
-- Wrapper for the Timer id, so it can be stored as custom mutable state
myTile = named "ResizableTall" $ smartBorders $ ResizableTall 1 0.03 0.5 []
+
data TidState = TID TimerId deriving Typeable
myMirr = named "MirrResizableTall" $ smartBorders $ Mirror myTile
+
myMosA = named "MosaicAlt" $ smartBorders $ MosaicAlt M.empty
+
instance ExtensionClass TidState where
myObig = named "OneBig" $ smartBorders $ OneBig 0.75 0.65
+
initialValue = TID 0
myTabs = named "Simple Tabbed" $ smartBorders $ tabbed shrinkText myTitleTheme
+
myFull = named "Full Tabbed" $ smartBorders $ tabbedAlways shrinkText myTitleTheme
+
-- Handle event hook
myTabM = named "Master Tabbed" $ smartBorders $ mastered 0.01 0.4 $ tabbed shrinkText myTitleTheme
+
myHandleEventHook = fullscreenEventHook <+> docksEventHook <+> clockEventHook <+> handleTimerEvent <+> notFocusFloat where
myFlat = named "Simple Float" $ mouseResize $ noFrillsDeco shrinkText myTitleTheme simplestFloat
+
clockEventHook e = do --thanks to DarthFennec
myGimp = named "Gimp MosaicAlt" $ withIM (0.15) (Role "gimp-toolbox") $ reflectHoriz $ withIM (0.20) (Role "gimp-dock") myMosA
+
(TID t) <- XS.get --get the recent Timer id
myChat = named "Pidgin MosaicAlt" $ withIM (0.20) (Title "Buddy List") $ Mirror $ ResizableTall 1 0.03 0.5 []
+
handleTimer t e $ do --run the following if e matches the id
  +
startTimer 1 >>= XS.put . TID --restart the timer, store the new id
  +
ask >>= logHook . config --get the loghook and run it
  +
return Nothing --return required type
  +
return $ All True --return required type
  +
notFocusFloat = followOnlyIf (fmap not isFloat) where --Do not focusFollowMouse on Float layout
  +
isFloat = fmap (isSuffixOf myFloaName) $ gets (description . W.layout . W.workspace . W.current . windowset)
  +
  +
  +
--------------------------------------------------------------------------------------------
  +
-- LAYOUT CONFIG --
  +
--------------------------------------------------------------------------------------------
   
 
-- Tabbed transformer (W+f)
 
-- Tabbed transformer (W+f)
 
data TABBED = TABBED deriving (Read, Show, Eq, Typeable)
 
data TABBED = TABBED deriving (Read, Show, Eq, Typeable)
 
instance Transformer TABBED Window where
 
instance Transformer TABBED Window where
transform TABBED x k = k myFull (\_ -> x)
+
transform TABBED x k = k myFTabU (\_ -> x)
   
 
-- Floated transformer (W+ctl+f)
 
-- Floated transformer (W+ctl+f)
 
data FLOATED = FLOATED deriving (Read, Show, Eq, Typeable)
 
data FLOATED = FLOATED deriving (Read, Show, Eq, Typeable)
 
instance Transformer FLOATED Window where
 
instance Transformer FLOATED Window where
transform FLOATED x k = k myFlat (\_ -> x)
+
transform FLOATED x k = k myFloaU (\_ -> x)
  +
  +
-- Normal Layouts
  +
myTileN = ResizableTall 1 0.03 0.5 []
  +
myMirrN = Mirror myTileN
  +
myMosAN = MosaicAlt M.empty
  +
myOneBN = OneBig 0.75 0.65
  +
myTabbN = tabbed shrinkText myTitleTheme
  +
myMTabN = mastered 0.01 0.4 $ myTabbN
  +
myChatN = withIM (0.20) (Title "Buddy List") myMosAN
  +
  +
-- Switcher Layouts
  +
myTileS = windowSwitcherDecoration shrinkText myTitleTheme $ draggingVisualizer myTileN
  +
myMirrS = windowSwitcherDecoration shrinkText myTitleTheme $ draggingVisualizer myTileN
  +
myMosAS = windowSwitcherDecoration shrinkText myTitleTheme $ draggingVisualizer myMosAN
  +
myOneBS = windowSwitcherDecoration shrinkText myTitleTheme $ draggingVisualizer myOneBN
  +
myMTabS = windowSwitcherDecoration shrinkText myTitleTheme $ draggingVisualizer myMTabN
  +
myChatS = withIM (0.20) (Title "Buddy List") myMosAS
  +
  +
-- Toggled Layouts
  +
myTileT = smartBorders $ toggleLayouts (named ("Switcher " ++ myTileName) myTileS) (named ("Normal " ++ myTileName) myTileN)
  +
myMirrT = smartBorders $ toggleLayouts (named ("Switcher " ++ myMirrName) myMirrS) (named ("Normal " ++ myMirrName) myMirrN)
  +
myMosAT = smartBorders $ toggleLayouts (named ("Switcher " ++ myMosAName) myMosAS) (named ("Normal " ++ myMosAName) myMosAN)
  +
myOneBT = smartBorders $ toggleLayouts (named ("Switcher " ++ myOneBName) myOneBS) (named ("Normal " ++ myOneBName) myOneBN)
  +
myMTabT = smartBorders $ toggleLayouts (named ("Switcher " ++ myMTabName) myMTabS) (named ("Normal " ++ myMTabName) myMTabN)
  +
myChatT = smartBorders $ toggleLayouts (named ("Switcher " ++ myChatName) myChatS) (named ("Normal " ++ myChatName) myChatN)
  +
  +
-- Unique Layouts
  +
myTabbU = smartBorders $ named ("Unique " ++ myTabbName) myTabbN
  +
myTTabU = smartBorders $ named ("Unique " ++ myTTabName) $ combineTwoP myOneBN myTabbN myTabbN $ ClassName "Chromium"
  +
myFTabU = smartBorders $ named ("Unique " ++ myFTabName) $ tabbedAlways shrinkText myTitleTheme
  +
myFloaU = named ("Unique " ++ myFloaName) $ mouseResize $ noFrillsDeco shrinkText myTitleTheme simplestFloat
   
 
-- Layout hook
 
-- Layout hook
myLayoutHook = gaps [(U,16), (D,16), (L,0), (R,0)]
+
myLayoutHook = avoidStruts
$ avoidStruts
+
$ configurableNavigation noNavigateBorders
$ windowNavigation
 
 
$ minimize
 
$ minimize
 
$ maximize
 
$ maximize
Line 222: Line 227:
 
$ mkToggle (single REFLECTX)
 
$ mkToggle (single REFLECTX)
 
$ mkToggle (single REFLECTY)
 
$ mkToggle (single REFLECTY)
$ onWorkspace (myWorkspaces !! 1) webLayouts --Workspace 1 layouts
+
$ onWorkspace (myWorkspaces !! 1) webLayouts
$ onWorkspace (myWorkspaces !! 2) codeLayouts --Workspace 2 layouts
+
$ onWorkspace (myWorkspaces !! 2) codeLayouts
$ onWorkspace (myWorkspaces !! 3) gimpLayouts --Workspace 3 layouts
+
$ onWorkspace (myWorkspaces !! 4) chatLayouts
$ onWorkspace (myWorkspaces !! 4) chatLayouts --Workspace 4 layouts
+
$ allLayouts where
$ allLayouts
+
webLayouts = myTabbU ||| myTTabU
where
+
codeLayouts = myMTabT ||| myOneBT ||| myTileT
allLayouts = myTile ||| myObig ||| myMirr ||| myMosA ||| myTabM
+
chatLayouts = myChatT
webLayouts = myTabs ||| myMirr ||| myTabM
+
allLayouts = myTileT ||| myOneBT ||| myMirrT ||| myMosAT ||| myMTabT
codeLayouts = myTabM ||| myTile
 
gimpLayouts = myGimp
 
chatLayouts = myChat
 
   
   
 
--------------------------------------------------------------------------------------------
 
--------------------------------------------------------------------------------------------
-- HANDLE EVENT HOOK CONFIG --
+
-- MANAGE HOOK CONFIG --
 
--------------------------------------------------------------------------------------------
 
--------------------------------------------------------------------------------------------
   
-- wrapper for the Timer id, so it can be stored as custom mutable state
+
-- Manage Hook
data TidState = TID TimerId deriving Typeable
+
myManageHook :: ManageHook
+
myManageHook = manageWindows <+> manageScratchPad <+> manageDocks <+> dynamicMasterHook
instance ExtensionClass TidState where
 
initialValue = TID 0
 
 
-- Handle event hook
 
myHandleEventHook :: (?focusFollow::IORef Bool) => Event -> X All
 
myHandleEventHook = fullscreenEventHook <+> docksEventHook <+> toggleFocus <+> clockEventHook <+> handleTimerEvent
 
where
 
toggleFocus e = case e of --thanks to Vgot
 
CrossingEvent {ev_window=w, ev_event_type=t}
 
| t == enterNotify, ev_mode e == notifyNormal -> do
 
whenX (io $ readIORef ?focusFollow) (focus w)
 
return $ All True
 
_ -> return $ All True
 
clockEventHook e = do --thanks to DarthFennec
 
(TID t) <- XS.get --get the recent Timer id
 
handleTimer t e $ do --run the following if e matches the id
 
startTimer 1 >>= XS.put . TID --restart the timer, store the new id
 
ask >>= logHook.config --get the loghook and run it
 
return Nothing --return required type
 
return $ All True --return required type
 
 
 
--------------------------------------------------------------------------------------------
 
-- MANAGE HOOK CONFIG --
 
--------------------------------------------------------------------------------------------
 
   
 
-- Scratchpad (W+º)
 
-- Scratchpad (W+º)
 
manageScratchPad :: ManageHook
 
manageScratchPad :: ManageHook
manageScratchPad = scratchpadManageHook (W.RationalRect (0) (1/50) (1) (3/4))
+
manageScratchPad = scratchpadManageHook $ W.RationalRect (0) (panelHeight/yRes) (1) (3/4)
 
scratchPad = scratchpadSpawnActionCustom "urxvtc -name scratchpad"
 
scratchPad = scratchpadSpawnActionCustom "urxvtc -name scratchpad"
   
 
-- Manage hook
 
-- Manage hook
myManageHook :: ManageHook
+
manageWindows :: ManageHook
myManageHook = composeAll . concat $
+
manageWindows = composeAll . concat $
[ [resource =? r --> doIgnore | r <- myIgnores] --ignore desktop
+
[ [ resource =? r --> doIgnore | r <- myIgnores ]
, [className =? c --> doShift (myWorkspaces !! 1) | c <- myWebS ] --move myWebS windows to workspace 1 by classname
+
, [ className =? c --> doShift (myWorkspaces !! 1) | c <- myWebS ]
, [className =? c --> doShift (myWorkspaces !! 2) | c <- myCodeS ] --move myCodeS windows to workspace 2 by classname
+
, [ className =? c --> doShift (myWorkspaces !! 2) | c <- myCodeS ]
, [className =? c --> doShift (myWorkspaces !! 4) | c <- myChatS ] --move myChatS windows to workspace 4 by classname
+
, [ className =? c --> doShift (myWorkspaces !! 3) | c <- myGfxS ]
, [className =? c --> doShift (myWorkspaces !! 3) | c <- myGfxS ] --move myGfxS windows to workspace 4 by classname
+
, [ className =? c --> doShift (myWorkspaces !! 4) | c <- myChatS ]
, [className =? c --> doShiftAndGo (myWorkspaces !! 5) | c <- myAlt1S ] --move myGameS windows to workspace 5 by classname and shift
+
, [ className =? c --> doShift (myWorkspaces !! 7) | c <- myAlt3S ]
, [className =? c --> doShift (myWorkspaces !! 7) | c <- myAlt3S ] --move myOtherS windows to workspace 5 by classname and shift
+
, [ className =? c --> doCenterFloat | c <- myFloatCC ]
, [className =? c --> doCenterFloat | c <- myFloatCC] --float center geometry by classname
+
, [ name =? n --> doCenterFloat | n <- myFloatCN ]
, [name =? n --> doCenterFloat | n <- myFloatCN] --float center geometry by name
+
, [ name =? n --> doSideFloat NW | n <- myFloatSN ]
, [name =? n --> doSideFloat NW | n <- myFloatSN] --float side NW geometry by name
+
, [ className =? c --> doF W.focusDown | c <- myFocusDC ]
, [className =? c --> doF W.focusDown | c <- myFocusDC] --dont focus on launching by classname
+
, [ isFullscreen --> doFullFloat ]
, [isFullscreen --> doFullFloat]
+
] where
]
+
name = stringProperty "WM_NAME"
where
+
myIgnores = ["desktop","desktop_window"]
doShiftAndGo ws = doF (W.greedyView ws) <+> doShift ws
+
myWebS = ["Chromium","Firefox", "Opera"]
role = stringProperty "WM_WINDOW_ROLE"
+
myCodeS = ["NetBeans IDE 7.3"]
name = stringProperty "WM_NAME"
+
myChatS = ["Pidgin", "Xchat"]
myIgnores = ["desktop","desktop_window"]
+
myGfxS = ["Gimp", "gimp", "GIMP"]
myWebS = ["Chromium","Firefox", "Opera"]
+
myAlt3S = ["Amule", "Transmission-gtk"]
myCodeS = ["NetBeans IDE 7.2"]
+
myFloatCC = ["MPlayer", "mplayer2", "File-roller", "zsnes", "Gcalctool", "Exo-helper-1", "Gksu", "PSX", "Galculator", "Nvidia-settings", "XFontSel"
myGfxS = ["Gimp", "gimp", "GIMP"]
+
, "XCalc", "XClock", "Ossxmix", "Xvidcap", "Main", "Wicd-client.py"]
myChatS = ["Pidgin", "Xchat"]
+
myFloatCN = ["Choose a file", "Open Image", "File Operation Progress", "Firefox Preferences", "Preferences", "Search Engines", "Set up sync"
myAlt1S = ["zsnes"]
+
,"Passwords and Exceptions", "Autofill Options", "Rename File", "Copying files", "Moving files", "File Properties", "Replace", ""]
myAlt3S = ["Amule", "Transmission-gtk"]
+
myFloatSN = ["Event Tester"]
myFloatCC = ["MPlayer", "File-roller", "zsnes", "Gcalctool", "Exo-helper-1", "Gksu", "PSX", "Galculator", "Nvidia-settings", "XFontSel"
+
myFocusDC = ["Event Tester", "Notify-osd"]
, "XCalc", "XClock", "Desmume", "Ossxmix", "Xvidcap", "Main", "Wicd-client.py", "com-mathworks-util-PostVMInit", "MATLAB"]
 
myFloatCN = ["ePSXe - Enhanced PSX emulator", "Seleccione Archivo", "Config Video", "Testing plugin", "Config Sound", "Config Cdrom", "Config Bios"
 
, "Config Netplay", "Config Memcards", "About ePSXe", "Config Controller", "Config Gamepads", "Select one or more files to open"
 
, "Add media", "Choose a file", "Open Image", "File Operation Progress", "Firefox Preferences", "Preferences", "Search Engines"
 
, "Set up sync", "Passwords and Exceptions", "Autofill Options", "Rename File", "Copying files", "Moving files", "File Properties", "Replace", ""]
 
myFloatSN = ["Event Tester"]
 
myFocusDC = ["Event Tester", "Notify-osd"]
 
   
   
 
--------------------------------------------------------------------------------------------
 
--------------------------------------------------------------------------------------------
-- STATUS BARS CONFIG --
+
-- DZEN STATUS BARS CONFIG --
 
--------------------------------------------------------------------------------------------
 
--------------------------------------------------------------------------------------------
   
-- UrgencyHook
+
-- urgencyHook
  +
myUrgencyHook :: LayoutClass l Window => XConfig l -> XConfig l
 
myUrgencyHook = withUrgencyHook dzenUrgencyHook
 
myUrgencyHook = withUrgencyHook dzenUrgencyHook
{ args = ["-fn", dzenFont, "-bg", colorBlack, "-fg", colorGreen, "-h", show panelHeight] }
+
{ duration = 2000000
  +
, args = ["-x", "0"
  +
, "-y", "0"
  +
, "-h", show panelHeight
  +
, "-w", show topPanelSepPos
  +
, "-fn", dzenFont
  +
, "-bg", colorBlack
  +
, "-fg", colorGreen
  +
]
  +
}
   
-- botLeftBar
+
-- Dzen top left bar flags
myBotLeftBar = "dzen2 -x 0 -y 752 -h 16 -w 400 -ta 'l' -fg '" ++ colorWhiteAlt ++ "' -bg '" ++ colorBlack ++ "' -fn '" ++ dzenFont ++ "' -p -e 'onstart=lower'"
+
dzenTopLeftFlags :: DF
myLogHook :: Handle -> X ()
+
dzenTopLeftFlags = DF
myLogHook h = dynamicLogWithPP $ defaultPP
+
{ xPosDF = 0
{ ppOutput = hPutStrLn h
+
, yPosDF = 0
, ppSort = fmap (namedScratchpadFilterOutWorkspace .) (ppSort defaultPP) --hide "NSP" from workspace list
+
, widthDF = topPanelSepPos
, ppOrder = \(ws:l:_:x) -> [ws] ++ x
+
, heightDF = panelHeight
, ppSep = " "
+
, alignementDF = "l"
, ppWsSep = ""
+
, fgColorDF = colorWhiteAlt
, ppCurrent = wrapTextBox colorBlack colorBlue colorBlack
+
, bgColorDF = colorBlack
, ppUrgent = wrapTextBox colorBlack colorGreen colorBlack . wrapClickWorkspace
+
, fontDF = dzenFont
, ppVisible = wrapTextBox colorBlack colorGrayAlt colorBlack . wrapClickWorkspace
+
, eventDF = "onstart=lower"
, ppHiddenNoWindows = wrapTextBox colorBlack colorGrayAlt colorBlack . wrapClickWorkspace
+
, extrasDF = "-p"
, ppHidden = wrapTextBox colorWhiteAlt colorGrayAlt colorBlack . wrapClickWorkspace
 
, ppExtras = [ (wrapLoggerBox colorBlue colorGrayAlt colorBlack $ loggerText "UPTIME") ++! (wrapLoggerBox colorWhiteAlt colorGrayAlt colorBlack uptime)
 
]
 
 
}
 
}
   
-- botRightBar
+
-- Top left bar logHook
myBotRightBar = "dzen2 -x 400 -y 752 -h 16 -w 966 -ta 'r' -fg '" ++ colorWhiteAlt ++ "' -bg '" ++ colorBlack ++ "' -fn '" ++ dzenFont ++ "' -p -e 'onstart=lower'"
+
myTopLeftLogHook :: Handle -> X ()
myLogHook1 :: Handle -> X ()
+
myTopLeftLogHook h = dynamicLogWithPP $ defaultPP
myLogHook1 h = dynamicLogWithPP $ defaultPP
+
{ ppOutput = hPutStrLn h
{ ppOutput = hPutStrLn h
+
, ppOrder = \(_:_:_:x) -> x
, ppOrder = \(_:_:_:x) -> x
+
, ppSep = " "
, ppSep = " "
+
, ppExtras = [ myLayoutL, myWorkspaceL, myFocusL ]
, ppExtras = [ (wrapLoggerBox colorGray colorGrayAlt colorBlack $ loggerText "CPU") ++! (wrapLoggerBox colorBlue colorGrayAlt colorBlack cpuUsage)
 
, (wrapLoggerBox colorGray colorGrayAlt colorBlack $ loggerText "MEM") ++! (wrapLoggerBox colorBlue colorGrayAlt colorBlack memUsage)
 
, (wrapLoggerBox colorGray colorGrayAlt colorBlack $ loggerText "TEMP") ++! (wrapLoggerBox colorBlue colorGrayAlt colorBlack cpuTemp)
 
, (wrapLoggerBox colorGray colorGrayAlt colorBlack $ loggerText "WIFI") ++! (wrapLoggerBox colorBlue colorGrayAlt colorBlack wifiSignal)
 
, (wrapLoggerBox colorGray colorGrayAlt colorBlack $ loggerText "BATTERY") ++! (wrapLoggerBox colorBlue colorGrayAlt colorBlack batPercent) ++! (wrapLoggerBox colorWhiteAlt colorGrayAlt colorBlack batStatus)
 
]
 
 
}
 
}
   
(++!) :: Logger -> Logger -> Logger
+
-- Dzen top right bar flags
l1 ++! l2 = do
+
dzenTopRightFlags :: DF
log1 <- l1
+
dzenTopRightFlags = DF
log2 <- l2
+
{ xPosDF = topPanelSepPos
let text = do
+
, yPosDF = 0
str1 <- log1
+
, widthDF = xRes - topPanelSepPos
str2 <- log2
+
, heightDF = panelHeight
return $ str1 ++ str2
+
, alignementDF = "r"
return text
+
, fgColorDF = colorWhiteAlt
  +
, bgColorDF = colorBlack
  +
, fontDF = dzenFont
  +
, eventDF = "onstart=lower"
  +
, extrasDF = "-p"
  +
}
   
loggerText :: String -> Logger
+
-- Top right bar logHook
loggerText t = return $ return t
+
myTopRightLogHook :: Handle -> X ()
  +
myTopRightLogHook h = dynamicLogWithPP $ defaultPP
  +
{ ppOutput = hPutStrLn h
  +
, ppOrder = \(_:_:_:x) -> x
  +
, ppSep = " "
  +
, ppExtras = [ myUptimeL, myDateL ]
  +
}
   
readWithE :: FilePath -> String -> String -> IO String
+
-- Dzen bottom left bar flags
readWithE p e c = E.catch (do
+
dzenBotLeftFlags :: DF
contents <- readFile p
+
dzenBotLeftFlags = DF
return $ (init contents) ++ c ) ((\_ -> return e) :: E.SomeException -> IO String) --init removes \n from contents
+
{ xPosDF = 0
+
, yPosDF = yRes - panelHeight
batPercent :: Logger
+
, widthDF = botPanelSepPos
batPercent = do
+
, heightDF = panelHeight
percent <- liftIO $ readWithE "/sys/class/power_supply/BAT0/capacity" "N/A" "%"
+
, alignementDF = "l"
return $ return percent
+
, fgColorDF = colorWhiteAlt
+
, bgColorDF = colorBlack
batStatus :: Logger
+
, fontDF = dzenFont
batStatus = do
+
, eventDF = "onstart=lower"
status <- liftIO $ readWithE "/sys/class/power_supply/BAT0/status" "AC Conection" ""
+
, extrasDF = "-p"
return $ return status
 
 
wifiSignal :: Logger
 
wifiSignal = do
 
signalContent <- liftIO $ readWithE "/proc/net/wireless" "N/A" ""
 
let signalLines = lines signalContent
 
let signal = if (length signalLines) >= 3 then (init ((words (signalLines !! 2)) !! 2) ++ "%") else "Off"
 
return $ return signal
 
 
cpuTemp :: Logger
 
cpuTemp = do
 
temp1 <- liftIO $ readWithE "/sys/bus/platform/devices/coretemp.0/temp1_input" "0" ""
 
temp2 <- liftIO $ readWithE "/sys/bus/platform/devices/coretemp.0/temp2_input" "0" ""
 
temp3 <- liftIO $ readWithE "/sys/bus/platform/devices/coretemp.0/temp3_input" "0" ""
 
let divc x = show $ div (read x::Int) 1000
 
return $ return $ (divc temp1) ++ "° " ++ (divc temp2) ++ "° " ++ (divc temp3) ++ "°"
 
 
memUsage :: Logger
 
memUsage = do
 
memInfo <- liftIO $ readWithE "/proc/meminfo" "N/A" ""
 
let memInfoLines = lines memInfo
 
let memTotal = read (words (memInfoLines !! 0) !! 1)::Int
 
let memFree = read (words (memInfoLines !! 1) !! 1)::Int
 
let buffers = read (words (memInfoLines !! 2) !! 1)::Int
 
let cached = read (words (memInfoLines !! 3) !! 1)::Int
 
let used = memTotal - (buffers + cached + memFree)
 
let perc = div ((memTotal - (buffers + cached + memFree)) * 100) memTotal
 
return $ return $ (show perc) ++ "% " ++ (show $ div used 1024) ++ "MB"
 
 
-- This is an ugly hack that depends on cpuUsage.sh script
 
cpuUsage :: Logger
 
cpuUsage = do
 
cpu0 <- liftIO $ readWithE "/tmp/cpuUsage0" "0" "%"
 
cpu1 <- liftIO $ readWithE "/tmp/cpuUsage1" "0" "%"
 
cpu2 <- liftIO $ readWithE "/tmp/cpuUsage2" "0" "%"
 
cpu3 <- liftIO $ readWithE "/tmp/cpuUsage3" "0" "%"
 
return $ return $ cpu0 ++ " " ++ cpu1 ++ " " ++ cpu2 ++ " " ++ cpu3
 
 
uptime :: Logger
 
uptime = do
 
uptime <- liftIO $ readWithE "/proc/uptime" "0" ""
 
let u = read (takeWhile (/='.') uptime )::Integer
 
let h = div u 3600
 
let hr = mod u 3600
 
let m = div hr 60
 
let s = mod hr 60
 
return $ return $ (show h) ++ "h " ++ (show m) ++ "m " ++ (show s) ++ "s"
 
 
 
-- TopLeftBar
 
myTopLeftBar = "dzen2 -x 0 -y 0 -h 16 -w 1050 -ta 'l' -fg '" ++ colorWhiteAlt ++ "' -bg '" ++ colorBlack ++ "' -fn '" ++ dzenFont ++ "' -p -e 'onstart=lower'"
 
myLogHook2 :: Handle -> X ()
 
myLogHook2 h = dynamicLogWithPP $ defaultPP
 
{ ppOutput = hPutStrLn h
 
, ppOrder = \(_:_:_:x) -> x
 
, ppSep = " "
 
, ppExtras = [ wrapL (wrapClickLayout $ wrapTextBox colorBlue colorGrayAlt colorBlack "LAYOUT") "" $ wrapLoggerBox colorWhiteAlt colorGrayAlt colorBlack $ onLogger layoutText $ removeWordL $ removeWordL logLayout
 
, wrapL (wrapClickGrid $ wrapTextBox colorBlue colorGrayAlt colorBlack "WORKSPACE") "" $ wrapLoggerBox colorWhiteAlt colorGrayAlt colorBlack $ onLogger namedWorkspaces logCurrent
 
, wrapL (wrapClickTitle $ wrapTextBox colorBlack colorWhiteAlt colorBlack "FOCUS") "" $ wrapLoggerBox colorWhiteAlt colorGrayAlt colorBlack $ shortenL 120 logTitle
 
]
 
 
}
 
}
where
 
namedWorkspaces w
 
| w == "1" = "^fg(" ++ colorGreen ++ ")1^fg(" ++ colorGray ++ ")|^fg()Terminal"
 
| w == "2" = "^fg(" ++ colorGreen ++ ")2^fg(" ++ colorGray ++ ")|^fg()Network"
 
| w == "3" = "^fg(" ++ colorGreen ++ ")3^fg(" ++ colorGray ++ ")|^fg()Development"
 
| w == "4" = "^fg(" ++ colorGreen ++ ")4^fg(" ++ colorGray ++ ")|^fg()Graphics"
 
| w == "5" = "^fg(" ++ colorGreen ++ ")5^fg(" ++ colorGray ++ ")|^fg()Chatting"
 
| w == "6" = "^fg(" ++ colorGreen ++ ")6^fg(" ++ colorGray ++ ")|^fg()Alternative"
 
| w == "7" = "^fg(" ++ colorGreen ++ ")7^fg(" ++ colorGray ++ ")|^fg()Alternative"
 
| w == "8" = "^fg(" ++ colorGreen ++ ")8^fg(" ++ colorGray ++ ")|^fg()Alternative"
 
| w == "9" = "^fg(" ++ colorGreen ++ ")9^fg(" ++ colorGray ++ ")|^fg()Alternative"
 
| w == "0" = "^fg(" ++ colorGreen ++ ")0^fg(" ++ colorGray ++ ")|^fg()Alternative"
 
| otherwise = "^fg(" ++ colorRed ++ ")x^fg(" ++ colorGray ++ ")|^fg()" ++ w
 
removeWord = tail . dropWhile (/= ' ')
 
removeWordL l = do
 
log <- l
 
let text = do
 
logStr <- log
 
return $ removeWord logStr
 
return text
 
layoutText xs
 
| isPrefixOf "Mirror" xs = layoutText $ removeWord xs ++ " [M]"
 
| isPrefixOf "ReflectY" xs = layoutText $ removeWord xs ++ " [Y]"
 
| isPrefixOf "ReflectX" xs = layoutText $ removeWord xs ++ " [X]"
 
| isPrefixOf "Simple Float" xs = "^fg(" ++ colorRed ++ ")" ++ xs
 
| isPrefixOf "Full Tabbed" xs = "^fg(" ++ colorGreen ++ ")" ++ xs
 
| otherwise = "^fg(" ++ colorWhiteAlt ++ ")" ++ xs
 
   
+
-- Bottom left bar logHook
-- TopRightBar
+
myBotLeftLogHook :: Handle -> X ()
myTopRightBar = "dzen2 -x 1050 -y 0 -h 16 -w 366 -ta 'r' -fg '" ++ colorWhiteAlt ++ "' -bg '" ++ colorBlack ++ "' -fn '" ++ dzenFont ++ "' -p -e 'onstart=lower'"
+
myBotLeftLogHook h = dynamicLogWithPP . namedScratchpadFilterOutWorkspacePP $ defaultPP
myLogHook3 :: Handle -> X ()
 
myLogHook3 h = dynamicLogWithPP $ defaultPP
 
 
{ ppOutput = hPutStrLn h
 
{ ppOutput = hPutStrLn h
, ppOrder = \(_:_:_:x) -> x
+
, ppOrder = \(ws:l:_:x) -> [ws] ++ x
 
, ppSep = " "
 
, ppSep = " "
+
, ppWsSep = ""
-- Wrap Clickable Area
+
, ppCurrent = dzenBoxStyle blue2BBoxPP
wrapClickGrid x = "^ca(1,/usr/bin/xdotool key super+g)" ++ x ++ "^ca()"
+
, ppUrgent = dzenBoxStyle green2BBoxPP . dzenClickWorkspace
wrapClickCalendar x = "^ca(1," ++ myBinPath ++ "dzencal.sh)" ++ x ++ "^ca()"
+
, ppVisible = dzenBoxStyle blackBoxPP . dzenClickWorkspace
wrapClickLayout x = "^ca(1,/usr/bin/xdotool key super+space)^ca(3,/usr/bin/xdotool key super+shift+space)" ++ x ++ "^ca()^ca()"
+
, ppHiddenNoWindows = dzenBoxStyle blackBoxPP . dzenClickWorkspace
wrapClickTitle x = "^ca(1,/usr/bin/xdotool key super+m)^ca(2,/usr/bin/xdotool key super+c)^ca(3,/usr/bin/xdotool key super+shift+m)" ++ x ++ "^ca()^ca()^ca()"
+
, ppHidden = dzenBoxStyle whiteBoxPP . dzenClickWorkspace
wrapClickWorkspace ws = "^ca(1," ++ xdo "w;" ++ xdo index ++ ")" ++ "^ca(3," ++ xdo "w;" ++ xdo index ++ ")" ++ ws ++ "^ca()^ca()"
+
, ppExtras = [ myFsL ]
where
+
} where
wsIdxToString Nothing = "1"
+
dzenClickWorkspace ws = "^ca(1," ++ xdo "w;" ++ xdo index ++ ")" ++ "^ca(3," ++ xdo "w;" ++ xdo index ++ ")" ++ ws ++ "^ca()^ca()" where
wsIdxToString (Just n) = show $ mod (n+1) $ length myWorkspaces
+
wsIdxToString Nothing = "1"
index = wsIdxToString (elemIndex ws myWorkspaces)
+
wsIdxToString (Just n) = show $ mod (n+1) $ length myWorkspaces
xdo key = "/usr/bin/xdotool key super+" ++ key
+
index = wsIdxToString (elemIndex ws myWorkspaces)
  +
xdo key = "/usr/bin/xdotool key super+" ++ key
   
-- Wrap Box
+
-- Dzen bottom right bar flags
wrapTextBox :: String -> String -> String -> String -> String
+
dzenBotRightFlags :: DF
wrapTextBox fg bg1 bg2 t = "^fg(" ++ bg1 ++ ")^i(" ++ myIconPath ++ "boxleft.xbm)^ib(1)^r(" ++ show xRes ++ "x" ++ show panelBoxHeight ++ ")^p(-" ++ show xRes ++ ")^fg(" ++ fg ++ ")" ++ t ++ "^fg(" ++ bg1 ++ ")^i(" ++ myIconPath ++ "boxright.xbm)^fg(" ++ bg2 ++ ")^r(" ++ show xRes ++ "x" ++ show panelBoxHeight ++ ")^p(-" ++ show xRes ++ ")^fg()^ib(0)"
+
dzenBotRightFlags = DF
  +
{ xPosDF = botPanelSepPos
  +
, yPosDF = yRes - panelHeight
  +
, widthDF = xRes - botPanelSepPos
  +
, heightDF = panelHeight
  +
, alignementDF = "r"
  +
, fgColorDF = colorWhiteAlt
  +
, bgColorDF = colorBlack
  +
, fontDF = dzenFont
  +
, eventDF = "onstart=lower"
  +
, extrasDF = "-p"
  +
}
   
wrapLoggerBox :: String -> String -> String -> Logger -> Logger
+
-- Bottom right bar logHook
wrapLoggerBox fg bg1 bg2 l = do
+
myBotRightLogHook :: Handle -> X ()
log <- l
+
myBotRightLogHook h = dynamicLogWithPP $ defaultPP
let text = do
+
{ ppOutput = hPutStrLn h
logStr <- log
+
, ppOrder = \(_:_:_:x) -> x
return $ wrapTextBox fg bg1 bg2 logStr
+
, ppSep = " "
return text
+
, ppExtras = [ myCpuL, myMemL, myTempL, myBrightL, myWifiL, myBatL ]
  +
}
   
   
 
--------------------------------------------------------------------------------------------
 
--------------------------------------------------------------------------------------------
-- BINDINGS CONFIG --
+
-- LOGGERS CONFIG --
 
--------------------------------------------------------------------------------------------
 
--------------------------------------------------------------------------------------------
   
-- Key bindings
+
myBatL = (dzenBoxStyleL gray2BoxPP $ labelL "BATTERY") ++! (dzenBoxStyleL blueBoxPP batPercent) ++! (dzenBoxStyleL whiteBoxPP batStatus)
myKeys :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ())
+
myWifiL = (dzenBoxStyleL gray2BoxPP $ labelL "WIFI") ++! (dzenBoxStyleL blueBoxPP wifiSignal)
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
+
myBrightL = (dzenBoxStyleL gray2BoxPP $ labelL "BRIGHT") ++! (dzenBoxStyleL blueBoxPP brightPerc)
--Xmonad bindings
+
myTempL = (dzenBoxStyleL gray2BoxPP $ labelL "TEMP") ++! (dzenBoxStyleL blueBoxPP cpuTemp)
[((modMask .|. shiftMask, xK_q), io (exitWith ExitSuccess)) --Quit xmonad
+
myMemL = (dzenBoxStyleL gray2BoxPP $ labelL "MEM") ++! (dzenBoxStyleL blueBoxPP memUsage)
, ((modMask, xK_q), restart "xmonad" True) --Restart xmonad
+
myCpuL = (dzenBoxStyleL gray2BoxPP $ labelL "CPU") ++! (dzenBoxStyleL blueBoxPP $ cpuUsage "/tmp/haskell-cpu-usage.txt")
, ((mod1Mask, xK_F2), shellPrompt myXPConfig) --Launch Xmonad shell prompt
+
myFsL = (dzenBoxStyleL blue2BoxPP $ labelL "ROOT") ++! (dzenBoxStyleL whiteBoxPP $ fsPerc "/") ++! (dzenBoxStyleL blueBoxPP $ labelL "HOME") ++! (dzenBoxStyleL whiteBoxPP $ fsPerc "/home")
, ((modMask, xK_F2), xmonadPrompt myXPConfig) --Launch Xmonad prompt
+
myDateL = (dzenBoxStyleL white2BBoxPP $ date "%A") ++! (dzenBoxStyleL whiteBoxPP $ date $ "%Y^fg(" ++ colorGray ++ ").^fg()%m^fg(" ++ colorGray ++ ").^fg()^fg(" ++ colorBlue ++ ")%d^fg() ^fg(" ++ colorGray ++ ")-^fg() %H^fg(" ++ colorGray ++ "):^fg()%M^fg(" ++ colorGray ++ "):^fg()^fg(" ++ colorGreen ++ ")%S^fg()") ++! (dzenClickStyleL calendarCA $ dzenBoxStyleL blueBoxPP $ labelL "CALENDAR")
, ((mod1Mask, xK_F3), manPrompt myXPConfig) --Launch man prompt
+
myUptimeL = (dzenBoxStyleL blue2BoxPP $ labelL "UPTIME") ++! (dzenBoxStyleL whiteBoxPP uptime)
, ((modMask, xK_g), goToSelected $ myGSConfig myColorizer) --Launch GridSelect
+
myFocusL = (dzenClickStyleL focusCA $ dzenBoxStyleL white2BBoxPP $ labelL "FOCUS") ++! (dzenBoxStyleL whiteBoxPP $ shortenL 100 logTitle)
, ((modMask, xK_masculine), scratchPad) --Scratchpad
+
myLayoutL = (dzenClickStyleL layoutCA $ dzenBoxStyleL blue2BoxPP $ labelL "LAYOUT") ++! (dzenBoxStyleL whiteBoxPP $ onLogger (layoutText . removeWord . removeWord) logLayout) where
, ((modMask .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf) --Launch default terminal
+
removeWord xs = tail $ dropWhile (/= ' ') xs
--Window management bindings
+
layoutText xs
, ((modMask, xK_c), kill) --Close focused window
+
| isPrefixOf "Mirror" xs = layoutText $ removeWord xs ++ " ^fg(" ++ colorBlue ++ ")M^fg(" ++ colorGray ++ ")|^fg(" ++ colorWhiteAlt ++ ")"
, ((mod1Mask, xK_F4), kill)
+
| isPrefixOf "ReflectY" xs = layoutText $ removeWord xs ++ " ^fg(" ++ colorBlue ++ ")Y^fg(" ++ colorGray ++ ")|^fg(" ++ colorWhiteAlt ++ ")"
, ((modMask, xK_n), refresh) --Resize viewed windows to the correct size
+
| isPrefixOf "ReflectX" xs = layoutText $ removeWord xs ++ " ^fg(" ++ colorBlue ++ ")X^fg(" ++ colorGray ++ ")|^fg(" ++ colorWhiteAlt ++ ")"
, ((modMask, xK_Tab), windows W.focusDown) --Move focus to the next window
+
| isPrefixOf "Switcher" xs = layoutText $ removeWord xs ++ " ^fg(" ++ colorRed ++ ")S^fg(" ++ colorGray ++ ")|^fg(" ++ colorWhiteAlt ++ ")"
, ((modMask, xK_j), windows W.focusDown)
+
| isPrefixOf "Normal" xs = layoutText $ removeWord xs ++ " ^fg(" ++ colorGreen ++ ")N^fg(" ++ colorGray ++ ")|^fg(" ++ colorWhiteAlt ++ ")"
, ((mod1Mask, xK_Tab), windows W.focusDown)
+
| isPrefixOf "Unique" xs = layoutText $ removeWord xs ++ " ^fg(" ++ colorGreen ++ ")U^fg(" ++ colorGray ++ ")|^fg(" ++ colorWhiteAlt ++ ")"
, ((modMask, xK_k), windows W.focusUp) --Move focus to the previous window
+
| otherwise = concat $ reverse $ words xs
, ((modMask, xK_a), windows W.focusMaster) --Move focus to the master window
+
myWorkspaceL = (dzenClickStyleL workspaceCA $ dzenBoxStyleL blue2BoxPP $ labelL "WORKSPACE") ++! (dzenBoxStyleL whiteBoxPP $ onLogger namedWorkspaces logCurrent) where
, ((modMask .|. shiftMask, xK_a), windows W.swapMaster) --Swap the focused window and the master window
+
namedWorkspaces w
, ((modMask .|. shiftMask, xK_j), windows W.swapDown) --Swap the focused window with the next window
+
| (elem w $ map show [0..9]) == True = "^fg(" ++ colorGreen ++ ")" ++ w ++ "^fg(" ++ colorGray ++ ")|^fg()" ++ workspaceNames !! (mod ((read w::Int) - 1) 10)
, ((modMask .|. shiftMask, xK_k), windows W.swapUp) --Swap the focused window with the previous window
+
| otherwise = "^fg(" ++ colorRed ++ ")x^fg(" ++ colorGray ++ ")|^fg()" ++ w
, ((modMask, xK_h), sendMessage Shrink) --Shrink the master area
 
, ((modMask .|. shiftMask, xK_Left), sendMessage Shrink)
 
, ((modMask, xK_l), sendMessage Expand) --Expand the master area
 
, ((modMask .|. shiftMask, xK_Right), sendMessage Expand)
 
, ((modMask .|. shiftMask, xK_h), sendMessage MirrorShrink) --MirrorShrink the master area
 
, ((modMask .|. shiftMask, xK_Down), sendMessage MirrorShrink)
 
, ((modMask .|. shiftMask, xK_l), sendMessage MirrorExpand) --MirrorExpand the master area
 
, ((modMask .|. shiftMask, xK_Up), sendMessage MirrorExpand)
 
, ((modMask, xK_t), withFocused $ windows . W.sink) --Push window back into tiling
 
, ((modMask .|. shiftMask, xK_t), rectFloatFocused) --Push window into float
 
, ((modMask, xK_m), withFocused minimizeWindow) --Minimize window
 
, ((modMask, xK_b), withFocused (sendMessage . maximizeRestore)) --Maximize window
 
, ((modMask .|. shiftMask, xK_m), sendMessage RestoreNextMinimizedWin) --Restore window
 
, ((modMask .|. shiftMask, xK_f), fullFloatFocused) --Push window into full screen
 
, ((modMask, xK_comma), sendMessage (IncMasterN 1)) --Increment the number of windows in the master area
 
, ((modMask, xK_period), sendMessage (IncMasterN (-1))) --Deincrement the number of windows in the master area
 
, ((modMask, xK_Right), sendMessage $ Go R) --Change focus to right
 
, ((modMask, xK_Left ), sendMessage $ Go L) --Change focus to left
 
, ((modMask, xK_Up ), sendMessage $ Go U) --Change focus to up
 
, ((modMask, xK_Down ), sendMessage $ Go D) --Change focus to down
 
, ((modMask .|. controlMask, xK_Right), sendMessage $ Swap R) --Swap focused window to right
 
, ((modMask .|. controlMask, xK_Left ), sendMessage $ Swap L) --Swap focused window to left
 
, ((modMask .|. controlMask, xK_Up ), sendMessage $ Swap U) --Swap focused window to up
 
, ((modMask .|. controlMask, xK_Down ), sendMessage $ Swap D) --Swap focused window to down
 
--Layout management bindings
 
, ((modMask, xK_space), sendMessage NextLayout) --Rotate through the available layout algorithms
 
, ((modMask .|. shiftMask, xK_space ), flashText myTextConfig 1 " Set to Default Layout " >> (setLayout $ XMonad.layoutHook conf)) --Reset layout to workspaces default
 
, ((modMask, xK_f), sendMessage $ XMonad.Layout.MultiToggle.Toggle TABBED) --Push layout into tabbed
 
, ((modMask .|. controlMask, xK_f), sendMessage $ XMonad.Layout.MultiToggle.Toggle FLOATED) --Push layout into float
 
, ((modMask .|. shiftMask, xK_z), sendMessage $ Toggle MIRROR) --Push layout into mirror
 
, ((modMask .|. shiftMask, xK_x), sendMessage $ XMonad.Layout.MultiToggle.Toggle REFLECTX) --Reflect layout by X
 
, ((modMask .|. shiftMask, xK_y), sendMessage $ XMonad.Layout.MultiToggle.Toggle REFLECTY) --Reflect layout by Y
 
--Gaps management bindings
 
, ((modMask .|. controlMask, xK_t), sendMessage $ ToggleGaps) --toogle all gaps
 
, ((modMask .|. controlMask, xK_u), sendMessage $ ToggleGap U) --toogle the top gap
 
, ((modMask .|. controlMask, xK_d), sendMessage $ ToggleGap D) --toogle the bottom gap
 
--Scripts management bindings
 
, ((modMask , xK_x), spawn "/usr/bin/xcalib -invert -alter") --Invert colors in X
 
, ((modMask , xK_d), spawn "/usr/bin/killall dzen2") --Kill dzen2
 
, ((0, xF86XK_AudioMute), spawn $ myBinPath ++ "voldzen.sh t -d") --Mute/unmute volume
 
, ((0, xF86XK_AudioRaiseVolume), spawn $ myBinPath ++ "voldzen.sh + -d") --Raise volume
 
, ((mod1Mask, xK_Up), spawn $ myBinPath ++ "voldzen.sh + -d")
 
, ((0, xF86XK_AudioLowerVolume), spawn $ myBinPath ++ "voldzen.sh - -d") --Lower volume
 
, ((mod1Mask, xK_Down), spawn $ myBinPath ++ "voldzen.sh - -d")
 
, ((0, xF86XK_AudioNext), flashText myTextConfig 1 " Next Song " >> spawn "/usr/bin/ncmpcpp next") --Next song
 
, ((mod1Mask, xK_Right), flashText myTextConfig 1 " Next Song " >> spawn "/usr/bin/ncmpcpp next")
 
, ((0, xF86XK_AudioPrev), flashText myTextConfig 1 " Previous Song " >> spawn "/usr/bin/ncmpcpp prev") --Prev song
 
, ((mod1Mask, xK_Left), flashText myTextConfig 1 " Previous Song " >> spawn "/usr/bin/ncmpcpp prev")
 
, ((0, xF86XK_AudioPlay), flashText myTextConfig 1 " Song Toggled " >> spawn "/usr/bin/ncmpcpp toggle") --Toggle song
 
, ((mod1Mask .|. controlMask, xK_Down), flashText myTextConfig 1 " Song Toggled " >> spawn "/usr/bin/ncmpcpp toggle")
 
, ((0, xF86XK_AudioStop), flashText myTextConfig 1 " Song Stopped " >> spawn "/usr/bin/ncmpcpp stop") --Stop song
 
, ((mod1Mask .|. controlMask, xK_Up), flashText myTextConfig 1 " Song Stopped " >> spawn "ncmpcpp stop")
 
, ((0, xF86XK_MonBrightnessUp), spawn $ myBinPath ++ "bridzen.sh") --Raise brightness
 
, ((0, xF86XK_MonBrightnessDown), spawn $ myBinPath ++ "bridzen.sh") --Lower brightness
 
, ((0, xF86XK_ScreenSaver), spawn $ myBinPath ++ "turnoffscreen.sh") --Lock screen
 
, ((0, xK_Print), spawn "/usr/bin/scrot '%Y-%m-%d_$wx$h.png'") --Take a screenshot
 
, ((modMask , xK_s), spawn $ myBinPath ++ "turnoffscreen.sh") --Turn off screen
 
--Workspaces management bindings
 
, ((mod1Mask, xK_comma), flashText myTextConfig 1 " Toggled to Previous Workspace " >> toggleWS) --Toggle to the workspace displayed previously
 
, ((mod1Mask, xK_masculine), flashText myTextConfig 1 " Switching with Workspace 1 " >> toggleOrView (myWorkspaces !! 0)) --If ws != 0 then move to workspace 0, else move to latest ws I was
 
, ((mod1Mask .|. controlMask, xK_Left), flashText myTextConfig 1 " Moved to Previous Workspace " >> prevWS) --Move to previous Workspace
 
, ((mod1Mask .|. controlMask, xK_Right), flashText myTextConfig 1 " Moved to Next Workspace " >> nextWS) --Move to next Workspace
 
, ((modMask .|. shiftMask, xK_n), flashText myTextConfig 1 " Shifted to Next Workspace " >> shiftToNext) --Send client to next workspace
 
, ((modMask .|. shiftMask, xK_p), flashText myTextConfig 1 " Shifted to Previous Workspace " >> shiftToPrev) --Send client to previous workspace
 
]
 
++
 
[((m .|. modMask, k), windows $ f i) --Switch to n workspaces and send client to n workspaces
 
| (i, k) <- zip (XMonad.workspaces conf) ([xK_1 .. xK_9] ++ [xK_0])
 
, (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
 
++
 
[((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f)) --Switch to n screens and send client to n screens
 
| (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
 
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
 
where
 
fullFloatFocused = withFocused $ \f -> windows =<< appEndo `fmap` runQuery doFullFloat f
 
rectFloatFocused = withFocused $ \f -> windows =<< appEndo `fmap` runQuery (doRectFloat $ RationalRect 0.05 0.05 0.9 0.9) f
 
 
-- Mouse bindings
 
myMouseBindings :: XConfig Layout -> M.Map (KeyMask, Button) (Window -> X ())
 
myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
 
[ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w >> windows W.shiftMaster)) --Set the window to floating mode and move by dragging
 
, ((modMask, button2), (\w -> focus w >> windows W.shiftMaster)) --Raise the window to the top of the stack
 
, ((modMask, button3), (\w -> focus w >> Flex.mouseResizeWindow w)) --Set the window to floating mode and resize by dragging
 
, ((modMask, button4), (\_ -> prevWS)) --Switch to previous workspace
 
, ((modMask, button5), (\_ -> nextWS)) --Switch to next workspace
 
, (((modMask .|. shiftMask), button4), (\_ -> shiftToPrev)) --Send client to previous workspace
 
, (((modMask .|. shiftMask), button5), (\_ -> shiftToNext)) --Send client to next workspace
 
], ppExtras = [ date $ (wrapTextBox colorBlack colorWhiteAlt colorBlack "%A") ++ (wrapTextBox colorWhiteAlt colorGrayAlt colorBlack $ "%Y^fg(" ++ colorGray ++ ").^fg()%m^fg(" ++ colorGray ++ ").^fg()^fg(" ++ colorBlue ++ ")%d^fg() ^fg(" ++ colorGray ++ ")-^fg() %H^fg(" ++ colorGray ++"):^fg()%M^fg(" ++ colorGray ++ "):^fg()^fg(" ++ colorGreen ++ ")%S^fg()")
 
, return $ return $ wrapClickCalendar $ wrapTextBox colorBlue colorGrayAlt colorBlack "CALENDAR"
 
]
 
}
 
 
-- Wrap Clickable Area
 
wrapClickGrid x = "^ca(1,/usr/bin/xdotool key super+g)" ++ x ++ "^ca()"
 
wrapClickCalendar x = "^ca(1," ++ myBinPath ++ "dzencal.sh)" ++ x ++ "^ca()"
 
wrapClickLayout x = "^ca(1,/usr/bin/xdotool key super+space)^ca(3,/usr/bin/xdotool key super+shift+space)" ++ x ++ "^ca()^ca()"
 
wrapClickTitle x = "^ca(1,/usr/bin/xdotool key super+m)^ca(2,/usr/bin/xdotool key super+c)^ca(3,/usr/bin/xdotool key super+shift+m)" ++ x ++ "^ca()^ca()^ca()"
 
wrapClickWorkspace ws = "^ca(1," ++ xdo "w;" ++ xdo index ++ ")" ++ "^ca(3," ++ xdo "w;" ++ xdo index ++ ")" ++ ws ++ "^ca()^ca()"
 
where
 
wsIdxToString Nothing = "1"
 
wsIdxToString (Just n) = show $ mod (n+1) $ length myWorkspaces
 
index = wsIdxToString (elemIndex ws myWorkspaces)
 
xdo key = "/usr/bin/xdotool key super+" ++ key
 
 
-- Wrap Box
 
wrapTextBox :: String -> String -> String -> String -> String
 
wrapTextBox fg bg1 bg2 t = "^fg(" ++ bg1 ++ ")^i(" ++ myIconPath ++ "boxleft.xbm)^ib(1)^r(" ++ show xRes ++ "x" ++ show panelBoxHeight ++ ")^p(-" ++ show xRes ++ ")^fg(" ++ fg ++ ")" ++ t ++ "^fg(" ++ bg1 ++ ")^i(" ++ myIconPath ++ "boxright.xbm)^fg(" ++ bg2 ++ ")^r(" ++ show xRes ++ "x" ++ show panelBoxHeight ++ ")^p(-" ++ show xRes ++ ")^fg()^ib(0)"
 
 
wrapLoggerBox :: String -> String -> String -> Logger -> Logger
 
wrapLoggerBox fg bg1 bg2 l = do
 
log <- l
 
let text = do
 
logStr <- log
 
return $ wrapTextBox fg bg1 bg2 logStr
 
return text
 
   
   
Line 432: Line 410:
 
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
 
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
 
--Xmonad bindings
 
--Xmonad bindings
[((modMask .|. shiftMask, xK_q), io (exitWith ExitSuccess)) --Quit xmonad
+
[((modMask .|. shiftMask, xK_q), killAndExit) --Quit xmonad
, ((modMask, xK_q), restart "xmonad" True) --Restart xmonad
+
, ((modMask, xK_q), killAndRestart) --Restart xmonad
 
, ((mod1Mask, xK_F2), shellPrompt myXPConfig) --Launch Xmonad shell prompt
 
, ((mod1Mask, xK_F2), shellPrompt myXPConfig) --Launch Xmonad shell prompt
 
, ((modMask, xK_F2), xmonadPrompt myXPConfig) --Launch Xmonad prompt
 
, ((modMask, xK_F2), xmonadPrompt myXPConfig) --Launch Xmonad prompt
Line 441: Line 419:
 
, ((modMask .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf) --Launch default terminal
 
, ((modMask .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf) --Launch default terminal
 
--Window management bindings
 
--Window management bindings
, ((modMask, xK_c), kill) --Close focused window
+
, ((modMask, xK_c), kill) --Close focused window
 
, ((mod1Mask, xK_F4), kill)
 
, ((mod1Mask, xK_F4), kill)
, ((modMask, xK_n), refresh) --Resize viewed windows to the correct size
+
, ((modMask, xK_n), refresh) --Resize viewed windows to the correct size
, ((modMask, xK_Tab), windows W.focusDown) --Move focus to the next window
+
, ((modMask, xK_Tab), windows W.focusDown) --Move focus to the next window
 
, ((modMask, xK_j), windows W.focusDown)
 
, ((modMask, xK_j), windows W.focusDown)
 
, ((mod1Mask, xK_Tab), windows W.focusDown)
 
, ((mod1Mask, xK_Tab), windows W.focusDown)
, ((modMask, xK_k), windows W.focusUp) --Move focus to the previous window
+
, ((modMask, xK_k), windows W.focusUp) --Move focus to the previous window
, ((modMask, xK_a), windows W.focusMaster) --Move focus to the master window
+
, ((modMask, xK_a), windows W.focusMaster) --Move focus to the master window
, ((modMask .|. shiftMask, xK_a), windows W.swapMaster) --Swap the focused window and the master window
+
, ((modMask .|. shiftMask, xK_a), windows W.swapMaster) --Swap the focused window and the master window
, ((modMask .|. shiftMask, xK_j), windows W.swapDown) --Swap the focused window with the next window
+
, ((modMask .|. shiftMask, xK_j), windows W.swapDown) --Swap the focused window with the next window
, ((modMask .|. shiftMask, xK_k), windows W.swapUp) --Swap the focused window with the previous window
+
, ((modMask .|. shiftMask, xK_k), windows W.swapUp) --Swap the focused window with the previous window
, ((modMask, xK_h), sendMessage Shrink) --Shrink the master area
+
, ((modMask, xK_h), sendMessage Shrink) --Shrink the master area
 
, ((modMask .|. shiftMask, xK_Left), sendMessage Shrink)
 
, ((modMask .|. shiftMask, xK_Left), sendMessage Shrink)
, ((modMask, xK_l), sendMessage Expand) --Expand the master area
+
, ((modMask, xK_l), sendMessage Expand) --Expand the master area
 
, ((modMask .|. shiftMask, xK_Right), sendMessage Expand)
 
, ((modMask .|. shiftMask, xK_Right), sendMessage Expand)
, ((modMask .|. shiftMask, xK_h), sendMessage MirrorShrink) --MirrorShrink the master area
+
, ((modMask .|. shiftMask, xK_h), sendMessage MirrorShrink) --MirrorShrink the master area
 
, ((modMask .|. shiftMask, xK_Down), sendMessage MirrorShrink)
 
, ((modMask .|. shiftMask, xK_Down), sendMessage MirrorShrink)
, ((modMask .|. shiftMask, xK_l), sendMessage MirrorExpand) --MirrorExpand the master area
+
, ((modMask .|. shiftMask, xK_l), sendMessage MirrorExpand) --MirrorExpand the master area
 
, ((modMask .|. shiftMask, xK_Up), sendMessage MirrorExpand)
 
, ((modMask .|. shiftMask, xK_Up), sendMessage MirrorExpand)
, ((modMask, xK_t), withFocused $ windows . W.sink) --Push window back into tiling
+
, ((modMask, xK_t), withFocused $ windows . W.sink) --Push window back into tiling
, ((modMask .|. shiftMask, xK_t), rectFloatFocused) --Push window into float
+
, ((modMask .|. shiftMask, xK_t), rectFloatFocused) --Push window into float
, ((modMask, xK_m), withFocused minimizeWindow) --Minimize window
+
, ((modMask, xK_m), withFocused minimizeWindow) --Minimize window
, ((modMask, xK_b), withFocused (sendMessage . maximizeRestore)) --Maximize window
+
, ((modMask, xK_b), withFocused (sendMessage . maximizeRestore)) --Maximize window
, ((modMask .|. shiftMask, xK_m), sendMessage RestoreNextMinimizedWin) --Restore window
+
, ((modMask .|. shiftMask, xK_m), sendMessage RestoreNextMinimizedWin) --Restore window
, ((modMask .|. shiftMask, xK_f), fullFloatFocused) --Push window into full screen
+
, ((modMask .|. shiftMask, xK_f), fullFloatFocused) --Push window into full screen
, ((modMask, xK_comma), sendMessage (IncMasterN 1)) --Increment the number of windows in the master area
+
, ((modMask, xK_comma), sendMessage (IncMasterN 1)) --Increment the number of windows in the master area
, ((modMask, xK_period), sendMessage (IncMasterN (-1))) --Deincrement the number of windows in the master area
+
, ((modMask, xK_period), sendMessage (IncMasterN (-1))) --Deincrement the number of windows in the master area
, ((modMask, xK_Right), sendMessage $ Go R) --Change focus to right
+
, ((modMask, xK_Right), sendMessage $ Go R) --Change focus to right
, ((modMask, xK_Left ), sendMessage $ Go L) --Change focus to left
+
, ((modMask, xK_Left ), sendMessage $ Go L) --Change focus to left
, ((modMask, xK_Up ), sendMessage $ Go U) --Change focus to up
+
, ((modMask, xK_Up ), sendMessage $ Go U) --Change focus to up
, ((modMask, xK_Down ), sendMessage $ Go D) --Change focus to down
+
, ((modMask, xK_Down ), sendMessage $ Go D) --Change focus to down
, ((modMask .|. controlMask, xK_Right), sendMessage $ Swap R) --Swap focused window to right
+
, ((modMask .|. controlMask, xK_Right), sendMessage $ Swap R) --Swap focused window to right
, ((modMask .|. controlMask, xK_Left ), sendMessage $ Swap L) --Swap focused window to left
+
, ((modMask .|. controlMask, xK_Left ), sendMessage $ Swap L) --Swap focused window to left
, ((modMask .|. controlMask, xK_Up ), sendMessage $ Swap U) --Swap focused window to up
+
, ((modMask .|. controlMask, xK_Up ), sendMessage $ Swap U) --Swap focused window to up
, ((modMask .|. controlMask, xK_Down ), sendMessage $ Swap D) --Swap focused window to down
+
, ((modMask .|. controlMask, xK_Down ), sendMessage $ Swap D) --Swap focused window to down
  +
, ((modMask .|. mod1Mask, xK_Left), withFocused (keysMoveWindow (-30,0))) -- move floated window 10 pixels left
  +
, ((modMask .|. mod1Mask, xK_Right), withFocused (keysMoveWindow (30,0))) -- move floated window 10 pixels right
  +
, ((modMask .|. mod1Mask, xK_Up), withFocused (keysMoveWindow (0,-30))) -- move floated window 10 pixels up
  +
, ((modMask .|. mod1Mask, xK_Down), withFocused (keysMoveWindow (0,30))) -- move floated window 10 pixels down
 
--Layout management bindings
 
--Layout management bindings
 
, ((modMask, xK_space), sendMessage NextLayout) --Rotate through the available layout algorithms
 
, ((modMask, xK_space), sendMessage NextLayout) --Rotate through the available layout algorithms
  +
, ((modMask, xK_v ), sendMessage ToggleLayout) --Toggle window titles (can click drag to move windows)
 
, ((modMask .|. shiftMask, xK_space ), flashText myTextConfig 1 " Set to Default Layout " >> (setLayout $ XMonad.layoutHook conf)) --Reset layout to workspaces default
 
, ((modMask .|. shiftMask, xK_space ), flashText myTextConfig 1 " Set to Default Layout " >> (setLayout $ XMonad.layoutHook conf)) --Reset layout to workspaces default
 
, ((modMask, xK_f), sendMessage $ XMonad.Layout.MultiToggle.Toggle TABBED) --Push layout into tabbed
 
, ((modMask, xK_f), sendMessage $ XMonad.Layout.MultiToggle.Toggle TABBED) --Push layout into tabbed
 
, ((modMask .|. controlMask, xK_f), sendMessage $ XMonad.Layout.MultiToggle.Toggle FLOATED) --Push layout into float
 
, ((modMask .|. controlMask, xK_f), sendMessage $ XMonad.Layout.MultiToggle.Toggle FLOATED) --Push layout into float
, ((modMask .|. shiftMask, xK_z), sendMessage $ Toggle MIRROR) --Push layout into mirror
+
, ((modMask .|. shiftMask, xK_z), sendMessage $ XMonad.Layout.MultiToggle.Toggle MIRROR) --Push layout into mirror
 
, ((modMask .|. shiftMask, xK_x), sendMessage $ XMonad.Layout.MultiToggle.Toggle REFLECTX) --Reflect layout by X
 
, ((modMask .|. shiftMask, xK_x), sendMessage $ XMonad.Layout.MultiToggle.Toggle REFLECTX) --Reflect layout by X
 
, ((modMask .|. shiftMask, xK_y), sendMessage $ XMonad.Layout.MultiToggle.Toggle REFLECTY) --Reflect layout by Y
 
, ((modMask .|. shiftMask, xK_y), sendMessage $ XMonad.Layout.MultiToggle.Toggle REFLECTY) --Reflect layout by Y
 
--Gaps management bindings
 
--Gaps management bindings
, ((modMask .|. controlMask, xK_t), sendMessage $ ToggleGaps) --toogle all gaps
+
, ((modMask .|. controlMask, xK_t), sendMessage $ ToggleStruts ) --toogle the all struts
, ((modMask .|. controlMask, xK_u), sendMessage $ ToggleGap U) --toogle the top gap
+
, ((modMask .|. controlMask, xK_u), sendMessage $ ToggleStrut U) --toogle the top strut
, ((modMask .|. controlMask, xK_d), sendMessage $ ToggleGap D) --toogle the bottom gap
+
, ((modMask .|. controlMask, xK_d), sendMessage $ ToggleStrut D) --toogle the bottom strut
 
--Scripts management bindings
 
--Scripts management bindings
, ((modMask , xK_x), spawn "/usr/bin/xcalib -invert -alter") --Invert colors in X
+
, ((modMask, xK_x), spawn "/usr/bin/xcalib -invert -alter") --Invert colors in X
, ((modMask , xK_d), spawn "/usr/bin/killall dzen2") --Kill dzen2
+
, ((modMask, xK_d), spawn "/usr/bin/killall dzen2 haskell-cpu-usage.out") --Kill dzen2
, ((0, xF86XK_AudioMute), spawn $ myBinPath ++ "voldzen.sh t -d") --Mute/unmute volume
+
, ((0, 0x1008ffa9), spawn "/home/nnoell/bin/touchpadtoggle.sh") --Toggle touchpad (xmodmap -pk | grep -i toggle)
, ((0, xF86XK_AudioRaiseVolume), spawn $ myBinPath ++ "voldzen.sh + -d") --Raise volume
+
, ((0, xF86XK_AudioMute), spawn "/home/nnoell/bin/voldzen.sh t -d") --Mute/unmute volume
, ((mod1Mask, xK_Up), spawn $ myBinPath ++ "voldzen.sh + -d")
+
, ((0, xF86XK_AudioRaiseVolume), spawn "/home/nnoell/bin/voldzen.sh + -d") --Raise volume
, ((0, xF86XK_AudioLowerVolume), spawn $ myBinPath ++ "voldzen.sh - -d") --Lower volume
+
, ((mod1Mask, xK_Up), spawn "/home/nnoell/bin/voldzen.sh + -d")
, ((mod1Mask, xK_Down), spawn $ myBinPath ++ "voldzen.sh - -d")
+
, ((0, xF86XK_AudioLowerVolume), spawn "/home/nnoell/bin/voldzen.sh - -d") --Lower volume
  +
, ((mod1Mask, xK_Down), spawn "/home/nnoell/bin/voldzen.sh - -d")
 
, ((0, xF86XK_AudioNext), flashText myTextConfig 1 " Next Song " >> spawn "/usr/bin/ncmpcpp next") --Next song
 
, ((0, xF86XK_AudioNext), flashText myTextConfig 1 " Next Song " >> spawn "/usr/bin/ncmpcpp next") --Next song
 
, ((mod1Mask, xK_Right), flashText myTextConfig 1 " Next Song " >> spawn "/usr/bin/ncmpcpp next")
 
, ((mod1Mask, xK_Right), flashText myTextConfig 1 " Next Song " >> spawn "/usr/bin/ncmpcpp next")
Line 504: Line 483:
 
, ((0, xF86XK_AudioStop), flashText myTextConfig 1 " Song Stopped " >> spawn "/usr/bin/ncmpcpp stop") --Stop song
 
, ((0, xF86XK_AudioStop), flashText myTextConfig 1 " Song Stopped " >> spawn "/usr/bin/ncmpcpp stop") --Stop song
 
, ((mod1Mask .|. controlMask, xK_Up), flashText myTextConfig 1 " Song Stopped " >> spawn "ncmpcpp stop")
 
, ((mod1Mask .|. controlMask, xK_Up), flashText myTextConfig 1 " Song Stopped " >> spawn "ncmpcpp stop")
, ((0, xF86XK_MonBrightnessUp), spawn $ myBinPath ++ "bridzen.sh") --Raise brightness
+
, ((0, xF86XK_MonBrightnessUp), spawn "/home/nnoell/bin/bridzen.sh") --Raise brightness
, ((0, xF86XK_MonBrightnessDown), spawn $ myBinPath ++ "bridzen.sh") --Lower brightness
+
, ((0, xF86XK_MonBrightnessDown), spawn "/home/nnoell/bin/bridzen.sh") --Lower brightness
, ((0, xF86XK_ScreenSaver), spawn $ myBinPath ++ "turnoffscreen.sh") --Lock screen
+
, ((0, xF86XK_ScreenSaver), spawn "/home/nnoell/bin/turnoffscreen.sh") --Lock screen
 
, ((0, xK_Print), spawn "/usr/bin/scrot '%Y-%m-%d_$wx$h.png'") --Take a screenshot
 
, ((0, xK_Print), spawn "/usr/bin/scrot '%Y-%m-%d_$wx$h.png'") --Take a screenshot
, ((modMask , xK_s), spawn $ myBinPath ++ "turnoffscreen.sh") --Turn off screen
+
, ((modMask , xK_s), spawn "/home/nnoell/bin/turnoffscreen.sh") --Turn off screen
 
--Workspaces management bindings
 
--Workspaces management bindings
 
, ((mod1Mask, xK_comma), flashText myTextConfig 1 " Toggled to Previous Workspace " >> toggleWS) --Toggle to the workspace displayed previously
 
, ((mod1Mask, xK_comma), flashText myTextConfig 1 " Toggled to Previous Workspace " >> toggleWS) --Toggle to the workspace displayed previously
Line 516: Line 495:
 
, ((modMask .|. shiftMask, xK_n), flashText myTextConfig 1 " Shifted to Next Workspace " >> shiftToNext) --Send client to next workspace
 
, ((modMask .|. shiftMask, xK_n), flashText myTextConfig 1 " Shifted to Next Workspace " >> shiftToNext) --Send client to next workspace
 
, ((modMask .|. shiftMask, xK_p), flashText myTextConfig 1 " Shifted to Previous Workspace " >> shiftToPrev) --Send client to previous workspace
 
, ((modMask .|. shiftMask, xK_p), flashText myTextConfig 1 " Shifted to Previous Workspace " >> shiftToPrev) --Send client to previous workspace
]
+
] ++
++
+
[ ((m .|. modMask, k), windows $ f i) --Switch to n workspaces and send client to n workspaces
[((m .|. modMask, k), windows $ f i) --Switch to n workspaces and send client to n workspaces
+
| (i, k) <- zip (XMonad.workspaces conf) ([xK_1 .. xK_9] ++ [xK_0])
| (i, k) <- zip (XMonad.workspaces conf) ([xK_1 .. xK_9] ++ [xK_0])
+
, (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]
, (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
+
] ++
++
+
[ ((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f)) --Switch to n screens and send client to n screens
[((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f)) --Switch to n screens and send client to n screens
+
| (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
| (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
+
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
+
] where
where
 
 
fullFloatFocused = withFocused $ \f -> windows =<< appEndo `fmap` runQuery doFullFloat f
 
fullFloatFocused = withFocused $ \f -> windows =<< appEndo `fmap` runQuery doFullFloat f
 
rectFloatFocused = withFocused $ \f -> windows =<< appEndo `fmap` runQuery (doRectFloat $ RationalRect 0.05 0.05 0.9 0.9) f
 
rectFloatFocused = withFocused $ \f -> windows =<< appEndo `fmap` runQuery (doRectFloat $ RationalRect 0.05 0.05 0.9 0.9) f
  +
killAndExit = do
  +
spawn "/usr/bin/killall dzen2 haskell-cpu-usage.out"
  +
io (exitWith ExitSuccess)
  +
killAndRestart = do
  +
spawn "/usr/bin/killall dzen2 haskell-cpu-usage.out"
  +
liftIO $ threadDelay 1000000
  +
restart "xmonad" True
   
 
-- Mouse bindings
 
-- Mouse bindings
Line 536: Line 522:
 
, ((modMask, button4), (\_ -> prevWS)) --Switch to previous workspace
 
, ((modMask, button4), (\_ -> prevWS)) --Switch to previous workspace
 
, ((modMask, button5), (\_ -> nextWS)) --Switch to next workspace
 
, ((modMask, button5), (\_ -> nextWS)) --Switch to next workspace
, (((modMask .|. shiftMask), button4), (\_ -> shiftToPrev)) --Send client to previous workspace
+
, (((modMask .|. shiftMask), button4), (\_ -> shiftToPrev)) --Send client to previous workspace
, (((modMask .|. shiftMask), button5), (\_ -> shiftToNext)) --Send client to next workspace
+
, (((modMask .|. shiftMask), button5), (\_ -> shiftToNext)) --Send client to next workspace
 
]
 
]
 
</haskell>
 
</haskell>

Revision as of 11:22, 25 August 2013

xmonad.hs

--------------------------------------------------------------------------------------------
-- File   : ~/.xmonad/xmonad.hs                                                           --
-- Author : Nnoell <nnoell3[at]gmail.com>                                                 --
-- Deps   : DzenBoxLogger.hs                                                              --
-- Desc   : My XMonad config                                                              --
-- Note   : Do not use "xmonad --recompile", it will throw errors because of non-official --
--          modules. Compile it manually with "ghc -o <outputName> xmonad.hs". EG:        --
--          $ cd ~/.xmonad/                                                               --
--          $ ghc -o xmonad-x86_64-linux xmonad.hs                                        --
--------------------------------------------------------------------------------------------
 
-- Options
{-# LANGUAGE DeriveDataTypeable, NoMonomorphismRestriction, MultiParamTypeClasses, ImplicitParams #-}
 
-- Modules
import XMonad
import XMonad.StackSet (RationalRect(..), currentTag)
import XMonad.Layout
import XMonad.Layout.IM
import XMonad.Layout.Named
import XMonad.Layout.Tabbed
import XMonad.Layout.OneBig
import XMonad.Layout.Master
import XMonad.Layout.Reflect
import XMonad.Layout.MosaicAlt
import XMonad.Layout.NoFrillsDecoration
import XMonad.Layout.SimplestFloat
import XMonad.Layout.NoBorders
import XMonad.Layout.ResizableTile
import XMonad.Layout.MultiToggle
import XMonad.Layout.MultiToggle.Instances
import XMonad.Layout.PerWorkspace (onWorkspace)
import XMonad.Layout.Minimize
import XMonad.Layout.Maximize
import XMonad.Layout.ToggleLayouts
import XMonad.Layout.ComboP
import XMonad.Layout.MagicFocus
import XMonad.Layout.WindowNavigation
import XMonad.Layout.WindowSwitcherDecoration
import XMonad.Layout.DraggingVisualizer
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.DynamicHooks
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.UrgencyHook
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.SetWMName
import XMonad.Hooks.ManageHelpers
import XMonad.Prompt
import XMonad.Prompt.Shell
import XMonad.Prompt.XMonad
import XMonad.Prompt.Man
import XMonad.Util.Timer
import XMonad.Util.Cursor
import XMonad.Util.Loggers
import XMonad.Util.Run (spawnPipe)
import XMonad.Util.Scratchpad
import XMonad.Util.NamedScratchpad
import XMonad.Actions.CycleWS
import XMonad.Actions.ShowText
import XMonad.Actions.GridSelect
import XMonad.Actions.MouseResize
import XMonad.Actions.FloatKeys
import Data.Monoid
import Data.List
import Graphics.X11.ExtraTypes.XF86
import System.Exit
import System.IO (Handle, hPutStrLn)
import Control.Concurrent (threadDelay)
import Control.Exception as E
import qualified XMonad.StackSet as W
import qualified Data.Map as M
import qualified XMonad.Actions.FlexibleResize as Flex
import qualified XMonad.Util.ExtensibleState as XS
 
-- Non-official modules
import DzenBoxLoggers
 
 
--------------------------------------------------------------------------------------------
-- MAIN                                                                                   --
--------------------------------------------------------------------------------------------
 
main :: IO ()
main = do
	topLeftBar  <- spawnPipe $ dzenFlagsToStr dzenTopLeftFlags
	topRightBar <- spawnPipe $ dzenFlagsToStr dzenTopRightFlags
	botLeftBar  <- spawnPipe $ dzenFlagsToStr dzenBotLeftFlags
	botRightBar <- spawnPipe $ dzenFlagsToStr dzenBotRightFlags
	xmonad $ myUrgencyHook $ defaultConfig
		{ terminal           = "urxvtc"          --default terminal
		, modMask            = mod4Mask          --default modMask
		, focusFollowsMouse  = True              --focus follow config
		, clickJustFocuses   = True              --focus click config
		, borderWidth        = 1                 --border width
		, normalBorderColor  = colorBlackAlt     --border color
		, focusedBorderColor = colorWhiteAlt2    --focused border color
		, workspaces         = myWorkspaces      --workspace names
		, startupHook        = myStartupHook     --autostart config
		, handleEventHook    = myHandleEventHook --event config
		, layoutHook         = myLayoutHook      --layout config
		, manageHook         = myManageHook      --xprop config
		, logHook            = do                --status bar config
			myTopLeftLogHook topLeftBar            --top left dzen
			myTopRightLogHook topRightBar          --top right dzen
			myBotLeftLogHook botLeftBar            --bottom left dzen
			myBotRightLogHook botRightBar          --bottom right dzen
			ewmhDesktopsLogHook
			setWMName "LG3D"
		, keys               = myKeys            --key bindings config
		, mouseBindings      = myMouseBindings   --mouse bindings config
		}
 
 
--------------------------------------------------------------------------------------------
-- LOOK AND FEEL CONFIG                                                                   --
--------------------------------------------------------------------------------------------
 
-- Colors, fonts and paths
dzenFont       = "-*-montecarlo-medium-r-normal-*-11-*-*-*-*-*-*-*"
colorBlack     = "#020202" --Background
colorBlackAlt  = "#1c1c1c" --Black Xdefaults
colorGray      = "#444444" --Gray
colorGrayAlt   = "#101010" --Gray dark
colorGrayAlt2  = "#404040"
colorGrayAlt3  = "#252525"
colorWhite     = "#a9a6af" --Foreground
colorWhiteAlt  = "#9d9d9d" --White dark
colorWhiteAlt2 = "#b5b3b3"
colorWhiteAlt3 = "#707070"
colorMagenta   = "#8e82a2"
colorBlue      = "#44aacc"
colorBlueAlt   = "#3955c4"
colorRed       = "#f7a16e"
colorRedAlt    = "#e0105f"
colorGreen     = "#66ff66"
colorGreenAlt  = "#558965"
boxLeftIcon    = "/home/nnoell/.icons/xbm_icons/subtle/boxleft.xbm"   --left icon of dzen logger boxes
boxLeftIcon2   = "/home/nnoell/.icons/xbm_icons/subtle/boxleft2.xbm"  --left icon2 of dzen logger boxes
boxRightIcon   = "/home/nnoell/.icons/xbm_icons/subtle/boxright.xbm"  --right icon of dzen logger boxes
xRes           = 1366
yRes           = 768
panelHeight    = 14  --height of top and bottom panels
boxHeight      = 14  --height of dzen logger box
topPanelSepPos = 950 --left-right alignment pos of top panel
botPanelSepPos = 400 --left-right alignment pos of bottom panel
 
-- Title theme
myTitleTheme :: Theme
myTitleTheme = defaultTheme
	{ fontName            = dzenFont
	, inactiveBorderColor = colorGrayAlt2
	, inactiveColor       = colorGrayAlt3
	, inactiveTextColor   = colorWhiteAlt3
	, activeBorderColor   = colorGrayAlt2
	, activeColor         = colorGrayAlt2
	, activeTextColor     = colorWhiteAlt2
	, urgentBorderColor   = colorGray
	, urgentTextColor     = colorGreen
	, decoHeight          = 14
	}
 
-- Prompt theme
myXPConfig :: XPConfig
myXPConfig = defaultXPConfig
	{ font              = dzenFont
	, bgColor           = colorBlack
	, fgColor           = colorWhite
	, bgHLight          = colorBlue
	, fgHLight          = colorBlack
	, borderColor       = colorGrayAlt
	, promptBorderWidth = 1
	, height            = panelHeight
	, position          = Top
	, historySize       = 100
	, historyFilter     = deleteConsecutive
	, autoComplete      = Nothing
	}
 
-- GridSelect color scheme
myColorizer :: Window -> Bool -> X (String, String)
myColorizer = colorRangeFromClassName
	(0x00,0x00,0x00) --lowest inactive bg
	(0x1C,0x1C,0x1C) --highest inactive bg
	(0x44,0xAA,0xCC) --active bg
	(0xBB,0xBB,0xBB) --inactive fg
	(0x00,0x00,0x00) --active fg
 
-- GridSelect theme
myGSConfig :: t -> GSConfig Window
myGSConfig colorizer = (buildDefaultGSConfig myColorizer)
	{ gs_cellheight  = 50
	, gs_cellwidth   = 200
	, gs_cellpadding = 10
	, gs_font        = dzenFont
	}
 
-- Flash text config
myTextConfig :: ShowTextConfig
myTextConfig = STC
	{ st_font = dzenFont
	, st_bg   = colorBlack
	, st_fg   = colorWhite
	}
 
-- Dzen logger box pretty printing themes
gray2BoxPP :: BoxPP
gray2BoxPP = BoxPP
	{ bgColorBPP   = colorBlack
	, fgColorBPP   = colorGray
	, boxColorBPP  = colorGrayAlt
	, leftIconBPP  = boxLeftIcon2
	, rightIconBPP = boxRightIcon
	, boxHeightBPP = boxHeight
	}
 
blueBoxPP :: BoxPP
blueBoxPP = BoxPP
	{ bgColorBPP   = colorBlack
	, fgColorBPP   = colorBlue
	, boxColorBPP  = colorGrayAlt
	, leftIconBPP  = boxLeftIcon
	, rightIconBPP = boxRightIcon
	, boxHeightBPP = boxHeight
	}
 
blue2BoxPP :: BoxPP
blue2BoxPP = BoxPP
	{ bgColorBPP   = colorBlack
	, fgColorBPP   = colorBlue
	, boxColorBPP  = colorGrayAlt
	, leftIconBPP  = boxLeftIcon2
	, rightIconBPP = boxRightIcon
	, boxHeightBPP = boxHeight
	}
 
whiteBoxPP :: BoxPP
whiteBoxPP = BoxPP
	{ bgColorBPP   = colorBlack
	, fgColorBPP   = colorWhiteAlt
	, boxColorBPP  = colorGrayAlt
	, leftIconBPP  = boxLeftIcon
	, rightIconBPP = boxRightIcon
	, boxHeightBPP = boxHeight
	}
 
blackBoxPP :: BoxPP
blackBoxPP = BoxPP
	{ bgColorBPP   = colorBlack
	, fgColorBPP   = colorBlack
	, boxColorBPP  = colorGrayAlt
	, leftIconBPP  = boxLeftIcon
	, rightIconBPP = boxRightIcon
	, boxHeightBPP = boxHeight
	}
 
white2BBoxPP :: BoxPP
white2BBoxPP = BoxPP
	{ bgColorBPP   = colorBlack
	, fgColorBPP   = colorBlack
	, boxColorBPP  = colorWhiteAlt
	, leftIconBPP  = boxLeftIcon2
	, rightIconBPP = boxRightIcon
	, boxHeightBPP = boxHeight
	}
 
blue2BBoxPP :: BoxPP --current workspace
blue2BBoxPP = BoxPP
	{ bgColorBPP   = colorBlack
	, fgColorBPP   = colorBlack
	, boxColorBPP  = colorBlue
	, leftIconBPP  = boxLeftIcon2
	, rightIconBPP = boxRightIcon
	, boxHeightBPP = boxHeight
	}
 
green2BBoxPP :: BoxPP --urgent workspace
green2BBoxPP = BoxPP
	{ bgColorBPP   = colorBlack
	, fgColorBPP   = colorBlack
	, boxColorBPP  = colorGreen
	, leftIconBPP  = boxLeftIcon2
	, rightIconBPP = boxRightIcon
	, boxHeightBPP = boxHeight
	}
 
-- Dzen logger clickable areas
calendarCA :: CA
calendarCA = CA
	{ leftClickCA   = "/home/nnoell/bin/dzencal.sh"
	, middleClickCA = "/home/nnoell/bin/dzencal.sh"
	, rightClickCA  = "/home/nnoell/bin/dzencal.sh"
	, wheelUpCA     = "/home/nnoell/bin/dzencal.sh"
	, wheelDownCA   = "/home/nnoell/bin/dzencal.sh"
	}
 
layoutCA :: CA
layoutCA = CA
	{ leftClickCA   = "/usr/bin/xdotool key super+space"
	, middleClickCA = "/usr/bin/xdotool key super+v"
	, rightClickCA  = "/usr/bin/xdotool key super+shift+space"
	, wheelUpCA     = "/usr/bin/xdotool key super+f"
	, wheelDownCA   = "/usr/bin/xdotool key super+control+f"
	}
 
workspaceCA :: CA
workspaceCA = CA
	{ leftClickCA   = "/usr/bin/xdotool key super+1"
	, middleClickCA = "/usr/bin/xdotool key super+g"
	, rightClickCA  = "/usr/bin/xdotool key super+0"
	, wheelUpCA     = "/usr/bin/xdotool key ctrl+alt+Right"
	, wheelDownCA   = "/usr/bin/xdotool key ctrl+alt+Left"
	}
 
focusCA :: CA
focusCA = CA
	{ leftClickCA   = "/usr/bin/xdotool key super+m"
	, middleClickCA = "/usr/bin/xdotool key super+c"
	, rightClickCA  = "/usr/bin/xdotool key super+shift+m"
	, wheelUpCA     = "/usr/bin/xdotool key super+shift+j"
	, wheelDownCA   = "/usr/bin/xdotool key super+shift+k"
	}
 
-- Workspace index
myWorkspaces :: [WorkspaceId]
myWorkspaces = map show $ [1..9] ++ [0]
 
-- Workspace names
workspaceNames :: [WorkspaceId]
workspaceNames = ["Terminal"
				 , "Network"
				 , "Development"
				 , "Graphics"
				 , "Chatting"
				 , "Video"
				 , "Alternate"
				 , "Alternate"
				 , "Alternate"
				 , "Alternate"
				 ]
 
-- Layout names (must be one word name and not equal to: Mirror, ReflectX, ReflectY, Switcher, Normal and Unique)
myTileName = "Tiled"
myMirrName = "Mirror"
myMosAName = "Mosaic"
myOneBName = "OneBig"
myMTabName = "MstrTab"
myChatName = "Chat"
myTabbName = "Tabbed"
myTTabName = "TwoTab"
myFTabName = "Full"
myFloaName = "Float"
 
 
--------------------------------------------------------------------------------------------
-- STARTUP HOOK CONFIG                                                                    --
--------------------------------------------------------------------------------------------
 
-- Startup Hook
myStartupHook = do
	setDefaultCursor xC_left_ptr
	spawn "/usr/bin/killall haskell-cpu-usage.out"
	liftIO $ threadDelay 1000000 --needed so that xmonad can be recompiled and launched on the fly without crashing
	spawn "/home/nnoell/.xmonad/apps/haskell-cpu-usage.out 5"
	startTimer 1 >>= XS.put . TID
 
 
--------------------------------------------------------------------------------------------
-- HANDLE EVENT HOOK CONFIG                                                               --
--------------------------------------------------------------------------------------------
 
-- Wrapper for the Timer id, so it can be stored as custom mutable state
data TidState = TID TimerId deriving Typeable
 
instance ExtensionClass TidState where
	initialValue = TID 0
 
-- Handle event hook
myHandleEventHook = fullscreenEventHook <+> docksEventHook <+> clockEventHook <+> handleTimerEvent <+> notFocusFloat where
	clockEventHook e = do                 --thanks to DarthFennec
		(TID t) <- XS.get                 --get the recent Timer id
		handleTimer t e $ do              --run the following if e matches the id
		    startTimer 1 >>= XS.put . TID --restart the timer, store the new id
		    ask >>= logHook . config      --get the loghook and run it
		    return Nothing                --return required type
		return $ All True                 --return required type
	notFocusFloat = followOnlyIf (fmap not isFloat) where --Do not focusFollowMouse on Float layout
		isFloat = fmap (isSuffixOf myFloaName) $ gets (description . W.layout . W.workspace . W.current . windowset)
 
 
--------------------------------------------------------------------------------------------
-- LAYOUT CONFIG                                                                          --
--------------------------------------------------------------------------------------------
 
-- Tabbed transformer (W+f)
data TABBED = TABBED deriving (Read, Show, Eq, Typeable)
instance Transformer TABBED Window where
	transform TABBED x k = k myFTabU (\_ -> x)
 
-- Floated transformer (W+ctl+f)
data FLOATED = FLOATED deriving (Read, Show, Eq, Typeable)
instance Transformer FLOATED Window where
	transform FLOATED x k = k myFloaU (\_ -> x)
 
-- Normal Layouts
myTileN = ResizableTall 1 0.03 0.5 []
myMirrN = Mirror myTileN
myMosAN = MosaicAlt M.empty
myOneBN = OneBig 0.75 0.65
myTabbN = tabbed shrinkText myTitleTheme
myMTabN = mastered 0.01 0.4 $ myTabbN
myChatN = withIM (0.20) (Title "Buddy List") myMosAN
 
-- Switcher Layouts
myTileS = windowSwitcherDecoration shrinkText myTitleTheme $ draggingVisualizer myTileN
myMirrS = windowSwitcherDecoration shrinkText myTitleTheme $ draggingVisualizer myTileN
myMosAS = windowSwitcherDecoration shrinkText myTitleTheme $ draggingVisualizer myMosAN
myOneBS = windowSwitcherDecoration shrinkText myTitleTheme $ draggingVisualizer myOneBN
myMTabS = windowSwitcherDecoration shrinkText myTitleTheme $ draggingVisualizer myMTabN
myChatS = withIM (0.20) (Title "Buddy List") myMosAS
 
-- Toggled Layouts
myTileT = smartBorders $ toggleLayouts (named ("Switcher " ++ myTileName) myTileS) (named ("Normal " ++ myTileName) myTileN)
myMirrT = smartBorders $ toggleLayouts (named ("Switcher " ++ myMirrName) myMirrS) (named ("Normal " ++ myMirrName) myMirrN)
myMosAT = smartBorders $ toggleLayouts (named ("Switcher " ++ myMosAName) myMosAS) (named ("Normal " ++ myMosAName) myMosAN)
myOneBT = smartBorders $ toggleLayouts (named ("Switcher " ++ myOneBName) myOneBS) (named ("Normal " ++ myOneBName) myOneBN)
myMTabT = smartBorders $ toggleLayouts (named ("Switcher " ++ myMTabName) myMTabS) (named ("Normal " ++ myMTabName) myMTabN)
myChatT = smartBorders $ toggleLayouts (named ("Switcher " ++ myChatName) myChatS) (named ("Normal " ++ myChatName) myChatN)
 
-- Unique Layouts
myTabbU = smartBorders $ named ("Unique " ++ myTabbName) myTabbN
myTTabU = smartBorders $ named ("Unique " ++ myTTabName) $ combineTwoP myOneBN myTabbN myTabbN $ ClassName "Chromium"
myFTabU = smartBorders $ named ("Unique " ++ myFTabName) $ tabbedAlways shrinkText myTitleTheme
myFloaU = named ("Unique " ++ myFloaName) $ mouseResize $ noFrillsDeco shrinkText myTitleTheme simplestFloat
 
-- Layout hook
myLayoutHook = avoidStruts
	$ configurableNavigation noNavigateBorders
	$ minimize
	$ maximize
	$ mkToggle (single TABBED)
	$ mkToggle (single FLOATED)
	$ mkToggle (single MIRROR)
	$ mkToggle (single REFLECTX)
	$ mkToggle (single REFLECTY)
	$ onWorkspace (myWorkspaces !! 1) webLayouts
	$ onWorkspace (myWorkspaces !! 2) codeLayouts
	$ onWorkspace (myWorkspaces !! 4) chatLayouts
	$ allLayouts where
		webLayouts  = myTabbU ||| myTTabU
		codeLayouts = myMTabT ||| myOneBT ||| myTileT
		chatLayouts = myChatT
		allLayouts  = myTileT ||| myOneBT ||| myMirrT ||| myMosAT ||| myMTabT
 
 
--------------------------------------------------------------------------------------------
-- MANAGE HOOK CONFIG                                                                     --
--------------------------------------------------------------------------------------------
 
-- Manage Hook
myManageHook :: ManageHook
myManageHook = manageWindows <+> manageScratchPad <+> manageDocks <+> dynamicMasterHook
 
-- Scratchpad (W+º)
manageScratchPad :: ManageHook
manageScratchPad = scratchpadManageHook $ W.RationalRect (0) (panelHeight/yRes) (1) (3/4)
scratchPad = scratchpadSpawnActionCustom "urxvtc -name scratchpad"
 
-- Manage hook
manageWindows :: ManageHook
manageWindows = composeAll . concat $
	[ [ resource  =? r --> doIgnore                    | r <- myIgnores ]
	, [ className =? c --> doShift (myWorkspaces !! 1) | c <- myWebS    ]
	, [ className =? c --> doShift (myWorkspaces !! 2) | c <- myCodeS   ]
	, [ className =? c --> doShift (myWorkspaces !! 3) | c <- myGfxS    ]
	, [ className =? c --> doShift (myWorkspaces !! 4) | c <- myChatS   ]
	, [ className =? c --> doShift (myWorkspaces !! 7) | c <- myAlt3S   ]
	, [ className =? c --> doCenterFloat               | c <- myFloatCC ]
	, [ name      =? n --> doCenterFloat               | n <- myFloatCN ]
	, [ name      =? n --> doSideFloat NW              | n <- myFloatSN ]
	, [ className =? c --> doF W.focusDown             | c <- myFocusDC ]
	, [ isFullscreen   --> doFullFloat ]
	] where
		name      = stringProperty "WM_NAME"
		myIgnores = ["desktop","desktop_window"]
		myWebS    = ["Chromium","Firefox", "Opera"]
		myCodeS   = ["NetBeans IDE 7.3"]
		myChatS   = ["Pidgin", "Xchat"]
		myGfxS    = ["Gimp", "gimp", "GIMP"]
		myAlt3S   = ["Amule", "Transmission-gtk"]
		myFloatCC = ["MPlayer", "mplayer2", "File-roller", "zsnes", "Gcalctool", "Exo-helper-1", "Gksu", "PSX", "Galculator", "Nvidia-settings", "XFontSel"
			        , "XCalc", "XClock", "Ossxmix", "Xvidcap", "Main", "Wicd-client.py"]
		myFloatCN = ["Choose a file", "Open Image", "File Operation Progress", "Firefox Preferences", "Preferences", "Search Engines", "Set up sync"
			        ,"Passwords and Exceptions", "Autofill Options", "Rename File", "Copying files", "Moving files", "File Properties", "Replace", ""]
		myFloatSN = ["Event Tester"]
		myFocusDC = ["Event Tester", "Notify-osd"]
 
 
--------------------------------------------------------------------------------------------
-- DZEN STATUS BARS CONFIG                                                                --
--------------------------------------------------------------------------------------------
 
-- urgencyHook
myUrgencyHook :: LayoutClass l Window => XConfig l -> XConfig l
myUrgencyHook = withUrgencyHook dzenUrgencyHook
	{ duration = 2000000
	, args     = ["-x", "0"
		         , "-y", "0"
		         , "-h", show panelHeight
		         , "-w", show topPanelSepPos
		         , "-fn", dzenFont
		         , "-bg", colorBlack
		         , "-fg", colorGreen
		         ]
	}
 
-- Dzen top left bar flags
dzenTopLeftFlags :: DF
dzenTopLeftFlags = DF
	{ xPosDF       = 0
	, yPosDF       = 0
	, widthDF      = topPanelSepPos
	, heightDF     = panelHeight
	, alignementDF = "l"
	, fgColorDF    = colorWhiteAlt
	, bgColorDF    = colorBlack
	, fontDF       = dzenFont
	, eventDF      = "onstart=lower"
	, extrasDF     = "-p"
	}
 
-- Top left bar logHook
myTopLeftLogHook :: Handle -> X ()
myTopLeftLogHook h = dynamicLogWithPP $ defaultPP
	{ ppOutput = hPutStrLn h
	, ppOrder = \(_:_:_:x) -> x
	, ppSep = " "
	, ppExtras = [ myLayoutL, myWorkspaceL, myFocusL ]
	}
 
-- Dzen top right bar flags
dzenTopRightFlags :: DF
dzenTopRightFlags = DF
	{ xPosDF       = topPanelSepPos
	, yPosDF       = 0
	, widthDF      = xRes - topPanelSepPos
	, heightDF     = panelHeight
	, alignementDF = "r"
	, fgColorDF    = colorWhiteAlt
	, bgColorDF    = colorBlack
	, fontDF       = dzenFont
	, eventDF      = "onstart=lower"
	, extrasDF     = "-p"
	}
 
-- Top right bar logHook
myTopRightLogHook :: Handle -> X ()
myTopRightLogHook h = dynamicLogWithPP $ defaultPP
	{ ppOutput  = hPutStrLn h
	, ppOrder = \(_:_:_:x) -> x
	, ppSep = " "
	, ppExtras  = [ myUptimeL, myDateL ]
	}
 
-- Dzen bottom left bar flags
dzenBotLeftFlags :: DF
dzenBotLeftFlags = DF
	{ xPosDF       = 0
	, yPosDF       = yRes - panelHeight
	, widthDF      = botPanelSepPos
	, heightDF     = panelHeight
	, alignementDF = "l"
	, fgColorDF    = colorWhiteAlt
	, bgColorDF    = colorBlack
	, fontDF       = dzenFont
	, eventDF      = "onstart=lower"
	, extrasDF     = "-p"
	}
 
-- Bottom left bar logHook
myBotLeftLogHook :: Handle -> X ()
myBotLeftLogHook h = dynamicLogWithPP . namedScratchpadFilterOutWorkspacePP $ defaultPP
	{ ppOutput          = hPutStrLn h
	, ppOrder           = \(ws:l:_:x) -> [ws] ++ x
	, ppSep             = " "
	, ppWsSep           = ""
	, ppCurrent         = dzenBoxStyle blue2BBoxPP
	, ppUrgent          = dzenBoxStyle green2BBoxPP . dzenClickWorkspace
	, ppVisible         = dzenBoxStyle blackBoxPP . dzenClickWorkspace
	, ppHiddenNoWindows = dzenBoxStyle blackBoxPP . dzenClickWorkspace
	, ppHidden          = dzenBoxStyle whiteBoxPP . dzenClickWorkspace
	, ppExtras          = [ myFsL ]
	} where
		dzenClickWorkspace ws = "^ca(1," ++ xdo "w;" ++ xdo index ++ ")" ++ "^ca(3," ++ xdo "w;" ++ xdo index ++ ")" ++ ws ++ "^ca()^ca()" where
			wsIdxToString Nothing = "1"
			wsIdxToString (Just n) = show $ mod (n+1) $ length myWorkspaces
			index = wsIdxToString (elemIndex ws myWorkspaces)
			xdo key = "/usr/bin/xdotool key super+" ++ key
 
-- Dzen bottom right bar flags
dzenBotRightFlags :: DF
dzenBotRightFlags = DF
	{ xPosDF       = botPanelSepPos
	, yPosDF       = yRes - panelHeight
	, widthDF      = xRes - botPanelSepPos
	, heightDF     = panelHeight
	, alignementDF = "r"
	, fgColorDF    = colorWhiteAlt
	, bgColorDF    = colorBlack
	, fontDF       = dzenFont
	, eventDF      = "onstart=lower"
	, extrasDF     = "-p"
	}
 
-- Bottom right bar logHook
myBotRightLogHook :: Handle -> X ()
myBotRightLogHook h = dynamicLogWithPP $ defaultPP
	{ ppOutput = hPutStrLn h
	, ppOrder  = \(_:_:_:x) -> x
	, ppSep    = " "
	, ppExtras = [ myCpuL, myMemL, myTempL, myBrightL, myWifiL, myBatL ]
	}
 
 
--------------------------------------------------------------------------------------------
-- LOGGERS CONFIG                                                                         --
--------------------------------------------------------------------------------------------
 
myBatL       = (dzenBoxStyleL gray2BoxPP $ labelL "BATTERY") ++! (dzenBoxStyleL blueBoxPP batPercent) ++! (dzenBoxStyleL whiteBoxPP batStatus)
myWifiL      = (dzenBoxStyleL gray2BoxPP $ labelL "WIFI") ++! (dzenBoxStyleL blueBoxPP wifiSignal)
myBrightL    = (dzenBoxStyleL gray2BoxPP $ labelL "BRIGHT") ++! (dzenBoxStyleL blueBoxPP brightPerc)
myTempL      = (dzenBoxStyleL gray2BoxPP $ labelL "TEMP") ++! (dzenBoxStyleL blueBoxPP cpuTemp)
myMemL       = (dzenBoxStyleL gray2BoxPP $ labelL "MEM") ++! (dzenBoxStyleL blueBoxPP memUsage)
myCpuL       = (dzenBoxStyleL gray2BoxPP $ labelL "CPU") ++! (dzenBoxStyleL blueBoxPP $ cpuUsage "/tmp/haskell-cpu-usage.txt")
myFsL        = (dzenBoxStyleL blue2BoxPP $ labelL "ROOT") ++! (dzenBoxStyleL whiteBoxPP $ fsPerc "/") ++! (dzenBoxStyleL blueBoxPP $ labelL "HOME") ++! (dzenBoxStyleL whiteBoxPP $ fsPerc "/home")
myDateL      = (dzenBoxStyleL white2BBoxPP $ date "%A") ++! (dzenBoxStyleL whiteBoxPP $ date $ "%Y^fg(" ++ colorGray ++ ").^fg()%m^fg(" ++ colorGray ++ ").^fg()^fg(" ++ colorBlue ++ ")%d^fg() ^fg(" ++ colorGray ++ ")-^fg() %H^fg(" ++ colorGray ++ "):^fg()%M^fg(" ++ colorGray ++ "):^fg()^fg(" ++ colorGreen ++ ")%S^fg()") ++! (dzenClickStyleL calendarCA $ dzenBoxStyleL blueBoxPP $ labelL "CALENDAR")
myUptimeL    = (dzenBoxStyleL blue2BoxPP $ labelL "UPTIME") ++! (dzenBoxStyleL whiteBoxPP uptime)
myFocusL     = (dzenClickStyleL focusCA $ dzenBoxStyleL white2BBoxPP $ labelL "FOCUS") ++! (dzenBoxStyleL whiteBoxPP $ shortenL 100 logTitle)
myLayoutL    = (dzenClickStyleL layoutCA $ dzenBoxStyleL blue2BoxPP $ labelL "LAYOUT") ++! (dzenBoxStyleL whiteBoxPP $ onLogger (layoutText . removeWord . removeWord) logLayout) where
	removeWord xs = tail $ dropWhile (/= ' ') xs
	layoutText xs
		| isPrefixOf "Mirror" xs   = layoutText $ removeWord xs ++ " ^fg(" ++ colorBlue ++ ")M^fg(" ++ colorGray ++ ")|^fg(" ++ colorWhiteAlt ++ ")"
		| isPrefixOf "ReflectY" xs = layoutText $ removeWord xs ++ " ^fg(" ++ colorBlue ++ ")Y^fg(" ++ colorGray ++ ")|^fg(" ++ colorWhiteAlt ++ ")"
		| isPrefixOf "ReflectX" xs = layoutText $ removeWord xs ++ " ^fg(" ++ colorBlue ++ ")X^fg(" ++ colorGray ++ ")|^fg(" ++ colorWhiteAlt ++ ")"
		| isPrefixOf "Switcher" xs = layoutText $ removeWord xs ++ " ^fg(" ++ colorRed ++ ")S^fg(" ++ colorGray ++ ")|^fg(" ++ colorWhiteAlt ++ ")"
		| isPrefixOf "Normal" xs   = layoutText $ removeWord xs ++ " ^fg(" ++ colorGreen ++ ")N^fg(" ++ colorGray ++ ")|^fg(" ++ colorWhiteAlt ++ ")"
		| isPrefixOf "Unique" xs   = layoutText $ removeWord xs ++ " ^fg(" ++ colorGreen ++ ")U^fg(" ++ colorGray ++ ")|^fg(" ++ colorWhiteAlt ++ ")"
		| otherwise                = concat $ reverse $ words xs
myWorkspaceL = (dzenClickStyleL workspaceCA $ dzenBoxStyleL blue2BoxPP $ labelL "WORKSPACE") ++! (dzenBoxStyleL whiteBoxPP $ onLogger namedWorkspaces logCurrent) where
	namedWorkspaces w
		| (elem w $ map show [0..9]) == True = "^fg(" ++ colorGreen ++ ")" ++ w ++ "^fg(" ++ colorGray ++ ")|^fg()" ++ workspaceNames !! (mod ((read w::Int) - 1) 10)
		| otherwise                          = "^fg(" ++ colorRed ++ ")x^fg(" ++ colorGray ++ ")|^fg()" ++ w
 
 
--------------------------------------------------------------------------------------------
-- BINDINGS CONFIG                                                                        --
--------------------------------------------------------------------------------------------
 
-- Key bindings
myKeys :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ())
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
	--Xmonad bindings
	[((modMask .|. shiftMask, xK_q), killAndExit)                        --Quit xmonad
	, ((modMask, xK_q), killAndRestart)                                  --Restart xmonad
	, ((mod1Mask, xK_F2), shellPrompt myXPConfig)                        --Launch Xmonad shell prompt
	, ((modMask, xK_F2), xmonadPrompt myXPConfig)                        --Launch Xmonad prompt
	, ((mod1Mask, xK_F3), manPrompt myXPConfig)                          --Launch man prompt
	, ((modMask, xK_g), goToSelected $ myGSConfig myColorizer)           --Launch GridSelect
	, ((modMask, xK_masculine), scratchPad)                              --Scratchpad
	, ((modMask .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf) --Launch default terminal
	--Window management bindings
	, ((modMask, xK_c), kill)                                                 --Close focused window
	, ((mod1Mask, xK_F4), kill)
	, ((modMask, xK_n), refresh)                                              --Resize viewed windows to the correct size
	, ((modMask, xK_Tab), windows W.focusDown)                                --Move focus to the next window
	, ((modMask, xK_j), windows W.focusDown)
	, ((mod1Mask, xK_Tab), windows W.focusDown)
	, ((modMask, xK_k), windows W.focusUp)                                    --Move focus to the previous window
	, ((modMask, xK_a), windows W.focusMaster)                                --Move focus to the master window
	, ((modMask .|. shiftMask, xK_a), windows W.swapMaster)                   --Swap the focused window and the master window
	, ((modMask .|. shiftMask, xK_j), windows W.swapDown)                     --Swap the focused window with the next window
	, ((modMask .|. shiftMask, xK_k), windows W.swapUp)                       --Swap the focused window with the previous window
	, ((modMask, xK_h), sendMessage Shrink)                                   --Shrink the master area
	, ((modMask .|. shiftMask, xK_Left), sendMessage Shrink)
	, ((modMask, xK_l), sendMessage Expand)                                   --Expand the master area
	, ((modMask .|. shiftMask, xK_Right), sendMessage Expand)
	, ((modMask .|. shiftMask, xK_h), sendMessage MirrorShrink)               --MirrorShrink the master area
	, ((modMask .|. shiftMask, xK_Down), sendMessage MirrorShrink)
	, ((modMask .|. shiftMask, xK_l), sendMessage MirrorExpand)               --MirrorExpand the master area
	, ((modMask .|. shiftMask, xK_Up), sendMessage MirrorExpand)
	, ((modMask, xK_t), withFocused $ windows . W.sink)                       --Push window back into tiling
	, ((modMask .|. shiftMask, xK_t), rectFloatFocused)                       --Push window into float
	, ((modMask, xK_m), withFocused minimizeWindow)                           --Minimize window
	, ((modMask, xK_b), withFocused (sendMessage . maximizeRestore))          --Maximize window
	, ((modMask .|. shiftMask, xK_m), sendMessage RestoreNextMinimizedWin)    --Restore window
	, ((modMask .|. shiftMask, xK_f), fullFloatFocused)                       --Push window into full screen
	, ((modMask, xK_comma), sendMessage (IncMasterN 1))                       --Increment the number of windows in the master area
	, ((modMask, xK_period), sendMessage (IncMasterN (-1)))                   --Deincrement the number of windows in the master area
	, ((modMask, xK_Right), sendMessage $ Go R)                               --Change focus to right
	, ((modMask, xK_Left ), sendMessage $ Go L)                               --Change focus to left
	, ((modMask, xK_Up   ), sendMessage $ Go U)                               --Change focus to up
	, ((modMask, xK_Down ), sendMessage $ Go D)                               --Change focus to down
	, ((modMask .|. controlMask, xK_Right), sendMessage $ Swap R)             --Swap focused window to right
	, ((modMask .|. controlMask, xK_Left ), sendMessage $ Swap L)             --Swap focused window to left
	, ((modMask .|. controlMask, xK_Up   ), sendMessage $ Swap U)             --Swap focused window to up
	, ((modMask .|. controlMask, xK_Down ), sendMessage $ Swap D)             --Swap focused window to down
	, ((modMask .|. mod1Mask, xK_Left), withFocused (keysMoveWindow (-30,0))) -- move floated window 10 pixels left
	, ((modMask .|. mod1Mask, xK_Right), withFocused (keysMoveWindow (30,0))) -- move floated window 10 pixels right
	, ((modMask .|. mod1Mask, xK_Up), withFocused (keysMoveWindow (0,-30)))   -- move floated window 10 pixels up
	, ((modMask .|. mod1Mask, xK_Down), withFocused (keysMoveWindow (0,30)))  -- move floated window 10 pixels down
	--Layout management bindings
	, ((modMask, xK_space), sendMessage NextLayout)                                                                                    --Rotate through the available layout algorithms
	, ((modMask, xK_v ), sendMessage ToggleLayout)                                                                                     --Toggle window titles (can click drag to move windows)
	, ((modMask .|. shiftMask, xK_space ), flashText myTextConfig 1 " Set to Default Layout " >> (setLayout $ XMonad.layoutHook conf)) --Reset layout to workspaces default
	, ((modMask, xK_f), sendMessage $ XMonad.Layout.MultiToggle.Toggle TABBED)                                                         --Push layout into tabbed
	, ((modMask .|. controlMask, xK_f), sendMessage $ XMonad.Layout.MultiToggle.Toggle FLOATED)                                        --Push layout into float
	, ((modMask .|. shiftMask, xK_z), sendMessage $ XMonad.Layout.MultiToggle.Toggle MIRROR)                                           --Push layout into mirror
	, ((modMask .|. shiftMask, xK_x), sendMessage $ XMonad.Layout.MultiToggle.Toggle REFLECTX)                                         --Reflect layout by X
	, ((modMask .|. shiftMask, xK_y), sendMessage $ XMonad.Layout.MultiToggle.Toggle REFLECTY)                                         --Reflect layout by Y
	--Gaps management bindings
	, ((modMask .|. controlMask, xK_t), sendMessage $ ToggleStruts ) --toogle the all struts
	, ((modMask .|. controlMask, xK_u), sendMessage $ ToggleStrut U) --toogle the top strut
	, ((modMask .|. controlMask, xK_d), sendMessage $ ToggleStrut D) --toogle the bottom strut
	--Scripts management bindings
	, ((modMask, xK_x), spawn "/usr/bin/xcalib -invert -alter")                                                           --Invert colors in X
	, ((modMask, xK_d), spawn "/usr/bin/killall dzen2 haskell-cpu-usage.out")                                             --Kill dzen2
	, ((0, 0x1008ffa9), spawn "/home/nnoell/bin/touchpadtoggle.sh")                                                       --Toggle touchpad (xmodmap -pk | grep -i toggle)
	, ((0, xF86XK_AudioMute), spawn "/home/nnoell/bin/voldzen.sh t -d")                                                   --Mute/unmute volume
	, ((0, xF86XK_AudioRaiseVolume), spawn "/home/nnoell/bin/voldzen.sh + -d")                                            --Raise volume
	, ((mod1Mask, xK_Up), spawn "/home/nnoell/bin/voldzen.sh + -d")
	, ((0, xF86XK_AudioLowerVolume), spawn "/home/nnoell/bin/voldzen.sh - -d")                                            --Lower volume
	, ((mod1Mask, xK_Down), spawn "/home/nnoell/bin/voldzen.sh - -d")
	, ((0, xF86XK_AudioNext),  flashText myTextConfig 1 " Next Song " >> spawn "/usr/bin/ncmpcpp next")                   --Next song
	, ((mod1Mask, xK_Right), flashText myTextConfig 1 " Next Song " >> spawn "/usr/bin/ncmpcpp next")
	, ((0, xF86XK_AudioPrev), flashText myTextConfig 1 " Previous Song " >> spawn "/usr/bin/ncmpcpp prev")                --Prev song
	, ((mod1Mask, xK_Left), flashText myTextConfig 1 " Previous Song " >> spawn "/usr/bin/ncmpcpp prev")
	, ((0, xF86XK_AudioPlay), flashText myTextConfig 1 " Song Toggled " >> spawn "/usr/bin/ncmpcpp toggle")               --Toggle song
	, ((mod1Mask .|. controlMask, xK_Down), flashText myTextConfig 1 " Song Toggled " >> spawn "/usr/bin/ncmpcpp toggle")
	, ((0, xF86XK_AudioStop), flashText myTextConfig 1 " Song Stopped " >> spawn "/usr/bin/ncmpcpp stop")                 --Stop song
	, ((mod1Mask .|. controlMask, xK_Up), flashText myTextConfig 1 " Song Stopped " >> spawn "ncmpcpp stop")
	, ((0, xF86XK_MonBrightnessUp), spawn "/home/nnoell/bin/bridzen.sh")                                                  --Raise brightness
	, ((0, xF86XK_MonBrightnessDown), spawn "/home/nnoell/bin/bridzen.sh")                                                --Lower brightness
	, ((0, xF86XK_ScreenSaver), spawn "/home/nnoell/bin/turnoffscreen.sh")                                                --Lock screen
	, ((0, xK_Print), spawn "/usr/bin/scrot '%Y-%m-%d_$wx$h.png'")                                                        --Take a screenshot
	, ((modMask , xK_s), spawn "/home/nnoell/bin/turnoffscreen.sh")                                                       --Turn off screen
	--Workspaces management bindings
	, ((mod1Mask, xK_comma), flashText myTextConfig 1 " Toggled to Previous Workspace " >> toggleWS)                          --Toggle to the workspace displayed previously
	, ((mod1Mask, xK_masculine), flashText myTextConfig 1 " Switching with Workspace 1 " >> toggleOrView (myWorkspaces !! 0)) --If ws != 0 then move to workspace 0, else move to latest ws I was
	, ((mod1Mask .|. controlMask, xK_Left), flashText myTextConfig 1 " Moved to Previous Workspace " >> prevWS)               --Move to previous Workspace
	, ((mod1Mask .|. controlMask, xK_Right), flashText myTextConfig 1 " Moved to Next Workspace " >> nextWS)                  --Move to next Workspace
	, ((modMask .|. shiftMask, xK_n), flashText myTextConfig 1 " Shifted to Next Workspace " >> shiftToNext)                  --Send client to next workspace
	, ((modMask .|. shiftMask, xK_p), flashText myTextConfig 1 " Shifted to Previous Workspace " >> shiftToPrev)              --Send client to previous workspace
	] ++
	[ ((m .|. modMask, k), windows $ f i)                                                        --Switch to n workspaces and send client to n workspaces
	  | (i, k) <- zip (XMonad.workspaces conf) ([xK_1 .. xK_9] ++ [xK_0])
	  , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]
	] ++
	[ ((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))                 --Switch to n screens and send client to n screens
	  | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
	  , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]
	] where
		fullFloatFocused = withFocused $ \f -> windows =<< appEndo `fmap` runQuery doFullFloat f
		rectFloatFocused = withFocused $ \f -> windows =<< appEndo `fmap` runQuery (doRectFloat $ RationalRect 0.05 0.05 0.9 0.9) f
		killAndExit = do
			spawn "/usr/bin/killall dzen2 haskell-cpu-usage.out"
			io (exitWith ExitSuccess)
		killAndRestart = do
			spawn "/usr/bin/killall dzen2 haskell-cpu-usage.out"
			liftIO $ threadDelay 1000000
			restart "xmonad" True
 
-- Mouse bindings
myMouseBindings :: XConfig Layout -> M.Map (KeyMask, Button) (Window -> X ())
myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
	[ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w >> windows W.shiftMaster)) --Set the window to floating mode and move by dragging
	, ((modMask, button2), (\w -> focus w >> windows W.shiftMaster))                      --Raise the window to the top of the stack
	, ((modMask, button3), (\w -> focus w >> Flex.mouseResizeWindow w))                   --Set the window to floating mode and resize by dragging
	, ((modMask, button4), (\_ -> prevWS))                                                --Switch to previous workspace
	, ((modMask, button5), (\_ -> nextWS))                                                --Switch to next workspace
	, (((modMask .|. shiftMask), button4), (\_ -> shiftToPrev))                           --Send client to previous workspace
	, (((modMask .|. shiftMask), button5), (\_ -> shiftToNext))                           --Send client to next workspace
	]