#Zer4tul的fvwm keybinding配置及其相关functions
#2007-08-09 12:01
################################################
# Keybinding Related Functions
################################################

DestroyFunc SerbianKeyboard
AddToFunc SerbianKeyboard
+ I PipeRead 'setxkbmap cs && echo Nop'
+ I Key space A CM USKeyboard

DestroyFunc GermanKeyboard
AddToFunc GermanKeyboard
+ I PipeRead 'setxkbmap de && echo Nop'
+ I Key space A CM USKeyboard

DestroyFunc USKeyboard
AddToFunc USKeyboard
+ I PipeRead 'setxkbmap us && echo Nop'
+ I Key K A C4 SerbianKeyboard

# Like 'Maximize 100 0' or 'Maximize 0 100', but they work independently
# (you can undo each of them separately)
DestroyFunc MaximizeVertically
AddToFunc MaximizeVertically
+ I Pick (State 13) Maximize Off
+ I Pick (State 13, State 14) Maximize On 100 0
+ I Pick (!State 13) Maximize On 0 100
+ I State 13

DestroyFunc MaximizeHorizontally
AddToFunc MaximizeHorizontally
+ I Pick (State 14) Maximize Off
+ I Pick (State 14, State 13) Maximize On 0 100
+ I Pick (!State 14) Maximize On 100 0
+ I State 14

DestroyFunc MaximizeFullScreen
AddToFunc MaximizeFullScreen
+ I Current (!State 11) WindowStyle NoTitle,!Borders
+ I Current (State 11) WindowStyle Title,Borders
+ I Current RefreshWindow
+ I Current (!State 11) Maximize true
+ I Current (State 11) Maximize false
+ I Current State 11 toggle


#Pidgin
Style FvwmPidginNotification Sticky, NoTitle, CirculateSkip, WindowListSkip, NeverFocus, BorderWidth 0, HandleWidth 0, Layer 0

DestroyFunc HideUnhideIM
AddToFunc HideUnhideIM
+ I Any (pidgin, !shaded, !Overlapped) HideIM
+ I TestRc (NoMatch) Any (pidgin, !shaded, Overlapped) UnhideIM
+ I TestRc (NoMatch) Any (pidgin, !"Buddy List", !shaded) HideIM
+ I TestRc (NoMatch) Any (pidgin, !shaded) HideIM
+ I TestRc (NoMatch) UnHideIM

DestroyFunc UnhideIM
AddToFunc UnhideIM
+ I All (pidgin, shaded) Move -0 +0
+ I All (pidgin, !"Buddy List") Raise
+ I All (pidgin, shaded) WindowShade Off
+ I Any (pidgin, !"Buddy List") Next (pidgin, !"Buddy List") WarpToWindow 50 1
+ I TestRc (NoMatch) Next (pidgin) WarpToWindow 50 1

DestroyFunc HideIM
AddToFunc HideIM
+ I Current (pidgin) Prev (CurrentPage, !Iconic, !Shaded, AcceptsFocus) Focus
+ I All (pidgin, !shaded) WindowShade E
+ I All (pidgin) Move -1000 -1000

# Additionaly Pidgin can set the urgency flag for a windows when a message is received
DestroyFunc UrgencyFunc
AddToFunc UrgencyFunc
#+ I ThisWindow (pidgin) Exec exec xmessage -title "FvwmPidginMessageNotification" -geometry -0-0 "Pidgin message"
+ I ThisWindow (pidgin) NewPidginMessage
+ I TestRc (NoMatch) StandardUrgencyFunc

DestroyFunc UrgencyDoneFunc
AddToFunc UrgencyDoneFunc
#+ I ThisWindow (pidgin) All (FvwmPidginMessageNotification) Close
+ I ThisWindow (pidgin) RemovePidginMessage
+ I TestRc (NoMatch) StandardUrgencyDoneFunc

DestroyFunc NewPidginMessage
AddToFunc NewPidginMessage
+ I Deschedule 12321
+ I SendToModule *FvwmPidginNotification SendString 1 1
+ I All (xv*Pidgin*) Move -0 -0
+ I Schedule 5000 12321 All (xv*Pidgin*) Move -1000 -1000

DestroyFunc RemovePidginMessage
AddToFunc RemovePidginMessage
+ I Deschedule 12321
+ I SendToModule *FvwmPidginNotification SendString 1 2
+ I All (xv*Pidgin*) Move -1000 -1000

