1 | #! perl |
1 | #! perl |
2 | |
2 | |
3 | our $EXPR = 'move load "/root/pix/das_fette_schwein.jpg", repeat_wrap, X, Y'; |
3 | #:META:X_RESOURCE:%.expr:string:background expression |
|
|
4 | #:META:X_RESOURCE:%.enable:boolean:some boolean |
|
|
5 | #:META:X_RESOURCE:%.extra.:value:extra config |
|
|
6 | |
|
|
7 | our $EXPR = 'move X, Y, load "MagnoliaAlpha.png"'; |
4 | $EXPR = ' |
8 | #$EXPR = ' |
5 | rotate W, H, 50, 50, counter 1/59.95, repeat_mirror, |
9 | # rotate W, H, 50, 50, counter 1/59.95, repeat_mirror, |
6 | clip X, Y, W, H, repeat_mirror, |
10 | # clip X, Y, W, H, repeat_mirror, |
7 | load "/root/pix/das_fette_schwein.jpg" |
11 | # load "/root/pix/das_fette_schwein.jpg" |
8 | '; |
12 | #'; |
|
|
13 | #$EXPR = 'solid "red"'; |
9 | #$EXPR = 'blur root, 10, 10' |
14 | #$EXPR = 'blur root, 10, 10' |
10 | #$EXPR = 'blur move (root, -x, -y), 5, 5' |
15 | #$EXPR = 'blur move (root, -x, -y), 5, 5' |
11 | #resize load "/root/pix/das_fette_schwein.jpg", w, h |
16 | #resize load "/root/pix/das_fette_schwein.jpg", w, h |
12 | |
17 | |
13 | use Safe; |
18 | use Safe; |
14 | |
19 | |
15 | our ($bgdsl_self, $old, $new); |
20 | our ($bgdsl_self, $old, $new); |
16 | our ($l, $t, $w, $h); |
21 | our ($l, $t, $w, $h); |
17 | |
22 | |
|
|
23 | # enforce at least this interval between updates |
18 | our $MIN_INTERVAL = 1/100; |
24 | our $MIN_INTERVAL = 1/100; |
19 | |
25 | |
20 | { |
26 | { |
21 | package urxvt::bgdsl; # background language |
27 | package urxvt::bgdsl; # background language |
22 | |
28 | |
23 | *repeat_black = \&urxvt::RepeatNone; #TODO wtf |
29 | *repeat_empty = \&urxvt::RepeatNone; |
24 | *repeat_wrap = \&urxvt::RepeatNormal; |
30 | *repeat_tile = \&urxvt::RepeatNormal; |
25 | *repeat_pad = \&urxvt::RepeatPad; |
31 | *repeat_pad = \&urxvt::RepeatPad; |
26 | *repeat_mirror = \&urxvt::RepeatReflect; |
32 | *repeat_mirror = \&urxvt::RepeatReflect; |
|
|
33 | |
|
|
34 | =head2 PROVIDERS/GENERATORS |
|
|
35 | |
|
|
36 | =over 4 |
|
|
37 | |
|
|
38 | =item load $path |
|
|
39 | |
|
|
40 | =cut |
27 | |
41 | |
28 | sub load($) { |
42 | sub load($) { |
29 | my ($path) = @_; |
43 | my ($path) = @_; |
30 | |
44 | |
31 | $new->{load}{$path} = $old->{load}{$path} || $bgdsl_self->new_img_from_file ($path); |
45 | $new->{load}{$path} = $old->{load}{$path} || $bgdsl_self->new_img_from_file ($path); |
… | |
… | |
33 | |
47 | |
34 | sub root() { |
48 | sub root() { |
35 | $new->{rootpmap_sensitive} = 1; |
49 | $new->{rootpmap_sensitive} = 1; |
36 | die "root op not supported, exg, we need you"; |
50 | die "root op not supported, exg, we need you"; |
37 | } |
51 | } |
|
|
52 | |
|
|
53 | sub solid($;$$) { |
|
|
54 | my $img = $bgdsl_self->new_img (urxvt::PictStandardARGB32, $_[1] || 1, $_[2] || 1); |
|
|
55 | $img->fill ($_[0]); |
|
|
56 | $img |
|
|
57 | } |
|
|
58 | |
|
|
59 | =back |
|
|
60 | |
|
|
61 | =head2 OPERATORS |
|
|
62 | |
|
|
63 | =over 4 |
|
|
64 | |
|
|
65 | =cut |
38 | |
66 | |
39 | # sub clone($) { |
67 | # sub clone($) { |
40 | # $_[0]->clone |
68 | # $_[0]->clone |
41 | # } |
69 | # } |
42 | |
70 | |
… | |
… | |
115 | |
143 | |
116 | sub counter($) { |
144 | sub counter($) { |
117 | $new->{again} = $_[0]; |
145 | $new->{again} = $_[0]; |
118 | $bgdsl_self->{counter} + 0 |
146 | $bgdsl_self->{counter} + 0 |
119 | } |
147 | } |
|
|
148 | |
|
|
149 | =back |
|
|
150 | |
|
|
151 | =cut |
|
|
152 | |
120 | } |
153 | } |
121 | |
154 | |
122 | sub parse_expr { |
155 | sub parse_expr { |
123 | my $expr = eval "sub {\npackage urxvt::bgdsl;\n#line 0 'background expression'\n$_[0]\n}"; |
156 | my $expr = eval "sub {\npackage urxvt::bgdsl;\n#line 0 'background expression'\n$_[0]\n}"; |
124 | die if $@; |
157 | die if $@; |
… | |
… | |
141 | |
174 | |
142 | if ($self->{next_refresh} > urxvt::NOW) { |
175 | if ($self->{next_refresh} > urxvt::NOW) { |
143 | $self->{next_refresh_timer} = urxvt::timer->new->after ($self->{next_refresh} - urxvt::NOW)->cb (sub { |
176 | $self->{next_refresh_timer} = urxvt::timer->new->after ($self->{next_refresh} - urxvt::NOW)->cb (sub { |
144 | $self->recalculate; |
177 | $self->recalculate; |
145 | }); |
178 | }); |
|
|
179 | return; |
146 | } |
180 | } |
147 | |
181 | |
148 | $self->{next_refresh} = urxvt::NOW + $MIN_INTERVAL; |
182 | $self->{next_refresh} = urxvt::NOW + $MIN_INTERVAL; |
149 | |
183 | |
150 | # set environment to evaluate user expression |
184 | # set environment to evaluate user expression |
… | |
… | |
159 | |
193 | |
160 | # evaluate user expression |
194 | # evaluate user expression |
161 | |
195 | |
162 | my $img = eval { $self->{expr}->() }; |
196 | my $img = eval { $self->{expr}->() }; |
163 | warn $@ if $@;#d# |
197 | warn $@ if $@;#d# |
|
|
198 | die if !UNIVERSAL::isa $img, "urxvt::img"; |
164 | |
199 | |
165 | # if the expression is sensitive to external events, prepare reevaluation then |
200 | # if the expression is sensitive to external events, prepare reevaluation then |
166 | |
201 | |
167 | my $repeat; |
202 | my $repeat; |
168 | |
203 | |