aboutsummaryrefslogblamecommitdiffstats
path: root/xmonad/xmonad.hs.gpp
blob: 7a6f9606df71ae62c9bfed3ec3f413a9ca82e0c8 (plain) (tree)























































                                                                     

                                                               
                        
                                          

                                


                                 
          

































































































                                                                                                                


                                                                                                      

     

                                                       
























                                                                                               

                                                            









                                                            

                                                                             
                   

                                                                   






















                                                                  
-- -*- haskell -*-
import XMonad hiding ( (|||) )
import qualified XMonad.StackSet as W -- hiding ( workspaces, focus )

import XMonad.Actions.CycleWS
import XMonad.Actions.UpdatePointer
import XMonad.Actions.MouseResize
import XMonad.Actions.WindowMenu

import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.UrgencyHook
import XMonad.Hooks.EwmhDesktops

import XMonad.Layout.IM
import XMonad.Layout.LayoutCombinators
import XMonad.Layout.LayoutHints
import XMonad.Layout.NoBorders
import XMonad.Layout.PerWorkspace
import XMonad.Layout.ResizableTile
import XMonad.Layout.Grid
import XMonad.Layout.Accordion
import XMonad.Layout.Circle
import XMonad.Layout.WindowArranger
import XMonad.Layout.SimpleFloat
import XMonad.Layout.PerScreen
import XMonad.Layout.LayoutModifier
import XMonad.Layout.Gaps

import XMonad.Util.EZConfig
import XMonad.Util.Loggers
import XMonad.Util.Run
import XMonad.Util.Scratchpad
import XMonad.Util.WindowProperties
import XMonad.Util.WorkspaceCompare
import XMonad.Util.Replace
import XMonad.Util.Themes

import XMonad.Layout.Tabbed
import XMonad.Layout.DecorationMadness
import XMonad.Layout.DecorationAddons
import XMonad.Layout.Decoration
import XMonad.Layout.SimpleDecoration
import XMonad.Layout.DwmStyle
import XMonad.Layout.TabBarDecoration
import XMonad.Layout.ImageButtonDecoration
import XMonad.Layout.BorderResize
import XMonad.Layout.SimpleFloat
import XMonad.Layout.Maximize
import XMonad.Layout.Minimize

import qualified Data.Map as M


$$<
	hostname="$(hostname | tr '[[:upper:]]' '[[:lower:]]')"

	workspace_1=main
	if test "$hostname" = zenith; then
		workspace_7=chat
		workspace_8=mail
		workspace_9=media
	else
		workspace_9=off
	fi

	modmask=mod4Mask # Super_L
	focus_on_hover=True
	with_decorations=true

	if test -x /usr/bin/terminator || test -x /usr/local/bin/terminator; then
		terminal=terminator
	elif test -x /usr/bin/st || test -x /usr/local/bin/st; then
		terminal=st
	else
		terminal=xterm
	fi
	screenshooter=
$$>



---- ==== Keypad numbers ==== ----
numPadKeys = [ xK_KP_Insert                             -- 0
             , xK_KP_End,  xK_KP_Down,  xK_KP_Page_Down -- 1, 2, 3
             , xK_KP_Left, xK_KP_Begin, xK_KP_Right     -- 4, 5, 6
             , xK_KP_Home, xK_KP_Up,    xK_KP_Page_Up   -- 7, 8, 9
             ]


---- ==== Kill panel and restart ==== ----
$$>if test -x /usr/bin/dpkill; then
myRestart = "env DISPLAY=${DISPLAY}.0 dpkill xpybar ; xmonad --restart"
$$>else
myRestart = "pkill xpybar ; xmonad --restart"
$$>fi


---- ==== Naming of workspaces ==== ---- 
myWorkspaces = [ "1$${workspace_1:+-${workspace_1}}"
               , "2$${workspace_2:+-${workspace_2}}"
               , "3$${workspace_3:+-${workspace_3}}"
               , "4$${workspace_4:+-${workspace_4}}"
               , "5$${workspace_5:+-${workspace_5}}"
               , "6$${workspace_6:+-${workspace_6}}"
               , "7$${workspace_7:+-${workspace_7}}"
               , "8$${workspace_8:+-${workspace_8}}"
               , "9$${workspace_9:+-${workspace_9}}"
               ]