DestroyFunc StandardUrgencyFunc
AddToFunc StandardUrgencyFunc
+ I Iconify off
+ I FlipFocus
+ I Raise
+ I WarpToWindow 5p 5p
DestroyFunc StandardUrgencyDoneFunc
AddToFunc StandardUrgencyDoneFunc
+ I Nop

Style FvwmPidginMessageNotification Sticky, NeverFocus

# Focus when changing pages
DestroyFunc OnNewPage
AddToFunc OnNewPage
+ I Current (CurrentPage) Nop
+ I TestRc (NoMatch) Next (CurrentPage, !Overlapped, !Iconic, !Sticky, !Shaded) Focus
+ I TestRc (NoMatch) Next (CurrentPage, Visible, !Iconic, !Sticky, !Shaded) Focus
+ I TestRc (NoMatch) Next (CurrentPage, Iconic) Focus
+ I ShowPageName

DestroyFunc GroupFunc
#AddToFunc GroupFunc I Layer 1
AddToFunc GroupFunc
+ I MoveToPage
+ I Iconify off
+ I Raise

DestroyFunc ToggleTitle
AddToFunc ToggleTitle
+ I Current (State 17) WindowStyle NoTitle
+ I TestRc (NoMatch) WindowStyle Title
+ I State 17

DestroyFunc ShadeWindowWithStyle
AddToFunc ShadeWindowWithStyle
+ I WindowShade $0
+ I Maximize Off
+ I ThisWindow (!Shaded) SetAquaDecor
+ I ThisWindow (!Shaded) Layer 0 4
#+ I ThisWindow (!Shaded) WindowStyle NoTitle
+ I ThisWindow (Shaded) WindowStyle HandleWidth 0
#+ I ThisWindow (Shaded) WindowStyle UseDecor ShadedWindowDecor, HilightColorSet 15, Colorset 14, Font "xft:Bitstream Vera Sans:size=11"
+ I ThisWindow (Shaded) Layer 0 2
+ I ThisWindow (Shaded) WindowStyle Title

DestroyFunc SortShadedWindows
AddToFunc SortShadedWindows
+ I All (CurrentPage, Shaded, !Sticky) PipeRead 'echo $$$[w.width] $$$[w.id] >> .fvwm/shadedWindows'
# This should be more simpler with awk, but there seem to be problems with $1, $2, etc substitutions
+ I PipeRead "if [ -e .fvwm/shadedWindows ]; then \
                offset=0; \
                for l in `sort -rnk 1 .fvwm/shadedWindows | tr ' ' '_'`; do \
                  echo `echo ${l} | sed 's/\\(.*\\)_\\(.*\\)/WindowId ResizeMoveMaximize 0 0p/'` ${offset}p; \
                  offset=$[offset + 21]; \
                done; \
                rm .fvwm/shadedWindows; \
              fi"

DestroyFunc ShadeAllWindows
AddToFunc ShadeAllWindows
+ I All (CurrentPage, !Iconic, !Sticky) ShadeWindowWithStyle $0
+ I SortShadedWindows

AddToDecor ShadedWindowDecor
+ TitleStyle Colorset 14
+ TitleStyle Height 20 -- Flat
+ TitleStyle LeftJustified
+ ButtonStyle 3 7
+ ButtonStyle 2 Vector 17 \
                           \
                          
+ ButtonStyle 4 Vector 5
+ ButtonStyle 6 Vector 4
+ ButtonStyle All -- Flat
+ ButtonStyle All -- UseTitleStyle

DestroyFunc CreateRunDialog
AddToFunc CreateRunDialog
+ I Exec exec urxvtc +sb -name fvwm-run-dialog -title "Run program..." \
                    -geometry 50x1 --keysym.0xFF0D: " &\nexit\n" \
                    -e bash --init-file $[HOME]/.fvwm/bashrc_noPS1
+ I Wait fvwm-run-dialog
+ I All (fvwm-run-dialog) WarpToWindow 50 75

# Xchat
DestroyFunc HideUnhideIRC
AddToFunc HideUnhideIRC
+ I Any (xchat, !shaded, !Overlapped) HideIRC
+ I TestRc (NoMatch) Any (xchat, !shaded, Overlapped) UnhideIRC
+ I TestRc (NoMatch) Any (xchat, !"*", !shaded) HideIRC
+ I TestRc (NoMatch) Any (xchat, !shaded) HideIRC
+ I TestRc (NoMatch) UnHideIRC

