… | |
… | |
24 | --background-border |
24 | --background-border |
25 | --background-interval seconds |
25 | --background-interval seconds |
26 | |
26 | |
27 | =head1 QUICK AND DIRTY CHEAT SHEET |
27 | =head1 QUICK AND DIRTY CHEAT SHEET |
28 | |
28 | |
29 | Just load a random jpeg image and tile the background with it without |
29 | Load a random jpeg image and tile the background with it without scaling |
30 | scaling or anything else: |
30 | or anything else: |
31 | |
31 | |
32 | load "/path/to/img.jpg" |
32 | load "/path/to/img.jpg" |
33 | |
33 | |
34 | The same, but use mirroring/reflection instead of tiling: |
34 | The same, but use mirroring/reflection instead of tiling: |
35 | |
35 | |
… | |
… | |
1148 | vertical radius of 0 disables blurring. |
1148 | vertical radius of 0 disables blurring. |
1149 | |
1149 | |
1150 | =back |
1150 | =back |
1151 | |
1151 | |
1152 | =head2 OSC sequences |
1152 | =head2 OSC sequences |
|
|
1153 | |
|
|
1154 | This extension will react to the following OSC sequences. Note that |
|
|
1155 | this extension will not be autoloaded when these are used currenmtly, |
|
|
1156 | so to make urxvt recognize them, you have to enable the C<background> |
|
|
1157 | extension. One way to achieve that is to use the C<--background-expr ''> |
|
|
1158 | command line argument or by specifying an empty C<URxvt.background.expr:>> |
|
|
1159 | resource. |
1153 | |
1160 | |
1154 | =over 4 |
1161 | =over 4 |
1155 | |
1162 | |
1156 | =item B<< C<ESC ] 705 ; Pt ST> >> Change transparent background tint colour to B<< C<Pt> >>. |
1163 | =item B<< C<ESC ] 705 ; Pt ST> >> Change transparent background tint colour to B<< C<Pt> >>. |
1157 | |
1164 | |
… | |
… | |
1214 | =cut |
1221 | =cut |
1215 | |
1222 | |
1216 | } |
1223 | } |
1217 | |
1224 | |
1218 | sub parse_expr { |
1225 | sub parse_expr { |
|
|
1226 | my ($expr) = @_; |
|
|
1227 | |
|
|
1228 | # an empty expression is valid and represents the default background |
|
|
1229 | if ($expr !~ /\S/) { |
|
|
1230 | $expr = sub { |
|
|
1231 | undef |
|
|
1232 | }; |
|
|
1233 | } else { |
1219 | my $expr = eval |
1234 | $expr = eval |
1220 | "sub {\n" |
1235 | "sub {\n" |
1221 | . "package urxvt::bgdsl;\n" |
1236 | . "package urxvt::bgdsl;\n" |
1222 | . "#line 0 'background expression'\n" |
1237 | . "#line 0 'background expression'\n" |
1223 | . "$_[0]\n" |
1238 | . "$expr\n" |
1224 | . "}"; |
1239 | . "}"; |
1225 | die if $@; |
1240 | die if $@; |
|
|
1241 | } |
|
|
1242 | |
1226 | $expr |
1243 | $expr |
1227 | } |
1244 | } |
1228 | |
1245 | |
1229 | # compiles a parsed expression |
1246 | # compiles a parsed expression |
1230 | sub set_expr { |
1247 | sub set_expr { |
… | |
… | |
1321 | # evaluate user expression |
1338 | # evaluate user expression |
1322 | |
1339 | |
1323 | my @img = eval { $self->{expr}->() }; |
1340 | my @img = eval { $self->{expr}->() }; |
1324 | die $@ if $@; |
1341 | die $@ if $@; |
1325 | die "background-expr did not return anything.\n" unless @img; |
1342 | die "background-expr did not return anything.\n" unless @img; |
|
|
1343 | |
|
|
1344 | if ($img[0]) { |
1326 | die "background-expr: expected image(s), got something else.\n" |
1345 | die "background-expr: expected image(s), got something else.\n" |
1327 | if grep { !UNIVERSAL::isa $_, "urxvt::img" } @img; |
1346 | if grep { !UNIVERSAL::isa $_, "urxvt::img" } @img; |
1328 | |
1347 | |
1329 | my $img = urxvt::bgdsl::merge @img; |
1348 | my $img = urxvt::bgdsl::merge @img; |
1330 | |
1349 | |
1331 | $frame->[FR_AGAIN]{size} = 1 |
1350 | $frame->[FR_AGAIN]{size} = 1 |
1332 | if $img->repeat_mode != urxvt::RepeatNormal; |
1351 | if $img->repeat_mode != urxvt::RepeatNormal; |
1333 | |
1352 | |
1334 | # if the expression is sensitive to external events, prepare reevaluation then |
1353 | # if the expression is sensitive to external events, prepare reevaluation then |
1335 | $self->compile_frame ($frame, sub { $arg_self->recalculate }); |
1354 | $self->compile_frame ($frame, sub { $arg_self->recalculate }); |
1336 | |
1355 | |
1337 | # clear stuff we no longer need |
1356 | # clear stuff we no longer need |
1338 | |
1357 | |
1339 | # unless (%{ $frame->[FR_STATE] }) { |
1358 | # unless (%{ $frame->[FR_STATE] }) { |
1340 | # delete $self->{state}; |
1359 | # delete $self->{state}; |
1341 | # delete $self->{expr}; |
1360 | # delete $self->{expr}; |
1342 | # } |
1361 | # } |
1343 | |
1362 | |
1344 | # set background pixmap |
1363 | # set background pixmap |
1345 | |
1364 | |
1346 | $self->set_background ($img, $self->{border}); |
1365 | $self->set_background ($img, $self->{border}); |
|
|
1366 | } else { |
|
|
1367 | $self->clr_background; |
|
|
1368 | } |
|
|
1369 | |
1347 | $self->scr_recolor (0); |
1370 | $self->scr_recolor (0); |
1348 | $self->want_refresh; |
1371 | $self->want_refresh; |
1349 | } |
1372 | } |
1350 | |
1373 | |
1351 | sub old_bg_opts { |
1374 | sub old_bg_opts { |
… | |
… | |
1565 | |
1588 | |
1566 | $self->old_bg_opts ($self->find_resource ("backgroundPixmap", "pixmap")); |
1589 | $self->old_bg_opts ($self->find_resource ("backgroundPixmap", "pixmap")); |
1567 | $expr = $self->old_bg_expr; |
1590 | $expr = $self->old_bg_expr; |
1568 | } |
1591 | } |
1569 | |
1592 | |
1570 | $expr or return; |
|
|
1571 | |
|
|
1572 | $self->set_expr (parse_expr $expr); |
1593 | $self->set_expr (parse_expr $expr); |
1573 | $self->{border} = $self->x_resource_boolean ("%.border"); |
1594 | $self->{border} = $self->x_resource_boolean ("%.border"); |
1574 | |
1595 | |
1575 | $MIN_INTERVAL = $self->x_resource ("%.interval"); |
1596 | $MIN_INTERVAL = $self->x_resource ("%.interval"); |
1576 | |
1597 | |