######################################################################
# FVWM - key and mouse bindings
######################################################################

# <thing> <button> <context> <modifiers> <action>
# thing     = Key | Mouse
# button    = mouse or keyboard button
# context   = A(ny), R(oot), W(in), F(rame) [corners], S(ide), T(itle), I(con)
# modifiers = N(one), C(ontrol), M(eta) (alt), S(hift)
 
# For numeric keypad (KP_), one must use movement syms (KP_Up/KP_Home/etc) and
# not numbers (KP_7/KP_8/etc).  For the latter, FVWM bindings don't work
# unless SHIFT is down.  (Num Lock state doesn't matter for either.)

######################################################################
# misc init

# delete some defaults
Key F1 R A -
Key Escape A CM -

######################################################################
# misc keyboard

# WIN+BREAK aborts a Wait or ModuleSync
# default is CTRL+ALT+ESC but we want that for other things
Key Break A 4 EscapeFunc

# root menu with WIN+ESC
Key Escape A 4 Menu RootMenu

######################################################################
# window lists and switching

# single-desk window list on WIN+SPACE
Key Space A 4 WinListDesk

# global window list on CTRL+WIN+SPACE
Key Space A C4 WinListAll

# cycle window list, MSFT style, with ALT+TAB
Key Tab A M WinListCycle

# move within window ring, without reordering the window ring
Key bracketleft  A 4 Prev (CurrentDesk, AcceptsFocus, !Iconic) Focus
Key bracketright A 4 Next (CurrentDesk, AcceptsFocus, !Iconic) Focus

# toggle between two windows with WIN+BACKSLASH
# FlipFocus recorders the window ring, so Prev should be the MRU
Key Backslash A 4 Prev (CurrentDesk, AcceptsFocus, !Iconic) FlipAndRaise

######################################################################
# pager via keyboard

# to change the number of virtual desktops, change:
#   DesktopName declarations (in main.conf)
#   GotoPage bindings (in bindings.conf)
#   Pager dimensions (in modules/Dock.conf)

# Desktops are numbered from 0 within FVWM and my own window titles
# but the key bindings are numbered from 1 to use the number row.
# Somehow this makes sense to my brain.

# switch directly to desk with WIN+<num>
Key 1 A 4 GotoDesk 0 0
Key 2 A 4 GotoDesk 0 1
Key 3 A 4 GotoDesk 0 2
Key 4 A 4 GotoDesk 0 3
Key 5 A 4 GotoDesk 0 4

# move current window to desk with WIN+SHIFT+<num>
Key 1 A S4 MoveToDesk 0 0
Key 2 A S4 MoveToDesk 0 1
Key 3 A S4 MoveToDesk 0 2
Key 4 A S4 MoveToDesk 0 3
Key 5 A S4 MoveToDesk 0 4

# relative desk switch with WIN+PGUP/DN
Key Prior A 4 GotoDesk -1
Key Next  A 4 GotoDesk +1

# move window to relative desk with WIN+SHIFT+PGUP/DN
Key Prior A S4 MoveToDesk -1
Key Next  A S4 MoveToDesk +1

######################################################################
# external programs via keyboard

# avoid WASD - reserved for games

Key T A 4 Exec exec xterm
Key T A M4 Resize 80c 24c
Key E A 4 Exec exec ee
Key B A 4 Exec exec web

# WIN+SEMICOLON or WIN+R = 1-line xterm, run 1 cmd (like MSFT "Run")
Key semicolon A 4 Exec exec $[HOME]/.fvwm/run-dialog-xterm.sh
Key R         A 4 Exec exec $[HOME]/.fvwm/run-dialog-xterm.sh

# WIN+SCRLLK = lock session; with SHIFT, also immediate dark.
Key Scroll_Lock A 4  ScreenLock
Key Scroll_Lock A S4 ScreenDark
# Tried doing same with WIN+L (like MS Windows, plus easier one-handed),
# but found my idiot fingers kept doing it instead of CTRL+L for clear.
#Key L           A 4  ScreenLock
#Key L           A M4 ScreenDark