DestroyFunc UnhideIRC
AddToFunc UnhideIRC
+ I All (xchat, shaded) Move -0 +0
+ I All (xchat, !"*") Raise
+ I All (xchat, shaded) WindowShade Off
+ I Any (xchat, !"*") Next (xchat, !"*") WarpToWindow 50 1
+ I TestRc (NoMatch) Next (xchat) WarpToWindow 50 1

DestroyFunc HideIRC
AddToFunc HideIRC
+ I Current (xchat) Prev (CurrentPage, !Iconic, !Shaded, AcceptsFocus) Focus
+ I All (xchat, !shaded) WindowShade E
+ I All (xchat) Move -1000 -1000

DestroyFunc HideUnhidePager
AddToFunc HideUnhidePager
+ I All (FvwmPager, Layer 10) Layer 0 1
+ I TestRc (NoMatch) All (FvwmPager) Layer 0 10

Key Super_L A A SetEnv FVWMFirstAltTab YES
Style * FPSortWindowlistByFocus

DestroyFunc AltTab
AddToFunc AltTab
+ I PipeRead 'if [ "$$FVWMFirstAltTab" != "NO" ]; then \
                 echo FirstAltTab $0 $1; \
              else \
                 echo NthAltTab $0 $1; \
              fi'
+ I SetEnv FVWMFirstAltTab NO

DestroyFunc WarpAltTab
AddToFunc WarpAltTab
+ I WarpToWindow 50 50
+ I FlipFocus

# Scroll pages also through desktops
DestroyFunc RightPage
AddToFunc RightPage
+ I Piperead 'if [ $[page.nx] = $[FVWMmaxPageX] ]; then \
                if [ $[desk.n] != $[FVWMMaxDeskNumber] ]; then \
                  echo GotoDeskAndPage $$\[ $[desk.n] + 1 \] 0 $[page.ny]; \
                fi; \
              else \
                  echo Scroll 100 0; \
              fi'

DestroyFunc LeftPage
AddToFunc LeftPage
+ I Piperead 'if [ $[page.nx] = 0 ]; then \
                if [ $[desk.n] != 0 ]; then \
                  echo GotoDeskAndPage $$\[ $[desk.n] - 1 \] $[FVWMmaxPageX] $[page.ny]; \
                fi; \
              else \
                  echo Scroll -100 0; \
              fi'

DestroyFunc CenterWindow
AddToFunc   CenterWindow
+ I Pick Piperead "echo AnimatedMove \
    $(( $[vp.width]/2-$[w.width]/2 ))p \
    $(( $[vp.height]/2-$[w.height]/2 ))p Warp"

# Expose-like function (needs patched FvwmRearrange)
DestroyFunc Expose
AddToFunc Expose
+ I SetEnv FVWMCountWindows 0
+ I All (CurrentPage, !Iconic, CirculateHit, !Sticky) PipeRead 'echo SetEnv FVWMCountWindows $((FVWMCountWindows + 1))'
+ I All (CurrentPage, !Iconic, CirculateHit, !Sticky, Maximized, !State 13, !State 14) State 16 On
+ I PipeRead 'echo ModuleSynchronous $[HOME]/.fvwm/FvwmRearrangeSync -tile -maximize -u -m -mn `$HOME/.fvwm/fvwmSqrt $FVWMCountWindows`'
+ I NoWindow Pick DeExpose $$$$[w.id]

DestroyFunc DeExpose
AddToFunc DeExpose
+ I All (CurrentPage, !Iconic, CirculateHit, !Sticky) DeExposeWindow
+ I WindowId $0 WarpToWindow 50 50

DestroyFunc DeExposeWindow
AddToFunc DeExposeWindow
+ I ThisWindow (State 16) Maximize On 100 100
+ I TestRc (NoMatch) Maximize off
+ I ThisWindow (State 13) Maximize On 0 100
+ I ThisWindow (State 14) Maximize On 100 0
+ I ThisWindow State 16 Off

