]> git.phdru.name Git - dotfiles.git/blob - .fvwm/functions
Feat(recode-filenames-recursive): Allow to omit parameters
[dotfiles.git] / .fvwm / functions
1 #----------------------------------------------------------------------------#
2 #
3 # 8. Now define some handy complex functions
4 #
5 #----------------------------------------------------------------------------#
6
7 #------------------------------------------------------------------------------
8 # This one moves and then raises the window if you drag the mouse,
9 # only raises the window if you click, or does a vertical maximize if
10 # you double click (full screen maximize would be 'Maximize 100 100')
11 #------------------------------------------------------------------------------
12
13 DestroyFunc Move-or-Raise
14 AddToFunc Move-or-Raise M Move
15 +                       M Raise
16 +                       C Raise
17 +                       D Maximize 0 100
18
19
20 #------------------------------------------------------------------------------
21 # As above but double click shade
22 #------------------------------------------------------------------------------
23
24 DestroyFunc Move-or-Raise-or-Shade
25 AddToFunc Move-or-Raise-or-Shade M Move
26 +                       M Raise
27 +                       C Raise
28 +                       D WindowShade
29
30 #------------------------------------------------------------------------------
31 # This one moves and then lowers the window if you drag the mouse,
32 # only lowers the window if you click, or does a RaiseLower if you double
33 # click
34 #------------------------------------------------------------------------------
35
36 DestroyFunc Move-or-Lower
37 AddToFunc Move-or-Lower M Move
38 +                       M Lower
39 +                       C Lower
40 +                       D RaiseLower
41
42
43 #------------------------------------------------------------------------------
44 # This one moves or (de)iconifies:
45 #------------------------------------------------------------------------------
46
47 DestroyFunc Move-or-Iconify-or-Raise
48 AddToFunc Move-or-Iconify-or-Raise M Move
49 +                         C Raise
50 +                         D Iconify
51
52 #------------------------------------------------------------------------------
53 # This one maximizes vertically if you click (leaving room for the taskbar
54 # at the bottom, or does a full maximization if you double click, or a
55 # true full vertical maximization if you just hold the mouse button down.
56 #------------------------------------------------------------------------------
57
58 DestroyFunc Maximize-Func
59 AddToFunc Maximize-Func M       Maximize 0 98
60 +                       C       Maximize 0 100
61 +                       D       Maximize 100 98
62
63 #------------------------------------------------------------------------------
64 # This one resizes and then raises the window if you drag the mouse,
65 # only raises the window if you click,  or does shade if you double
66 # click
67 #------------------------------------------------------------------------------
68
69 DestroyFunc Resize-or-Raise-or-Shade
70 AddToFunc Resize-or-Raise-or-Shade M Resize
71 +                         M Raise
72 +                         C Raise
73 +                         D WindowShade
74
75
76 #------------------------------------------------------------------------------
77 # This one focuses and then 'warps' to the window.
78 #------------------------------------------------------------------------------
79
80
81 DestroyFunc FocusAndWarp
82 AddToFunc FocusAndWarp I Focus
83 +                      I WarpToWindow 1 1
84
85
86 #------------------------------------------------------------------------------
87 # Like the previous one, but de-iconifies first.
88 #------------------------------------------------------------------------------
89
90 DestroyFunc DeiconifyFocusAndWarp
91 AddToFunc DeiconifyFocusAndWarp I Iconify off
92 +                               I FocusAndWarp
93
94 #------------------------------------------------------------------------------
95 # Like the previous one, but only Raise.
96 #------------------------------------------------------------------------------
97
98 DestroyFunc DeiconifyFocusAndRaise
99 AddToFunc DeiconifyFocusAndRaise I Iconify off
100 +                               I Focus
101 +                               I Raise
102
103 #------------------------------------------------------------------------------
104 # This one is used to modify some style for a window (almost obsolet)
105 #------------------------------------------------------------------------------
106
107 DestroyFunc StyleAndRecapture
108 AddToFunc StyleAndRecapture I Style "$0" $1
109 + I All ("$0") RecaptureWindow
110
111
112 #------------------------------------------------------------------------------
113 # A really useful one: de-iconifies, warps to the window
114 # or creates it if it doen't exist (often used with mailtools)
115 #------------------------------------------------------------------------------
116
117 DestroyFunc WarpOrExec
118 AddToFunc WarpOrExec       I Next (AcceptsFocus $0) Iconify -1
119 +                          I Next (AcceptsFocus $0) FocusAndWarp
120 +                          I None (AcceptsFocus $0) Exec $0 $1
121
122 #------------------------------------------------------------------------------
123 # For the left button
124 #------------------------------------------------------------------------------
125
126 DestroyMenu "window_ops_func"
127 AddToFunc "window_ops_func" "C" PopUp Window-Ops2
128 +              "M" PopUp Window-Ops2
129 +              "D" Delete
130
131 #------------------------------------------------------------------------------
132 # Functions to restart Modules and Restart/Kill FvwmButtons by aliases
133 #------------------------------------------------------------------------------
134
135 DestroyFunc RestartModule
136 AddToFunc RestartModule
137 + I KillModule $0
138 + I Module $0
139
140 DestroyFunc RestartModuleByAlias
141 AddToFunc RestartModuleByAlias
142 + I All ($2) Close
143 + I Module $0 $1
144
145
146 # This function is for WMakerFvwmButtons (start or iconify id started)
147 DestroyFunc MyPanelButtons
148 AddToFunc  MyPanelButtons
149 + I All ($0) Iconify
150 + I None (CirculateHit $0) FvwmButtons -g +$1+$2 $0
151
152 #------------------------------------------------------------------------------
153 # Functions for FvwmScript-BaseConfig
154 #------------------------------------------------------------------------------
155
156 DestroyFunc BaseConfigOkFunc
157 AddToFunc BaseConfigOkFunc I Read styles
158
159 DestroyFunc BaseConfigApplyFunc
160 AddToFunc BaseConfigApplyFunc I Read styles
161
162
163 #------------------------------------------------------------------------------
164 # Functions which start and save state for FvwmAnimate, FvwmEvent, etc ...
165 # $1 $2 is used only by FvwmAuto
166 #------------------------------------------------------------------------------
167
168 DestroyFunc ModuleOn
169 AddToFunc   ModuleOn
170 + I KillModule $0
171 + I Module $0 $1 $2
172 + I Exec echo "AddToFunc StartFunction I $0 $1 $2" > $FVWM_USERDIR/.start-$0
173
174 DestroyFunc ModuleOff
175 AddToFunc   ModuleOff
176 + I KillModule $0
177 + I Exec echo "# Do not start $0" > $FVWM_USERDIR/.start-$0
178
179 #------------------------------------------------------------------------------
180 # Functions which start and save state for MiniButtons and WinMakerAppButtons
181 #------------------------------------------------------------------------------
182
183 DestroyFunc ButtonsOn
184 AddToFunc   ButtonsOn
185 + I All ($2) Close
186 + I Module $0 $1
187 + I Exec echo "AddToFunc StartFunction I $0 $1" > $FVWM_USERDIR/.start-$1
188
189 DestroyFunc ButtonsOff
190 AddToFunc   ButtonsOff
191 + I All ($1) Close
192 + I Exec echo "# Do not start $0" > $FVWM_USERDIR/.start-$0
193
194 #------------------------------------------------------------------------------
195 # Functions for choosing the "Big" buttons Wharf or BarButtons
196 #------------------------------------------------------------------------------
197
198 DestroyFunc ChangeButtonsOn
199 AddToFunc  ChangeButtonsOn
200 + I All (BarButtons) Close
201 + I KillModule FvwmWharf
202 + I Exec echo "AddToFunc StartFunction I $0" > $FVWM_USERDIR/.start-FvwmButtons
203 + I $0
204
205 DestroyFunc ChangeButtonsOff
206 AddToFunc  ChangeButtonsOff
207 + I All (BarButtons) Close
208 + I KillModule FvwmWharf
209 + I Exec echo "# No Buttons Bar" > $FVWM_USERDIR/.start-FvwmButtons
210 + I $0
211
212 #------------------------------------------------------------------------------
213 # Functions for Raising modules only
214 #------------------------------------------------------------------------------
215
216 DestroyFunc StartModulesAutoRaise
217 AddToFunc StartModulesAutoRaise
218 + I Style FvwmDesker Lenience
219 + I FvwmAuto 400 Silent ModulesAutoRaise
220 + I Exec echo "AddToFunc StartFunction I StartModulesAutoRaise" > $FVWM_USERDIR/.start-FvwmAuto
221
222 DestroyFunc ModulesAutoRaise
223 AddToFunc ModulesAutoRaise
224 + I Current (FvwmButtons) Raise
225 + I Current (FvwmTaskBar) Raise
226 + I Current (FvwmIconBox) Raise
227 + I Current (FvwmDesker)  Raise
228 + I Current (FvwmIconMan) Raise
229 + I Current (FvwmWinList) Raise
230 + I Current (FvwmWharf)   Raise
231 + I Current (panel)       Raise
232
233 #------------------------------------------------------------------------------
234 # Functions which start and save a background
235 #------------------------------------------------------------------------------
236
237 DestroyFunc SetBackground
238 AddToFunc   SetBackground
239 + I KillModule FvwmBacker
240 + I $0
241 + I Exec echo "AddToFunc StartFunction I $0" > $FVWM_USERDIR/.start-Background
242
243 DestroyFunc SetBackgroundOff
244 AddToFunc   SetBackgroundOff
245 + I KillModule FvwmBacker
246 + I Exec echo "# Background disabled" > $FVWM_USERDIR/.start-Background
247
248 #------------------------------------------------------------------------------
249 # Functions which start and defines which applications manager we use
250 #------------------------------------------------------------------------------
251
252 DestroyFunc ChangeAppsMan
253 AddToFunc  ChangeAppsMan
254 + I KillModule FvwmTaskBar
255 + I KillModule FvwmWinList
256 + I KillModule FvwmIconMan
257 + I KillModule FvwmIconBox
258 + I Exec echo "AddToFunc StartFunction I $0" > $FVWM_USERDIR/.start-apps-man
259 + I $0
260
261 DestroyFunc AppsManNone
262 AddToFunc  AppsManNone
263 +  I  Style * NoIcon
264 + I KillModule FvwmTaskBar
265 + I KillModule FvwmWinList
266 + I KillModule FvwmIconMan
267 + I KillModule FvwmIconBox
268 + I Exec echo "AddToFunc StartFunction I Style * NoIcon # No applications Manager" > $FVWM_USERDIR/.start-apps-man
269
270 DestroyFunc UseIcons
271 AddToFunc  UseIcons
272 + I Style * Icon
273 + I Read iconstyles
274 # Need to reaload menus for KDE mini-icons styles
275 + I Read menus
276 + I KillModule FvwmTaskBar
277 + I KillModule FvwmWinList
278 + I KillModule FvwmIconMan
279 + I KillModule FvwmIconBox
280 + I Exec echo "# Use Icons" > $FVWM_USERDIR/.start-apps-man
281
282 DestroyFunc WinListDesk
283 AddToFunc WinListDesk
284 + I Style * NoIcon
285 + I *FvwmWinList: ShowCurrentDesk
286 + I Module FvwmWinList
287
288 DestroyFunc WinListGlobal
289 AddToFunc WinListGlobal
290 + I Style * NoIcon
291 + I DestroyModuleConfig FvwmWinList: ShowCurrent*
292 + I Module FvwmWinList
293
294 DestroyFunc TaskBarDesk
295 AddToFunc TaskBarDesk
296 + I Style * NoIcon
297 + I DestroyModuleConfig FvwmTaskBar: AutoHid*
298 + I *FvwmTaskBar: DeskOnly
299 + I Module FvwmTaskBar
300
301 DestroyFunc TaskBarGlobal
302 AddToFunc TaskBarGlobal
303 + I Style * NoIcon
304 + I DestroyModuleConfig FvwmTaskBar: AutoHid*
305 + I DestroyModuleConfig FvwmTaskBar: Desk*
306 + I Module FvwmTaskBar
307
308 DestroyFunc TaskBarDeskAutoHide
309 AddToFunc TaskBarDeskAutoHide
310 + I Style * NoIcon
311 + I *FvwmTaskBar: DeskOnly
312 + I *FvwmTaskBar: AutoHide
313 + I Module FvwmTaskBar
314
315 DestroyFunc TaskBarGlobalAutoHide
316 AddToFunc TaskBarGlobalAutoHide
317 + I Style * NoIcon
318 + I DestroyModuleConfig FvwmTaskBar: Desk*
319 + I *FvwmTaskBar: AutoHide
320 + I Module FvwmTaskBar
321
322 DestroyFunc IconManGlobal
323 AddToFunc IconManGlobal
324 + I Style * NoIcon
325 + I *FvwmIconMan: *Resolution global
326 + I Module FvwmIconMan
327
328 DestroyFunc IconManDesk
329 AddToFunc IconManDesk
330 + I Style * NoIcon
331 + I *FvwmIconMan: *Resolution desk
332 + I Module FvwmIconMan
333
334 DestroyFunc IconManPage
335 AddToFunc IconManPage
336 + I Style * NoIcon
337 + I *FvwmIconMan: *Resolution page
338 + I Module FvwmIconMan
339
340 DestroyFunc IconBoxDesk
341 AddToFunc IconBoxDesk
342 + I Style * NoIcon
343 + I *FvwmIconBox: ResolutionDesk
344 + I Module FvwmIconBox
345
346 DestroyFunc IconBoxGlobal
347 AddToFunc IconBoxGlobal
348 + I Style * NoIcon
349 + I DestroyModuleConfig FvwmIconBox: Reso*
350 + I Module FvwmIconBox
351
352 #------------------------------------------------------------------------------
353 # Functions for Layers
354 #------------------------------------------------------------------------------
355
356 DestroyFunc SetLayers
357 AddToFunc SetLayers
358 + I StyleAndRecapture $n $0
359 + I Exec F=$FVWM_USERDIR; Z=$F/.fvwm-layers; T=$F/.tmp-layers; if grep -qe "$n" $Z; then sed -e "s/\ $n\ .*/\ $n\ $0/" $Z>$T; cat $T>$Z; else echo "Style $n $0" >>$Z; fi
360
361 DestroyFunc DestroyLayers
362 AddToFunc DestroyLayers
363 + I StyleAndRecapture $n StaysPut
364 + I Exec F=$FVWM_USERDIR; Z=$F/.fvwm-layers; T=$F/.tmp-layers; sed -e "/^Style\ $n\ .*/d" $Z>$T; cat $T>$Z
365
366 #------------------------------------------------------------------------------
367 # Function for reloading the icons styles
368 #------------------------------------------------------------------------------
369
370 DestroyFunc ReloadIconStylesAndMenus
371 AddToFunc ReloadIconStylesAndMenus
372 + I Read iconstyles
373 + I Read menus
374 # Need to reload the NoIcon style
375 + I PipeRead 'if grep -qe AddToFunc $FVWM_USERDIR/.start-apps-man; then echo "Style * NoIcon"; fi'
376
377 #------------------------------------------------------------------------------
378 # Functions for Loading/Saving/Showing Settings
379 #------------------------------------------------------------------------------
380
381 DestroyFunc SaveAsSettings
382 AddToFunc SaveAsSettings
383 + I Exec F=$FVWM_USERDIR;for i in ~/.xinitrc-fvwm $F/.FvwmBaseConfig $F/.FvwmAnimate $F/.FvwmForm $F/.start-Background $F/.start-apps-man $F/.start-FvwmButtons $F/.start-DeskerPanelButtons $F/.start-MiniButtons $F/.start-WinMakerAppButtons $F/.start-FvwmAnimate $F/.start-FvwmAuto $F/.start-FvwmBanner $F/.start-FvwmEvent $F/.fvwm-layers; do [ ! -f "$i" ] || /bin/cp $i $i-$0; done;
384
385 DestroyFunc LoadSettings
386 AddToFunc LoadSettings
387 + I Exec F=$FVWM_USERDIR; for i in ~/.xinitrc-fvwm $F/.FvwmBaseConfig $F/.FvwmAnimate $F/.FvwmForm $F/.start-Background $F/.start-apps-man $F/.start-FvwmButtons $F/.start-DeskerPanelButtons $F/.start-MiniButtons $F/.start-WinMakerAppButtons $F/.start-FvwmAnimate $F/.start-FvwmAuto $F/.start-FvwmBanner $F/.start-FvwmEvent $F/.fvwm-layers; do [ ! -f "$i-$0" ] || /bin/cp $i-$0 $i; done;
388 + I Exec [ ! -f ~/.xinitrc-fvwm-$0 ] || (xscreensaver-command -exit; ~/.xinitrc-fvwm-$0)
389 + I PipeRead '[ ! -f $FVWM_USERDIR/.FvwmBaseConfig ] || (echo Read .FvwmBaseConfig; echo BaseConfigOkFunc)'
390 + I Style * StaysPut
391 + I Read .fvwm-layers-$0
392 + I KillModule FvwmAnimate
393 + I KillModule FvwmAuto
394 + I KillModule FvwmEvent
395 + I KillModule FvwmButtons
396 + I KillModule FvwmWharf
397 + I KillModule FvwmTaskBar
398 + I KillModule FvwmWinList
399 + I KillModule FvwmIconMan
400 + I KillModule FvwmIconBox
401 + I PipeRead 'F=$FVWM_USERDIR; F=$FVWM_USERDIR; for i in $F/.start-Background $F/.start-apps-man $F/.start-FvwmButtons $F/.start-DeskerPanelButtons $F/.start-MiniButtons $F/.start-WinMakerAppButtons $F/.start-FvwmAnimate $F/.start-FvwmAuto $F/.start-FvwmBanner $F/.start-FvwmEvent; do [ ! -f "$i-$0" ] || sed -e s/AddToFunc\\.StartFunction\\.I\\.// $i-$0; done; if [ -f "$F/.start-apps-man-$0" ]; then if grep -qe Icons $F/.start-apps-man-$0; then echo "Style * Icon"; echo "Read iconstyles"; echo "Read menus"; fi; fi'
402
403 DestroyFunc ShowFvwmSettings
404 AddToFunc ShowFvwmSettings I Exec F=$FVWM_USERDIR;f=$F/.tmp-modules-setting; echo "" > $f; for j in 0 1 2 3 4; do if [ "$j" -eq "0" ]; then j=""; t="Current Setting:"; l="--------------"; else j="-$j"; t="Setting$j:"; l="---------"; fi; echo $t >> $f; echo $l >> $f; for i in $F/.start-Background $F/.start-apps-man $F/.start-FvwmButtons $F/.start-DeskerPanelButtons $F/.start-MiniButtons $F/.start-WinMakerAppButtons $F/.start-FvwmAnimate $F/.start-FvwmAuto $FVWM_USERDIR/.start-FvwmBanner $F/.start-FvwmEvent; do z="$i$j"; [ ! -f "$z" ] || sed -e s/^\\#\.// -e s/\.*exec/Background:/ -e s/AddToFunc\.StartFunction\.I/Start/ -e s/FvwmEvent/Sounds\ Effect/ $z >> $f; done; echo -n "Base Config: ">>$f; if [ -f $F/.FvwmBaseConfig$j ]; then echo "Used">>$f; else echo "Not Used">>$f; fi; echo "">>$f;done; xmessage -file $f
405
406 DestroyFunc ShowXSettings
407 AddToFunc ShowXSettings \
408 I Exec T=$FVWM_USERDIR/.tmp-x-set;u=~/.xinitrc-fvwm;echo "">$T;for j in 0 1 2 3 4;do if [ "$j" -eq "0" ];then z=$u;t="Current Setting:";else z="$u-$j";t="Setting-$j:";fi;echo $t >>$T;if grep -qe Bell $z;then grep -e "xset b" $z|sed -e s/xset\.b/Bell:/>>$T;fi;if grep -qe Screen $z;then echo -n "Background: ">>$T;if grep -qe \#xsetroot $z;then echo "disabled">>$T;elif grep -qe xpmroot $z;then grep -e xpmroot $z|sed -e s/xpmroot\.//>>$T;else grep -e xsetroot $z|sed -e s/xsetroot\.//>>$T;fi;grep -e "xset s" $z|sed -e s/xset\.s/xsaver:/>>$T;echo -n "DPMS: ">>$T;grep -e xset\.*dpms $z|sed -e s/xset\.-dpms/Off/ -e s/xset\.dpms/On/>>$T;echo -n "xscreensaver: ">>$T;if grep -qe \#xscreen $z;then echo "Off">>$T;else echo "On">>$T;fi;fi;if grep -qe Keyboard $z;then echo -n "Keyboard: ">>$T;grep -e "xset r" $z|sed -e s/xset\.r/auto\ repeat/ -e s/c/Vol/>>$T;fi;if grep -qe Pointer $z;then echo -n "Mouse: ">>$T;grep -e "xset m" $z|sed -e s/xset\.m//>>$T;fi;echo "">>$T;done;xmessage -file $T
409
410
411 DestroyFunc ShowLayers
412 AddToFunc ShowLayers I Exec F=$FVWM_USERDIR; T=$F/.tmp-layers; echo -e "A StaysOnTop window is a window which is above \nthe normal (i.e., StaysPut) windows, a StaysOnBottom\nwindow is below the normal windows. Here the list\nof StaysOnTop and StaysOnBottom windows:\n"> $T; u=$F/.fvwm-layers; for j in 0 1 2 3 4; do if [ "$j" -eq "0" ];then z=$u; t="Current Setting:"; l="---------------"; else z="$u-$j"; t="Setting-$j:"; l="----------"; fi; echo $t >>$T; echo $l >>$T; [ ! -f $z ] || cat $z>>$T; echo "" >> $T; done; xmessage -file $T
413