# WIN+PrtScr     = screen shot, entire screen
# WIN+SFT+PrtScr = screen shot, focused window only. with border/trim
# WIN+ALT+PrtScr = ditto, but key stroke has no effect (FIXME)
# WIN+CTL+PrtScr = screen shot, interactive select a rectangle
Key Print A 4  Exec exec scrot	     '$[HOME]/incoming/scrot_all_%Y-%m-%d_%H%M-%S.png'
Key Print A M4 Exec exec scrot -u -b '$[HOME]/incoming/scrot_win_%Y-%m-%d_%H%M-%S.png'
Key Print A S4 Exec exec scrot -u -b '$[HOME]/incoming/scrot_win_%Y-%m-%d_%H%M-%S.png'
Key Print A C4 Exec exec scrot -s    '$[HOME]/incoming/scrot_sel_%Y-%m-%d_%H%M-%S.png'

######################################################################
# window ops via keyboard - general/misc

# ALT+SPACE = win ops menu
Key Space A M Menu WinOpsMenu

# ALT+F4 = close
Key F4 A M Delete

# stacking
Key Equal	A 4 Raise
Key Minus	A 4 Lower

# toggle states
Key Slash	A 4 WindowShade
Key Period	A 4 Iconify
Key Comma	A 4 MaximizeAndRaise
Key Apostrophe	A 4 Stick

# maximize on one axis only: ALT=horiz CTRL=vert
Key Comma A 4M Maximize 100 0
Key Comma A 4C Maximize 0 100

# iconify all windows with SHIFT+Iconify
# FIXME iconifies the button box/dock, too
# tried CirculateHit and !CirculateSkip, neither helped
#Key Period	A CMS All (CurrentDesk, !Iconic) Iconify

# ENTER on an Icon also de-iconfiies
Key Return	I N Iconify
Key KP_Enter	I N Iconify

# center window on current monitor with WIN+HOME
Key Home A 4 CenterWin

######################################################################
# window ops via keyboard - arrow keys

# WIN = move
Key Left	A 4 MoveWinLeft
Key Right	A 4 MoveWinRight
Key Up		A 4 MoveWinUp
Key Down	A 4 MoveWinDown

# WIN+SHIFT = grow/shrink by adjusting bottom or right sides
Key Left	A S4 Resize w-20p keep
Key Right	A S4 Resize w+20p keep
Key Up		A S4 Resize keep w-20p
Key Down	A S4 Resize keep w+20p

# WIN+SHIFT+ALT = grow/shrink by adjusting top or left sides
Key Left	A MS4 ResizeMove w+20p keep w-20p keep 
Key Right	A MS4 ResizeMove w-20p keep w+20p keep 
Key Down	A MS4 ResizeMove keep w-20p keep w+20p
Key Up  	A MS4 ResizeMove keep w+20p keep w-20p

# WIN+CTRL = Move window to next adjacent window.
# Called "window packing" by some.
Key Up	   A C4 Move shuffle Up    Warp
Key Down   A C4 Move shuffle Down  Warp
Key Left   A C4 Move shuffle Left  Warp
Key Right  A C4 Move shuffle Right Warp

# WIN+CTRL+SHIFT = Enlarge (resize) window to next adjacent window.
# Called "fill" by me.
Key Up	   A CS4 FillUp
Key Down   A CS4 FillDown
Key Left   A CS4 FillLeft
Key Right  A CS4 FillRight

# WIN+ALT = Move window to edge of current monitor.  "edge packing".
Key Up     A M4 Move   keep   0p    Warp
Key Down   A M4 Move   keep  -0p    Warp
Key Left   A M4 Move   0p     keep  Warp
Key Right  A M4 Move  -0p     keep  Warp

# WIN+ALT+CTRL = Move window to given monitor.
# (If I get more monitors, I'll add more sophistication/directions.)
Key Up   A CM4 MoveWarpScreen DisplayPort-2
Key Down A CM4 MoveWarpScreen DisplayPort-0

# WIN+CTRL+ALT+SHIFT not assigned

######################################################################
# mouse on desktop surface (root window)

# root window
Mouse 1 R A Menu RootMenu
Mouse 2 R A WinListMouse
Mouse 3 R A Menu WinOpsMenu

# icons
Mouse 1 I N Function MoveIconifyRaise
Mouse 3 I N Menu WinOpsMenu

######################################################################
# mouse on window decorations

# frames (corners) and sides of windows
Mouse 1 FS N Function SizeRaise
Mouse 2 FS N Function MoveRaise
Mouse 3 FS N Menu WinOpsMenu

# see titlebar.conf for title bar buttons and bindings

######################################################################
# misc mouse

# WIN+right-click in window = menu
Mouse 3 W 4 Menu WinOpsMenu

# WIN+left-click in window = drag to move
Mouse 1 W 4 MoveRaise

######################################################################
# END OF FILE
######################################################################