DestroyFunc WMIArrange
AddToFunc WMIArrange
+ I Current ResizeMove frame 50 100 0 0
+ I Current WindowStyle WindowListSkip
+ I Current WarpToWindow 50 50
+ I UpdateStyles
+ I ModuleSynchronous $[HOME]/.fvwm/FvwmRearrangeSync -tile -u -m -h 50 0 100 100
+ I Current WindowStyle WindowListHit
+ I Current Raise

Style OneOfSTDDialogs NoTitle

# A more "elaborate" AltTab. It allows to go to the last focused
# window when hitting "AltTab" only once

# This is important
Style * FPSortWindowlistByFocus

DestroyFunc AltTab
AddToFunc AltTab
+ I PipeRead 'if [ "$$FVWMFirstAltTab" != "NO" ]; then \
                 echo FirstAltTab $0 $1; \
              else \
                 echo NthAltTab $0 $1; \
              fi'
+ I SetEnv FVWMFirstAltTab NO

DestroyFunc WarpAltTab
AddToFunc WarpAltTab
+ I WarpToWindow 50 50
+ I FlipFocus

DestroyFunc FirstAltTabAction
AddToFunc FirstAltTabAction
+ I $0
+ I State 15 Off
+ I WindowId $1 (!Sticky) State 15 On

DestroyFunc FirstAltTab
AddToFunc FirstAltTab
+ I Current (State 15) NthAltTab $0 $1
+ I TestRc (NoMatch) $0 (CurrentPage, State 15, !Iconic, !Shaded, AcceptsFocus) FirstAltTabAction $1 $[w.id]
+ I TestRc (NoMatch) $0 (CurrentPage, !Iconic, !Shaded, AcceptsFocus) FirstAltTabAction $1 $[w.id]

DestroyFunc NthAltTab
AddToFunc NthAltTab
+ I $0 (CurrentPage, !Iconic, !Shaded, AcceptsFocus) $1

######################################
# Functions from Taviso
######################################

DestroyFunc PackWindowUp
AddToFunc PackWindowUp
+ I SetEnv low_w 0
+ I WindowId $3 Raise
+ I All (CurrentPage, AnyScreen, !Iconic, AcceptsFocus, \
        !Shaded) PipeRead "test `expr $[w.y] + $[w.height]` -gt $[low_w] \
        -a `expr $[w.y] + $[w.height]` -lt $0 \
        -a \\( \\( $[w.x] -gt $1 -a $[w.x] -lt `expr $1 + $2` \\) \
            -o \\( $1 -gt $[w.x] -a $1 -lt `expr $[w.x] + $[w.width]` \\) \
            -o \\( $1 -le $[w.x] -a `expr $1 + $2` -ge `expr $[w.x] + $[w.width]` \\) \
            -o \\( $[w.x] -lt $1 -a `expr $[w.x] + $[w.width]` -gt `expr $1 + $2` \\) \
        \\) \
        && echo SetEnv low_w `expr $[w.y] + $[w.height]` \
        || echo Nop"
+ I WindowId $3 AnimatedMove keep $[low_w]p

AddToFunc PackWrapperUp I NoWindow PackWindowUp $[w.y] $[w.x] $[w.width] $[w.id]

DestroyFunc PackWindowDown
AddToFunc PackWindowDown
+ I SetEnv high_w $[vp.height]
+ I WindowId $3 Raise
+ I All (CurrentPage, AnyScreen, !Iconic, AcceptsFocus, \
        !Shaded) PipeRead "test $[w.y] -lt $[high_w] \
        -a $[w.y] -gt `expr $0 + $4` \
        -a \\( \\( $[w.x] -gt $1 -a $[w.x] -lt `expr $1 + $2` \\) \
            -o \\( $1 -gt $[w.x] -a $1 -lt `expr $[w.x] + $[w.width]` \\) \
            -o \\( $1 -le $[w.x] -a `expr $1 + $2` -ge `expr $[w.x] + $[w.width]` \\) \
            -o \\( $[w.x] -lt $1 -a `expr $[w.x] + $[w.width]` -gt `expr $1 + $2` \\) \
        \\) \
        && echo SetEnv high_w $[w.y] \
        || echo Nop"
+ I PipeRead "echo WindowId $3 AnimatedMove keep `expr $[high_w] - $4`p"

AddToFunc PackWrapperDown I NoWindow PackWindowDown $[w.y] $[w.x] $[w.width] $[w.id] $[w.height]

