chiark / gitweb /
Imported Upstream version 1.0.0
[e16] / sample-scripts / testroller.pl
1 #!/usr/bin/perl
2
3 # Copyright (C) 2000-2004 Carsten Haitzler, Geoff Harrison and various contributors
4
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # of this software and associated documentation files (the "Software"), to
7 # deal in the Software without restriction, including without limitation the
8 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 # sell copies of the Software, and to permit persons to whom the Software is
10 # furnished to do so, subject to the following conditions:
11
12 # The above copyright notice and this permission notice shall be included in
13 # all copies of the Software, its documentation and marketing & publicity
14 # materials, and acknowledgment shall be given in the documentation, materials
15 # and software packages that this Software was used.
16
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 # THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24 # This script is still VERY VERY VERY early on in development
25 # but I wanted to give you folks an idea of why the IPC was being
26 # set up the way it was.  this is just a quick hack.  expect better
27 # samples in the near future.
28 # This app will take the parameters "on" and "off", and will basically
29 # shade all the windows on the current desktop and area.  (or unshade)
30 #
31 # --Mandrake
32
33 # here we're going to test to see whether we are shading or unshading
34 # the window.
35
36 if($ARGV[0] eq "on") {
37         $shade = 1;
38 } else {
39         $shade = 0;
40 }
41
42 # here we'll retreive the current desk we're on
43
44 $_ = `eesh desk`;
45 @stuff = split(/\s*:\s*/);
46 @stuff = split(/\s*\/\s*/, $stuff[1]);
47 $current_desk = $stuff[0];
48
49 # here we'll retreive the current area we're on
50
51 $_ = `eesh area`;
52 @stuff = split(/\s*\n\s*/);
53 @stuff = split(/\s*:\s*/, $stuff[0]);
54 $current_area = $stuff[1];
55 $current_area =~ s/\n//g;
56
57
58 # get the old shadespeed so that we can set it back later
59 # because we want this to happen fairly quickly, we'll set
60 # the speed to something really high
61
62 $_ = `eesh show misc.shading.speed`;
63 @stuff = split(/\s*\n\s*/);
64 @stuff = split(/\s*=\s*/, $stuff[0]);
65 $shadespeed = $stuff[1];
66
67 open IPCPIPE,"| eesh";
68 print IPCPIPE "set misc.shading.speed 10000000\n";
69
70 # now we're going to walk through each of these windows and
71 # shade them
72
73 @winlist = `eesh window_list a`;
74 foreach (@winlist) {
75         if (/\s*(\w+)\s* : .* :: \s*(-*\d+)\s* : (.*) : (.*)$/) {
76                 $window = $1;
77                 $desk = $2;
78                 $area = $3;
79                 $name = $4;
80
81                 # Skip pagers, iconboxes, systrays, and epplets
82                 next if ($name =~ /^Pager-|Iconbox|Systray|E-/);
83 #               next unless (($desk == -1) and ($desk eq $current_desk));
84                 next unless ($desk eq $current_desk);
85                 next unless ($area eq $current_area);
86                 if ($shade) {
87                         print IPCPIPE "win_op $window shade on\n";
88                 } else {
89                         print IPCPIPE "win_op $window shade off\n";
90                 }
91         }
92 }
93
94 # now we're going to set the shade speed back to what it was originally
95
96 print IPCPIPE "set misc.shading.speed $shadespeed\n";
97 close IPCPIPE;
98
99 # that's it!