module XMonad.Config.Bluetile (
bluetileConfig
) where
import XMonad hiding ( (|||) )
import XMonad.Layout.BorderResize
import XMonad.Layout.BoringWindows
import XMonad.Layout.ButtonDecoration
import XMonad.Layout.Decoration
import XMonad.Layout.DecorationAddons
import XMonad.Layout.DraggingVisualizer
import XMonad.Layout.LayoutCombinators
import XMonad.Layout.Maximize
import XMonad.Layout.Minimize
import XMonad.Layout.MouseResizableTile
import XMonad.Layout.Named
import XMonad.Layout.NoBorders
import XMonad.Layout.PositionStoreFloat
import XMonad.Layout.WindowSwitcherDecoration
import XMonad.Actions.BluetileCommands
import XMonad.Actions.CycleWS
import XMonad.Actions.WindowMenu
import XMonad.Hooks.CurrentWorkspaceOnTop
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.PositionStoreHooks
import XMonad.Hooks.Minimize
import XMonad.Hooks.ServerMode
import XMonad.Hooks.WorkspaceByPos
import XMonad.Config.Gnome
import qualified XMonad.StackSet as W
import qualified Data.Map as M
import System.Exit
import Data.Monoid
import Control.Monad(when)
bluetileWorkspaces :: [String]
bluetileWorkspaces = ["1","2","3","4","5","6","7","8","9","0"]
bluetileKeys :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ())
bluetileKeys conf@(XConfig {XMonad.modMask = modMask'}) = M.fromList $
[ ((modMask' , xK_Return), spawn $ XMonad.terminal conf)
, ((modMask', xK_p ), gnomeRun)
, ((modMask' .|. shiftMask, xK_c ), kill)
, ((modMask', xK_F5 ), refresh)
, ((modMask' .|. shiftMask, xK_F5 ), setLayout $ XMonad.layoutHook conf)
, ((modMask', xK_o ), windowMenu)
, ((modMask', xK_Tab ), focusDown)
, ((modMask' .|. shiftMask, xK_Tab ), focusUp)
, ((modMask', xK_j ), focusDown)
, ((modMask', xK_k ), focusUp)
, ((modMask', xK_space ), focusMaster)
, ((modMask' .|. shiftMask, xK_space ), windows W.swapMaster)
, ((modMask' .|. shiftMask, xK_j ), windows W.swapDown )
, ((modMask' .|. shiftMask, xK_k ), windows W.swapUp )
, ((modMask', xK_h ), sendMessage Shrink)
, ((modMask', xK_l ), sendMessage Expand)
, ((modMask', xK_u ), sendMessage ShrinkSlave)
, ((modMask', xK_i ), sendMessage ExpandSlave)
, ((modMask', xK_t ), withFocused $ windows . W.sink)
, ((modMask' .|. shiftMask, xK_t ), withFocused $ float )
, ((modMask' , xK_comma ), sendMessage (IncMasterN 1))
, ((modMask' , xK_period), sendMessage (IncMasterN (1)))
, ((modMask' .|. shiftMask, xK_q ), io (exitWith ExitSuccess))
, ((modMask' , xK_q ), restart "xmonad" True)
, ((mod1Mask .|. controlMask, xK_Left), prevWS)
, ((mod1Mask .|. controlMask, xK_Right), nextWS)
, ((mod1Mask .|. controlMask .|. shiftMask, xK_Left), shiftToPrev >> prevWS)
, ((mod1Mask .|. controlMask .|. shiftMask, xK_Right), shiftToNext >> nextWS)
, ((mod1Mask , xK_F2), gnomeRun)
, ((mod1Mask , xK_F4), kill)
, ((modMask' , xK_a), sendMessage $ JumpToLayout "Floating")
, ((modMask' , xK_s), sendMessage $ JumpToLayout "Tiled1")
, ((modMask' , xK_d), sendMessage $ JumpToLayout "Tiled2")
, ((modMask' , xK_f), sendMessage $ JumpToLayout "Fullscreen")
, ((modMask' , xK_z), withFocused (sendMessage . maximizeRestore))
, ((modMask', xK_m ), withFocused minimizeWindow)
, ((modMask' .|. shiftMask, xK_m ), sendMessage RestoreNextMinimizedWin)
]
++
[((m .|. modMask', k), windows $ f i)
| (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))
| (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
bluetileMouseBindings :: XConfig Layout -> M.Map (KeyMask, Button) (Window -> X ())
bluetileMouseBindings (XConfig {XMonad.modMask = modMask'}) = M.fromList $
[ ((modMask', button1), (\w -> isFloating w >>= \isF -> when (isF) $
focus w >> mouseMoveWindow w >> windows W.shiftMaster))
, ((modMask', button2), (\_ -> sendMessage NextLayout))
, ((modMask' .|. shiftMask, button2), (\_ -> sendMessage $ JumpToLayout "Floating"))
, ((modMask', button3), (\w -> isFloating w >>= \isF -> when (isF) $
focus w >> mouseResizeWindow w >> windows W.shiftMaster))
]
isFloating :: Window -> X (Bool)
isFloating w = do
ws <- gets windowset
return $ M.member w (W.floating ws)
bluetileManageHook :: ManageHook
bluetileManageHook = composeAll
[ workspaceByPos, positionStoreManageHook (Just defaultThemeWithButtons)
, className =? "MPlayer" --> doFloat
, isFullscreen --> doFullFloat
, manageDocks]
bluetileLayoutHook = avoidStruts $ minimize $ boringWindows $ (
named "Floating" floating |||
named "Tiled1" tiled1 |||
named "Tiled2" tiled2 |||
named "Fullscreen" fullscreen
)
where
floating = floatingDeco $ maximize $ borderResize $ positionStoreFloat
tiled1 = tilingDeco $ maximize $ mouseResizableTileMirrored
tiled2 = tilingDeco $ maximize $ mouseResizableTile
fullscreen = tilingDeco $ maximize $ smartBorders Full
tilingDeco l = windowSwitcherDecorationWithButtons shrinkText defaultThemeWithButtons (draggingVisualizer l)
floatingDeco l = buttonDeco shrinkText defaultThemeWithButtons l
bluetileConfig =
defaultConfig
{ modMask = mod4Mask,
manageHook = bluetileManageHook,
layoutHook = bluetileLayoutHook,
logHook = currentWorkspaceOnTop >> ewmhDesktopsLogHook,
handleEventHook = ewmhDesktopsEventHook
`mappend` fullscreenEventHook
`mappend` minimizeEventHook
`mappend` serverModeEventHook' bluetileCommands
`mappend` positionStoreEventHook,
workspaces = bluetileWorkspaces,
keys = bluetileKeys,
mouseBindings = bluetileMouseBindings,
focusFollowsMouse = False,
focusedBorderColor = "#000000",
terminal = "gnome-terminal"
}