DestroyFunc PackWindowLeft
AddToFunc PackWindowLeft
+ I SetEnv left_w 0
+ I WindowId $3 Raise
+ I All (CurrentPage, AnyScreen, !Iconic, AcceptsFocus, \
        !Shaded) PipeRead "test `expr $[w.x] + $[w.width]` -gt $[left_w] \
        -a `expr $[w.x] + $[w.width]` -lt $1 \
        -a \\( \\( $[w.y] -gt $0 -a $[w.y] -lt `expr $0 + $4` \\) \
            -o \\( $[w.y] -lt $0 -a `expr $[w.y] + $[w.height]` -gt $0 \\) \
            -o \\( $[w.y] -ge $0 -a `expr $[w.y] + $[w.height]` -le `expr $0 + $4` \\) \
            -o \\( $[w.y] -lt $0 -a `expr $[w.y] + $[w.height]` -gt `expr $0 + $4` \\) \
        \\) \
        && echo SetEnv left_w `expr $[w.x] + $[w.width]` \
        || echo Nop"
+ I WindowId $3 AnimatedMove $[left_w]p keep

AddToFunc PackWrapperLeft I NoWindow PackWindowLeft $[w.y] $[w.x] $[w.width] $[w.id] $[w.height]

DestroyFunc PackWindowRight
AddToFunc PackWindowRight
+ I SetEnv right_w $[vp.width]
+ I WindowId $3 Raise
+ I All (CurrentPage, AnyScreen, !Iconic, AcceptsFocus, \
        !Shaded) PipeRead "test $[w.x] -lt $[right_w] \
        -a $[w.x] -gt `expr $1 + $2` \
        -a \\( \\( $[w.y] -gt $0 -a $[w.y] -lt `expr $0 + $4` \\) \
            -o \\( $[w.y] -lt $0 -a `expr $[w.y] + $[w.height]` -gt $0 \\) \
            -o \\( $[w.y] -ge $0 -a `expr $[w.y] + $[w.height]` -le `expr $0 + $4` \\) \
            -o \\( $[w.y] -lt $0 -a `expr $[w.y] + $[w.height]` -gt `expr $0 + $4` \\) \
        \\) \
        && echo SetEnv right_w $[w.x] \
        || echo Nop"
+ I PipeRead "echo WindowId $3 AnimatedMove `expr $[right_w] - $2`p keep"

AddToFunc PackWrapperRight I NoWindow PackWindowRight $[w.y] $[w.x] $[w.width] $[w.id] $[w.height]

################################################
# some simple default mouse bindings:
################################################
Mouse 3 R     A       Menu MainMenu Nop
#Mouse 3 WI    SC      CloseOrNot
Mouse 3 A     4M      Menu MainMenu Nop
Mouse 3 A     S       Move

Mouse 2 R     A       WindowList
Mouse 2 W     4       resize

Mouse 1 R     N       StrokeFunc DrawMotion
################################################
# for other parts of the window/borders/icons:
################################################
Mouse 1 F       A       Resize-or-Raise
Mouse 1 TS      A       Move-or-Raise
Mouse 1 I       A       Move-or-Iconify

#################################################
# for Volume control
#################################################
Mouse 4 A 4M Exec exec $fvwm_script/VulValue.sh 5
Mouse 5 A 4M Exec exec $fvwm_script/VulValue.sh "-5"

##################################################
# mouse defs for window
##################################################
## window frame and side
Mouse 1 F A Function ResizeOrRaiseOrLowerFunc
Mouse 2 F A Layer 0 5
Mouse 3 F A RaiseLower

Mouse 1 S A Function ResizeOrRaiseOrLowerFunc
Mouse 3 S A RaiseLower

Mouse 1 1 A Menu WindowOptionsMenuRight Nop
Mouse 2 1 A FuncChangeLayer
Mouse 3 1 A Menu WindowOptionsMenuLeft Nop

Mouse 1 3 A Function MoveOrRaiseOrLowerFunc
Mouse 2 3 A Resize

Mouse 1 2 A CloseOrNot
Mouse 2 2 A FuncCloseAllOrNot
Mouse 3 2 A DestroyOrNot

Mouse 1 6 A IconifyOrNot
Mouse 3 6 A FuncIconifySameResourceOrNot
Mouse 2 6 A FuncIconifyAllOrNot

Mouse 2 4 A Menu MaximizeMenu Nop
Mouse 1 4 A MaximizeOrNot
Mouse 3 4 A GrowOrNot

