### vim:ft=fvwm:fdm=marker
###
### .fvwm/functions
###
### functions to get fvwm match my taste
### for some of these functions you need to
### have a FvwmPerl instance running
###
### Needs at least fvwm 2.5.16.
###
### Frank Terbeck <ft@bewatermyfriend.org>
### Last-Modified: Sat Feb 13 11:36:12 2010
###
### <http://ft.bewatermyfriend.org/comp/fvwm.html>
###
### this one is for Perl preprocessing
### {{{
DestroyFunc .
AddToFunc .
+ I SendToModule FvwmPerl preprocess -c -- $*
### }}}
###------------------------------------------------------------------###
### desktop functions ###
###------------------------------------------------------------------###
### {{{
### These two disables the wrap around feature of GotoDesk
DestroyFunc PrevDesktop
AddToFunc PrevDesktop
+ I . %{ if ($[desk.n] > $[first_desktop]) { "GotoDesk -1 0 $[first_desktop] $[last_desktop]"; } else { "Nop"; } }%
+ I UpdateDS
DestroyFunc NextDesktop
AddToFunc NextDesktop
+ I . %{ if ($[desk.n] < $[last_desktop]) { "GotoDesk +1 0 $[first_desktop] $[last_desktop]"; } else { "Nop"; } }%
+ I UpdateDS
DestroyFunc DeskJumpGo
AddToFunc DeskJumpGo
+ I . %{ if ($[desk.n] == $[marked_desktop]) { "GotoDesk prev" } else { "GotoDesk 0 $[marked_desktop] $[first_desktop] $[last_desktop]"; } }%
+ I UpdateDS
DestroyFunc DeskJumpMark
AddToFunc DeskJumpMark
+ I SetEnv marked_desktop $[desk.n]
+ I UpdateDS
### Update FvwmButton "DeskSwitch"'s Title
DestroyFunc UpdateDS
AddToFunc UpdateDS
+ I . %{ my ($premark, $postmark) = ('', ''); if ($[desk.n] == $[marked_desktop]) { $postmark = ' *'; $premark = '* '; } "SendToModule DeskSwitch ChangeButton desk Title \"$premark" . "$[desk.name$[desk.n]]" . "$postmark\""; }%
### this takes one argument and switches the view to the given argument
DestroyFunc Switch2Desk
AddToFunc Switch2Desk
+ I GotoDesk 0 $0 $[first_desktop] $[last_desktop]
+ I UpdateDS
DestroyFunc SwitchPrevDesk
AddToFunc SwitchPrevDesk
+ I GotoDesk prev
+ I UpdateDS
### }}}
###------------------------------------------------------------------###
### window resize/move/whatever functions ###
###------------------------------------------------------------------###
### {{{
### moving the window around on keypress
DestroyFunc ClickToMove
AddToFunc ClickToMove
+ M Move
### move the focused window to another Desktop
DestroyFunc MoveWinToDesktop
AddToFunc MoveWinToDesktop
+ I MoveToDesk 0 $0 $[first_desktop] $[last_desktop]
### my titlebar function
### if you click once the window raises, keep clicked and move the window;
### a DoubleClick puts the window into shadedmode
DestroyFunc Move-Raise-Shade
AddToFunc Move-Raise-Shade
+ I Raise
+ M Move
+ D WindowShade
### My WindowMaximization doesn't paint over my Dock and Icons;
### (Yes, I like the WMaker feeling ;)
DestroyFunc Maximize-Func
AddToFunc Maximize-Func
+ C Maximize -66p -62p
+ C Move +66p 0 Wrap
DestroyFunc Maximize-Func-Auto
AddToFunc Maximize-Func-Auto
+ I Maximize -66p -62p
+ I Move +66p 0 Wrap
### Move the mouse pointer to a sane position after certain actions
DestroyFunc MP-Warp-Auto
AddToFunc MP-Warp-Auto
+ I ThisWindow WarpToWindow 50 25
### similar to Move-Raise-Shade, but for icons;
### click: raise, move: move, doubleclick: deiconify
DestroyFunc Move-or-Iconify
AddToFunc Move-or-Iconify
+ I Raise
+ M Move
+ D Iconify
### the next 8 functions are for resizing my windows
### you got 8 regions in your border/handle, i'm doing different
### resizing methods for each region
DestroyFunc ResizeW
AddToFunc ResizeW
+ M Resize Direction W
DestroyFunc ResizeE
AddToFunc ResizeE
+ M Resize Direction E
DestroyFunc ResizeN
AddToFunc ResizeN
+ M Resize Direction N
DestroyFunc ResizeS
AddToFunc ResizeS
+ M Resize Direction S
DestroyFunc ResizeNW
AddToFunc ResizeNW
+ M Resize Direction NW
DestroyFunc ResizeNE
AddToFunc ResizeNE
+ M Resize Direction NE
DestroyFunc ResizeSE
AddToFunc ResizeSE
+ M Resize Direction SE
DestroyFunc ResizeSW
AddToFunc ResizeSW
+ M Resize Direction SW
### Resize window if the mouse button is in the lower right corner of a window.
### On the rest of the right part of the window, we resize horizontally. On the
### rest of the lower part of the window, we resize vertically. Else, fall back
### to ClickToMove; Based on an idea by Daniel Wilmer.
DestroyFunc ResizeLRWC
AddToFunc ResizeLRWC
+ M PipeRead 'rel_x_pos=$(($[pointer.wx]00 / $[w.width])); \
rel_y_pos=$(($[pointer.wy]00 / $[w.height])); \
if [ "${rel_y_pos}" -gt 80 ] && \
[ "${rel_x_pos}" -gt 80 ] ; then \
echo "Resize Direction SE"; \
elif [ "${rel_y_pos}" -lt 80 ] && \
[ "${rel_x_pos}" -gt 80 ] ; then \
echo "Resize Direction E"; \
elif [ "${rel_y_pos}" -gt 80 ] && \
[ "${rel_x_pos}" -lt 80 ] ; then \
echo "Resize Direction S"; \
else \
echo "ClickToMove"; \
fi'
### }}}
###------------------------------------------------------------------###
### dynamic menu functions ###
###------------------------------------------------------------------###
### {{{
DestroyFunc genwallpapersmenu
AddToFunc genwallpapersmenu
+ I DestroyMenu recreate wallpapers
+ I AddToMenu wallpapers "wallpapers" Title
+ I PipeRead 'perl $[FVWM_USERDIR]/bin/gen_menu_wallpapers.pl $[HOME]/etc/graphics/wallpapers wallpapers png habak'
DestroyFunc genmovemenu
AddToFunc genmovemenu
+ I DestroyMenu recreate MoveToWorkspace
+ I AddToMenu MoveToWorkspace "workspace" Title
+ I PipeRead 'perl $[FVWM_USERDIR]/bin/gen_move_menu.pl MoveToWorkspace $[first_desktop] $[last_desktop] $[desk.n]'
DestroyFunc gentmuxsessionsmenu
AddToFunc gentmuxsessionsmenu
+ I DestroyMenu recreate dynsessions
+ I AddToMenu dynsessions "existing sessions" Title
+ I PipeRead 'perl $[FVWM_USERDIR]/bin/gen_tmuxsessions_menu.pl dynsessions $[FVWM_USERDIR]/bin/fvwm_launch.sh tmux'
### }}}
###------------------------------------------------------------------###
### misc. functions ###
###------------------------------------------------------------------###
### {{{
DestroyFunc EWMHActivateWindowFunc
# AddToFunc EWMHActivateWindowFunc
### wrap the cursor to the left upper corner of the window
### and open Menu WindowOpts
DestroyFunc menu_wopts
AddToFunc menu_wopts
+ I WarpToWindow 38p 8p
+ I Menu WindowOpts Nop
### This is run whenever a window is created.
### Be careful, when adding things to this one.
DestroyFunc CreateWindow
AddToFunc CreateWindow
+ I ThisWindow ("Emacs") Maximize-Func-Auto
+ I ThisWindow ("Gvim") Maximize-Func-Auto
+ I ThisWindow ("xCHM*") Maximize-Func-Auto
+ I ThisWindow ("Evince*") Maximize-Func-Auto
+ I ThisWindow ("Djview*") Maximize-Func-Auto
+ I ThisWindow (PlacedByButton 1) MP-Warp-Auto
+ I ThisWindow (PlacedByButton 2) MP-Warp-Auto
+ I ThisWindow (PlacedByButton 3) MP-Warp-Auto
### changed the WarpToWindow offsets a bit
DestroyFunc WindowListFunc
AddToFunc WindowListFunc
+ I WindowId $0 Iconify off
+ I WindowId $0 FlipFocus
+ I WindowId $0 Raise
+ I WindowId $0 WarpToWindow 50 25
+ I UpdateDS
### MyEdgeFunc isn't used currently...
DestroyFunc MyEdgeFunc
AddToFunc MyEdgeFunc
+ C Module FvwmConsole -terminal xterm -g 155x12+70+0
### }}}