DEF globalKeyBindings {
   NextTask                   : KeyPress = Tab & Mod1Mask & !ShiftMask,
   PreviousTask               : KeyPress = Tab & Mod1Mask & ShiftMask,
   MenuRemapFocused(rootmenu) : KeyPress = Escape & ControlMask,
   ViewportFixedMove(+0+0)    : KeyPress = F1 & Mod1Mask,
   ViewportFixedMove(+0+H)    : KeyPress = F2 & Mod1Mask,
   ViewportFixedMove(+0+2H)   : KeyPress = F3 & Mod1Mask,
   {xmms -r}                  : KeyPress = F5,
   {xmms -p}                  : KeyPress = F6,
   {xmms -u}                  : KeyPress = F7,
   {xmms -f}                  : KeyPress = F8,
   {xmms -s}                  : KeyPress = F9 & !Mod1Mask,
   {/usr/local/bin/dosleep}   : KeyPress = F13,
   {/usr/local/bin/setcpu -}  : KeyPress = F9 & Mod1Mask,
   {/usr/local/bin/setcpu +}  : KeyPress = F10 & Mod1Mask,
   {/usr/local/bin/setlcd -}  : KeyPress = F11 & Mod1Mask,
   {/usr/local/bin/setlcd +}  : KeyPress = F12 & Mod1Mask,
   {Eterm}                    : KeyPress = X & ControlMask & Mod1Mask,   
   {xscreensaver-command -lock}: KeyPress = Z & ControlMask & Mod1Mask,   
}

DEF defaultAllWindows {
   Raise                  : ButtonPress = Button1 & Mod1Mask,
   StartOpaqueMove        : ButtonPress = Button1 & Mod1Mask,
   StartOpaqueResizeRight : ButtonPress = Button3 & Mod1Mask,
   Lower                  : ButtonPress = Button2 & Mod1Mask,
   EndMoveResize          : ButtonRelease = Button1 & MoveResizeMask,
   EndMoveResize          : ButtonRelease = Button3 & MoveResizeMask,
   MoveToSmartPlace       : KeyPress = C & ControlMask & Mod1Mask
}

DEF defaultAllDecor {
	defaultAllWindows,
   Raise             : ButtonPress = Button1 & !Mod1Mask,
   Focus             : ButtonPress = Button1 & !Mod1Mask,
   Lower             : ButtonPress = Button3 & !Mod1Mask,
   MenuRemap(window) : ButtonPress = Button2 & !Mod1Mask,
   MenuUnmap(window) : ButtonPress = Button1 & !Mod1Mask,
   MenuUnmap(window) : ButtonPress = Button3 & !Mod1Mask
}

DEF defaultAllTitle {
   defaultAllDecor,
   StartOpaqueMove : ButtonPress = Button1 & !Mod1Mask,
   ToggleShade     : DoubleClick = Button1 & !Mod1Mask
}

window.frame { 
   defaultAllDecor,
   Focus : EnterNotify
}
window.title {
   defaultAllTitle
}
window.label { defaultAllTitle }
window.handle { defaultAllDecor }
window.leftgrip { 
   defaultAllWindows,
   StartOpaqueResizeLeft : ButtonPress = Button1 & !Mod1Mask
}
window.rightgrip { 
   defaultAllWindows,
   StartOpaqueResizeRight : ButtonPress = Button1 & !Mod1Mask
}
window.button0 {
   defaultAllWindows,
   MenuRemap(window) : ButtonRelease = Button1,
   MoveToSmartPlace  : ButtonRelease = Button3
}
window.button1 { 
   defaultAllWindows,
   Close          : ButtonRelease = Button1
}
window.button2 {
   defaultAllWindows,
   ToggleMaximize : ButtonRelease = Button1,
   Raise          : ButtonRelease = Button1
}

window.passiveclient { 
   defaultAllWindows,
   MoveToSmartPlace : MapRequest,
   Raise     : MapRequest
}
window.activeclient {
   defaultAllWindows,
   globalKeyBindings
}

root {
   MenuRemap(rootmenu) : ButtonPress = Button1,
   MenuUnmap(rootmenu) : ButtonRelease = Button1,
   StartViewportMove   : ButtonPress = Button2,
   EndMoveResize       : ButtonRelease = Button2 & MoveResizeMask,
   globalKeyBindings
}

#westedge { ViewportLeft : EnterNotify }

#eastedge { ViewportRight : EnterNotify }
 
#northedge { ViewportUp : EnterNotify [250 : LeaveNotify] }
 
#southedge { ViewportDown : EnterNotify [250 : LeaveNotify] }

DEF allMenuWindows {
   Raise           : ButtonPress = Button1 & Mod1Mask,
   StartOpaqueMove : ButtonPress = Button1 & Mod1Mask,
   UnLink          : ButtonPress = Button1 & Mod1Mask,
   EndMoveResize   : ButtonRelease = Button1 & MoveResizeMask
}

DEF allMenuItems {
   allMenuWindows,
   Exec         : ButtonRelease = AnyButton,
   Func         : ButtonRelease = AnyButton,
   NextItem     : KeyPress = Tab & !ShiftMask,
   PreviousItem : KeyPress = Tab & ShiftMask,
   NextItem     : KeyPress = Down,
   PreviousItem : KeyPress = Up,
   UnmapSubs    : KeyPress = Left,
   UnmapFocused : KeyPress = Left,
   UnmapTree    : KeyPress = Escape,
   Exec         : KeyPress = Return,
   Func         : KeyPress = Return
} 

menu.title {
   allMenuWindows,
   Raise           : ButtonPress = Button1,
   UnLink          : ButtonPress = Button1 & !Mod1Mask,
   StartOpaqueMove : ButtonPress = Button1 & !Mod1Mask,
   UnmapSubs       : ButtonPress = Button3,
   Unmap           : ButtonPress = Button3,
   Unmap           : ButtonRelease = AnyButton
}
menu.item {
   allMenuItems,
   UnmapSubs    : EnterNotify,
   UnmapTree    : ButtonRelease = AnyButton,
   #UnmapFocused : KeyRelease = Mod1Mask,
   #Func         : KeyRelease = Mod1Mask,
   UnmapTree    : KeyPress = Return
}
menu.checkbox {
   allMenuItems,
   UnmapSubs : EnterNotify,
   Exec      : KeyPress = space,
   Func      : KeyPress = space
}
menu.sub {
   allMenuItems,
   MapSubOnly      : EnterNotify,
   RemapSub        : ButtonPress = AnyButton,
   RemapSubFocused : KeyPress = Right,
   RemapSubFocused : KeyPress = Return
}