Mouse 1 8 A Function MoveOrRaiseOrLowerFunc
Mouse 3 8 A stick
Mouse 2 8 A Resize

Mouse 1 0 A Function MoveOrRaiseOrLowerFunc
Mouse 3 T A StrokeFunc DrawMotion
Mouse 1 T A Function MoveOrRaiseOrLowerFunc
Mouse 2 T A Resize

Mouse 4 W 4 Resize br w-5 w-5
Mouse 5 W 4 Resize br w+5 w+5


###############################################
# for screen shot
###############################################
Key s A M4 Exec exec scrot -q 100 '%m-%d-%H-%M-%S_$wx$h.png'
Key s A CM4 Exec exec scrot -b -s -q 100 '%m-%d-%H-%M-%S_$wx$h.png'

###############################################
# for Quit Fvwm/Close widnow/Icony all widnows
###############################################
Key q A CM4 menu ConfirmQuit
Key F4 W 4 CloseSilent
Key d A 4 FuncIconifyAll

###############################################
# Quit start some applications
###############################################
Key r A 4 Exec exec rox
Key t A 4 Exec exec mlterm
Key v A 4 Exec exec gvim
Key e A 4 Exec exec emacs

###############################################
# for move windows between Desks
###############################################
Key 1 WT 4 Silent MoveToDesk 0 0
Key 2 WT 4 Silent MoveToDesk 0 1
Key 3 WT 4 Silent MoveToDesk 0 2
Key 4 WT 4 Silent MoveToDesk 0 3

## stroke ########################################
# Move to desktop N
##################################################
Stroke N654 0 T N Silent MoveToDesk 0 0
Stroke N852 0 T N Silent MoveToDesk 0 1
Stroke N456 0 T N Silent MoveToDesk 0 2
Stroke N258 0 T N Silent MoveToDesk 0 3

#################################################
# for Go to Desk N
#################################################
Stroke N654 0 R N Exec exec $fvwm_script/gotodesk.sh 0
Stroke N852 0 R N Exec exec $fvwm_script/gotodesk.sh 1
Stroke N456 0 R N Exec exec $fvwm_script/gotodesk.sh 2
Stroke N258 0 R N Exec exec $fvwm_script/gotodesk.sh 3

Key F1 A M Exec exec $fvwm_script/gotodesk.sh 0
Key F2 A M Exec exec $fvwm_script/gotodesk.sh 1
Key F3 A M Exec exec $fvwm_script/gotodesk.sh 2
Key F4 A M Exec exec $fvwm_script/gotodesk.sh 3

#################################################
# Use Win+Tab key combination to switch desk
#################################################
SetEnv currentDeskNum
Key Tab A 4 Exec exec $fvwm_script/switchdesk.sh

