… | |
… | |
71 | return scale load "$HOME/weekday.png"; |
71 | return scale load "$HOME/weekday.png"; |
72 | } else { |
72 | } else { |
73 | return scale load "$HOME/sunday.png"; |
73 | return scale load "$HOME/sunday.png"; |
74 | } |
74 | } |
75 | |
75 | |
76 | This expression gets evaluated once per hour. It will set F<sunday.png> as |
76 | This expression is evaluated once per hour. It will set F<sunday.png> as |
77 | background on Sundays, and F<weekday.png> on all other days. |
77 | background on Sundays, and F<weekday.png> on all other days. |
78 | |
78 | |
79 | Fortunately, we expect that most expressions will be much simpler, with |
79 | Fortunately, we expect that most expressions will be much simpler, with |
80 | little Perl knowledge needed. |
80 | little Perl knowledge needed. |
81 | |
81 | |
… | |
… | |
229 | =item load $path |
229 | =item load $path |
230 | |
230 | |
231 | Loads the image at the given C<$path>. The image is set to plane tiling |
231 | Loads the image at the given C<$path>. The image is set to plane tiling |
232 | mode. |
232 | mode. |
233 | |
233 | |
234 | Loaded images will be cached for one cycle. |
234 | Loaded images will be cached for one cycle, and shared between temrinals |
|
|
235 | running in the same process (e.g. in C<urxvtd>). |
235 | |
236 | |
|
|
237 | =item load_uc $path |
|
|
238 | |
|
|
239 | Load uncached - same as load, but does not cache the image. This function |
|
|
240 | is most useufl if you want to optimise a background expression in some |
|
|
241 | way. |
|
|
242 | |
236 | =cut |
243 | =cut |
|
|
244 | |
|
|
245 | sub load_uc($) { |
|
|
246 | my ($path) = @_; |
|
|
247 | |
|
|
248 | $_IMG_CACHE{$path} || do { |
|
|
249 | my $img = $self->new_img_from_file ($path); |
|
|
250 | Scalar::Util::weaken ($_IMG_CACHE{$path} = $img); |
|
|
251 | $img |
|
|
252 | } |
|
|
253 | } |
237 | |
254 | |
238 | sub load($) { |
255 | sub load($) { |
239 | my ($path) = @_; |
256 | my ($path) = @_; |
240 | |
257 | |
241 | $new->{load}{$path} = $old->{load}{$path} || $self->new_img_from_file ($path); |
258 | $new->{load}{$path} = $old->{load}{$path} || load_uc $path; |
242 | } |
259 | } |
243 | |
260 | |
244 | =item root |
261 | =item root |
245 | |
262 | |
246 | Returns the root window pixmap, that is, hopefully, the background image |
263 | Returns the root window pixmap, that is, hopefully, the background image |