cvsimport
[fvwm.git] / modules / FvwmCommand / scripts / ex-auto.pl
blob85dc23fa7a7b03610ea15e24b7666d627d101daa
1 #! xPERLx
2 # FvwmCommand example - auto raise small windows
3 # arg1 - size ( w * h in pixel) (default 60000)
4 # arg2 - delay (second) (default 1)
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 open( FCM, "FvwmCommand -m -i3 send_windowlist |" ) || die "FCM";
21 open( FCC, ">$ENV{'HOME'}/.FvwmCommandC" ) || die "FCC";
23 select( FCC ); $| = 1;
24 select( STDOUT ); $| = 1;
27 $Size = shift;
28 if( $Size <= 0 ) {
29 $Size = 60000;
32 if( $#ARGV >= 0) {
33 $Delay = shift;
34 }else{
35 $Delay = 1;
39 LOOP1:while( <FCM> ) {
40 if( /^0x(\S+) frame .*width (\d+), height (\d+)/ ) {
41 $Config{$1}{'area'} = $2 * $3;
42 }elsif( /^0x(\S+) (focus change|end windowlist)/ ) {
44 if( $1 != 0 ) {
45 # delay longer than FvwmAuto
46 select(undef,undef,undef,$Delay);
48 foreach $w (keys %Config) {
49 if( $Config{$w}{'area'} < $Size ) {
50 print FCC "windowid 0x$w Raise\n";
52 # ignore
53 while(<FCM>) {
54 last if /^0x$w raise/;
55 redo LOOP1 if /^0x\S+ focus change/;
57 select(undef,undef,undef,0.1);