######################################################################
# Key binders for moving window to 9 places
# -------------
# | 7 | 8 | 9 |
# -------------
# | 4 | 5 | 6 |
# -------------
# | 1 | 2 | 3 |
# -------------
######################################################################
key j W S4 PipeRead "~/.fvwm/scripts/GetTargetPosition.sh $[desk.width] $[desk.height] $[w.x] $[w.y] $[w.width] $[w.height] 1 $[pointer.x] $[pointer.y]"
key k W S4 PipeRead "~/.fvwm/scripts/GetTargetPosition.sh $[desk.width] $[desk.height] $[w.x] $[w.y] $[w.width] $[w.height] 2 $[pointer.x] $[pointer.y]"
key l W S4 PipeRead "~/.fvwm/scripts/GetTargetPosition.sh $[desk.width] $[desk.height] $[w.x] $[w.y] $[w.width] $[w.height] 3 $[pointer.x] $[pointer.y]"
key u W S4 PipeRead "~/.fvwm/scripts/GetTargetPosition.sh $[desk.width] $[desk.height] $[w.x] $[w.y] $[w.width] $[w.height] 4 $[pointer.x] $[pointer.y]"
key i W S4 PipeRead "~/.fvwm/scripts/GetTargetPosition.sh $[desk.width] $[desk.height] $[w.x] $[w.y] $[w.width] $[w.height] 5 $[pointer.x] $[pointer.y]"
key o W S4 PipeRead "~/.fvwm/scripts/GetTargetPosition.sh $[desk.width] $[desk.height] $[w.x] $[w.y] $[w.width] $[w.height] 6 $[pointer.x] $[pointer.y]"
key 7 W S4 PipeRead "~/.fvwm/scripts/GetTargetPosition.sh $[desk.width] $[desk.height] $[w.x] $[w.y] $[w.width] $[w.height] 7 $[pointer.x] $[pointer.y]"
key 8 W S4 PipeRead "~/.fvwm/scripts/GetTargetPosition.sh $[desk.width] $[desk.height] $[w.x] $[w.y] $[w.width] $[w.height] 8 $[pointer.x] $[pointer.y]"
key 9 W S4 PipeRead "~/.fvwm/scripts/GetTargetPosition.sh $[desk.width] $[desk.height] $[w.x] $[w.y] $[w.width] $[w.height] 9 $[pointer.x] $[pointer.y]"
########################################################################
# Keybind for start Applications
########################################################################
key f A CS Exec exec firefox
key b A CS Exec exec thunderbird
key g A CS Exec exec pidgin
key l A CS Exec exec lumaqq
key s A CS Exec exec stardict
key i A CS Exec exec xchat
key o A CS Exec exec opera
########################################################################
# Keybind for start system tools
########################################################################
key t A CM Exec exec roxterm
Stroke N7896 0 R N Exec exec roxterm
Stroke N78963 0 R N Exec exec roxterm
key l A CM Exec exec xscreensaver-command -lock
key r A CM Exec exec thunar
key u A CM Exec exec urxvtc -pe tabbed
########################################################################
# Media Section
########################################################################
key x A M Exec exec sudo /etc/init.d/mpd start
key x A SM Exec exec mpc play
key c A M Exec exec mpc prev
key v A M Exec exec mpc next
key p A M Exec exec mpc toggle
key s A M Exec exec sudo /etc/init.d/mpd stop
key s A MS Exec exec mpc stop
key Up A M Exec exec mpc volume +1
key Down A M Exec exec mpc volume -1
key Right A M Exec exec mpc seek +1s
key Left A M Exec exec mpc seek -1s

########################################################################
# Keybindings
########################################################################
Key Tab         A      C   AltTab Next WarpAltTab
Key backslash   A        4     AltTab Next Focus


# Only within a class
Key bracketright WSFT 4 Next (!Iconic, !Shaded, $[w.class]) WarpToWindow 50 1
Key bracketright WSFT S4 Next (!Iconic, !Shaded, $[w.class]) Focus
Key bracketleft WSFT 4 Prev (!Iconic, !Shaded, $[w.class]) WarpToWindow 50 1
Key bracketleft WSFT S4 Prev (!Iconic, !Shaded, $[w.class]) Focus

Key Space A 4 WindowList (CurrentPage) SortByClass
Key Space A S4 WindowList NoCurrentDeskTitle,TitleForAllDesks,SortByClass

# fvwm+direction (scrolls)
Key Left A    4     LeftPage
Key Up    A    4     Scroll +0 -100
Key Right A    4     RightPage
Key Down A    4     Scroll +0 +100

# fvwm+shift+directions moves windows
Key     Up WT       S4    MoveToPage 0w -1w
Key     Down        WT     S4 MoveToPage 0w +1w
Key     Left        WT     S4 MoveToPage -1w 0w
Key     Right       WT    S4 MoveToPage +1w 0w

# Window resizing and positioning
Key F1 A 4 Maximize 100 100
Key F1 A S4 MaximizeFullScreen
Key F2 A 4 MaximizeVertically
Key F3 A 4 MaximizeHorizontally
Key F4 A 4 IconifyWithThumbnail
Key F4 A S4 ShadeWindowAndSort

Key KP_Up    A 4 ResizeMoveMaximize frame 100 50 0 0 Warp
Key KP_Down A 4 ResizeMoveMaximize frame 100 50 0 50 Warp
Key KP_Left A 4 ResizeMoveMaximize frame 50 100 0 0 Warp
Key KP_Right A 4 ResizeMoveMaximize frame 50 100 50 0 Warp

Key KP_Home A 4 ResizeMoveMaximize frame 50 50 0 0 Warp
Key KP_Prior A 4 ResizeMoveMaximize frame 50 50 50 0 Warp
Key KP_End   A 4 ResizeMoveMaximize frame 50 50 0 50 Warp
Key KP_Next A 4 ResizeMoveMaximize frame 50 50 50 50 Warp