---- ==== Mouse bindings ==== ----
stackRotate (W.Stack f [] rs) = W.Stack f [] rs
stackRotate (W.Stack f ls rs) = W.Stack l (f:(reverse ls')) rs
                              where
                                (l:ls') = reverse ls

stackUnrotate (W.Stack f [] rs)     = W.Stack f [] rs
stackUnrotate (W.Stack f (l:ls) rs) = W.Stack l (ls ++ [f]) rs

stackUnrotateRight (W.Stack f ls []) = W.Stack f ls []
stackUnrotateRight (W.Stack f ls rs) = W.Stack r ls (f:(reverse rs'))
                                     where
                                       (r:rs') = reverse rs

stackRotateRight (W.Stack f ls [])     = W.Stack f ls []
stackRotateRight (W.Stack f ls (r:rs)) = W.Stack r ls (rs ++ [f])

myMouse = [ (( $${modmask}, button4), (\w -> focus w >> windows (W.modify' stackRotate)))
          , (( $${modmask}, button5), (\w -> focus w >> windows (W.modify' stackUnrotate)))
          , (( $${modmask} .|. controlMask, button4), (\w -> focus w >> windows (W.modify' stackRotateRight)))
          , (( $${modmask} .|. controlMask, button5), (\w -> focus w >> windows (W.modify' stackUnrotateRight)))
          ]


---- ==== Main method ==== ---- 
main = do
  ---- System status panel
  d <- spawnPipe "env DISPLAY=${DISPLAY}.0 xpybar -c ~/.config/xpybar/xmonad-monitor"

  ---- Dude… settings
  xmonad $ docks $ ewmh def
    { terminal           = "$${terminal}"
    , focusFollowsMouse  = $${focus_on_hover}
    , modMask            = $${modmask}
    , borderWidth        = 0                     --   No borders
    , workspaces         = myWorkspaces          --   Name my workspaces
    , logHook            = myLogHook d           --   Top(system) panel hook
    , manageHook         = myManageHook          --   Manage hook
    , layoutHook         = myLayoutHook          --   Layout algorithms
    , handleEventHook    = handleEventHook def <+> fullscreenEventHook
    , mouseBindings      = \x -> M.union (mouseBindings def x) (M.fromList myMouse)
    }`additionalKeys`                                -- Modifiy keybindings
    [ (( $${modmask}, xK_F4), kill)                  --   <Super>F4   ::  Kill window
    , (( $${modmask}, xK_F12), spawn "$${terminal}") --   <Super>F12  ::  Open terminal
$$>if test -n "${screenshooter}"; then
    , (( 0, xK_Print), spawn "$${screenshooter}")    --   SysReq      ::  Take a screen-shot
$$>fi
    , (( $${modmask}, xK_q), spawn myRestart)        --   modified restart command
    , (( $${modmask}, xK_F5), sendMessage $ JumpToLayout (decoName ++ "Tall"))
    , (( $${modmask}, xK_F6), sendMessage $ JumpToLayout (decoName ++ "Mirror Tall"))
    , (( $${modmask}, xK_F7), sendMessage $ JumpToLayout (decoName ++ "Grid"))
    , (( $${modmask}, xK_F8), sendMessage $ JumpToLayout "Full")
    {-- TODO , (( $${modmask} .|. controlMask, xK_m), withFocused (sendMessage . maximizeRestore)) --}
    {-- TODO , (( $${modmask}, xK_m), withFocused minimizeWindow) --}
    {-- TODO , (( $${modmask} .|. shiftMask , xK_m), sendMessage RestoreNextMinimizedWin) --}
    ]

{-- TODO preselect workspace 9 on secondary monitor --}


---- ==== Layout settings ==== ----
ratios = [ toRational (2/(1 + sqrt 5 :: Double)) -- golden ratio
         , toRational (sqrt 2 - 1 :: Double)     -- silver ratio
         , 1 / 2                                 -- half
         ]

$$>if ${with_decorations}; then
$$>    deco="imageButtonDeco shrinkText myTheme"
myTheme = (defaultThemeWithImageButtons
                {         activeColor = "#333333"
                ,       inactiveColor = "#000000"
                ,         urgentColor = "#880000"
                ,   activeBorderColor = "#888888"
                , inactiveBorderColor = "#888888"
                ,   urgentBorderColor = "#CD656C"
                ,     activeTextColor = "#EEEEEE"
                ,   inactiveTextColor = "#EEEEEE"
                ,     urgentTextColor = "#FFFFFF"
                , fontName            = "-misc-fixed-medium-r-normal-*-10-*-*-*-c-*-iso10646-1"
                , decoWidth           = 100
                , decoHeight          = 14
                , windowTitleAddons   = []
                {- , windowTitleIcons = [] -}
                })
{-- TODO decoName = "ImageButtonDeco Maximize Minimize " --}
decoName = "ImageButtonDeco Maximize "
$$>else
$$>    deco=
decoName = "Maximize Minimize "
$$>fi

myManageHook = manageDocks <+> manageHook def <+> composeAll
               [ className =? "XEyes"         --> doIgnore
               , className =? "TzClock"       --> doIgnore
               ]
myLayoutHook = avoidStruts $ myLayouts
myLayouts    = $${deco} (maximize {-- $ TODO minimize --} (tiled 2))
           ||| $${deco} (maximize {-- $ TODO minimize --} (Mirror (tiled 2)))
           ||| full
           ||| $${deco} (maximize {-- $ minimize --} Grid)
           ||| $${deco} (maximize {-- $ minimize --} (Mirror Grid))
           ||| full
tiled n      = Tall nmaster delta (ratios!!n)
full         = noBorders Full
nmaster      = 1
delta        = 1/100


---- ==== dzen2/xpybar (top panel) settings ==== ----
myLogHook h = do
  dynamicLogWithPP $ def
    { ppCurrent         = dzenColor "#303030" "#909090" . pad
    , ppHidden          = dzenColor "#909090" "" . pad
    , ppHiddenNoWindows = dzenColor "#606060" "" . pad
    , ppLayout          = dzenColor "#909090" "" . pad
    , ppUrgent          = dzenColor "#cd656c" "" . pad . dzenStrip
    , ppTitle           = shorten 100
    , ppWsSep           = ""
    , ppSep             = "  "
    , ppOutput          = hPutStrLn h
    }
  dynamicLogString def
    { ppSort = getSortByXineramaRule
    } >>= xmonadPropLog