Key Escape WSFT 4 CenterWindow

Key E A 4 Expose

Key A WSFT 4 WMIArrange

# Closing a window
Key Q A 4 Current Close
Key Q A S4 Current Destroy

Key Z WSFT 4 RaiseLower

# Move and resize the windows with the keyboard
Key M WSFT 4 Move
Key M WSFT 4S Resize Direction SE
Key M WSFT 4C Resize Direction NW

# Resize the windows with the keyboard until a window is found
Key j WSFT 4SC Maximize growonwindowlayer true 0 growup
Key h WSFT 4SC Maximize growonwindowlayer true growleft 0
Key l WSFT 4SC Maximize growonwindowlayer true growright 0
Key k WSFT 4SC Maximize growonwindowlayer true 0 growdown

Key Left WSFT 4SC Maximize growonwindowlayer true growleft growup
Key Right WSFT 4SC Maximize growonwindowlayer true growright growdown
Key Up WSFT 4SC Maximize growonwindowlayer true growright growup
Key Down WSFT 4SC Maximize growonwindowlayer true growleft growdown

# Run dialog
Key R A 4 CreateRunDialog

# Show "hidden windows"
Key BackSpace A 4 HideUnhidePager


Key P A 4 ShowCursorPosition

# Show the root window or restore the windows
Key S A 4 ShadeAllWindows On
Key S A 4S ShadeAllWindows Off
Key I A 4 All (CurrentPage, !Iconic, !Shaded, !Sticky) IconifyWithThumbnail
Key I A 4S All (CurrentPage, Iconic) Iconify Off

Key T WSFT 4 ToggleTitle

# Change the title of a window
Key T WSFT 4S PipeRead 'echo Module FvwmForm FormWindowTitle WINDOWID=$[w.id] OLDTITLE="\\\"$[w.name]\\\"" POSX=$$$$[ ($[w.width] - 310) / 2 + $[w.x] ] POSY=$$$$[ $[w.y] + 4]'

# IM togggling
Key J A 4 HideUnhideIM
Key J A 4S UnhideIM

# IRC togggling
Key i A 4 HideUnhideIRC
Key i A 4S UnhideIRC

# I don't like when I press Control-J by mistake when I want to press Control-K
Key J WSFT C Nop

# Focus the windows according to their position
# Specially useful when using the WMIRearrange function
Key Up    A 4C Direction North (CurrentPage, !Iconic) WarpToWindow 50 50
Key Down A 4C Direction South (CurrentPage, !Iconic) WarpToWindow 50 50
Key Right A 4C Direction East (CurrentPage, !Iconic) WarpToWindow 50 50
Key Left A 4C Direction West (CurrentPage, !Iconic) WarpToWindow 50 50

# Navigating through icons (see http://fvwm.lair.be/viewtopic.php?t=1129)
Key Up    I N Direction North (CurrentPage, Iconic) Focus
Key Down I N Direction South (CurrentPage, Iconic) Focus
Key Right I N Direction East (CurrentPage, Iconic) Focus
Key Left I N Direction West (CurrentPage, Iconic) Focus
Key Return I N Current (Iconic) Iconify off

Key S A C4 SerbianKeyboard
Key space A CM USKeyboard
Key G A C4 GermanKeyboard

# Group Windows
Key 0 WI SC State 0
Key 1 WI SC State 1
Key 2 WI SC State 2
Key 3 WI SC State 3
Key 4 WI SC State 4
Key 5 WI SC State 5
Key 6 WI SC State 6
Key 7 WI SC State 7
Key 8 WI SC State 8
Key 9 WI SC State 9

Key 0 A C All (State 0) GroupFunc
Key 1 A C All (State 1) GroupFunc
Key 2 A C All (State 2) GroupFunc
Key 3 A C All (State 3) GroupFunc
Key 4 A C All (State 4) GroupFunc
Key 5 A C All (State 5) GroupFunc
Key 6 A C All (State 6) GroupFunc
Key 7 A C All (State 7) GroupFunc
Key 8 A C All (State 8) GroupFunc
Key 9 A C All (State 9) GroupFunc

#Key k WSFT 4 PackWrapperUp
#Key j WSFT 4 PackWrapperDown
#Key h WSFT 4 PackWrapperLeft
#Key l WSFT 4 PackWrapperRight