ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/background
(Generate patch)

Comparing rxvt-unicode/src/perl/background (file contents):
Revision 1.97 by root, Tue Sep 17 18:17:14 2019 UTC vs.
Revision 1.100 by root, Sat Jul 24 09:48:43 2021 UTC

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
29Just load a random jpeg image and tile the background with it without 29Load a random jpeg image and tile the background with it without scaling
30scaling or anything else: 30or anything else:
31 31
32 load "/path/to/img.jpg" 32 load "/path/to/img.jpg"
33 33
34The same, but use mirroring/reflection instead of tiling: 34The same, but use mirroring/reflection instead of tiling:
35 35
259 259
260=head1 REFERENCE 260=head1 REFERENCE
261 261
262=head2 COMMAND LINE SWITCHES 262=head2 COMMAND LINE SWITCHES
263 263
264=over 4 264=over
265 265
266=item --background-expr perl-expression 266=item --background-expr perl-expression
267 267
268Specifies the Perl expression to evaluate. 268Specifies the Perl expression to evaluate.
269 269
310 310
311These functions provide an image, by loading it from disk, grabbing it 311These functions provide an image, by loading it from disk, grabbing it
312from the root screen or by simply generating it. They are used as starting 312from the root screen or by simply generating it. They are used as starting
313points to get an image you can play with. 313points to get an image you can play with.
314 314
315=over 4 315=over
316 316
317=item load $path 317=item load $path
318 318
319Loads the image at the given C<$path>. The image is set to plane tiling 319Loads the image at the given C<$path>. The image is set to plane tiling
320mode. 320mode.
439=head2 TILING MODES 439=head2 TILING MODES
440 440
441The following operators modify the tiling mode of an image, that is, the 441The following operators modify the tiling mode of an image, that is, the
442way that pixels outside the image area are painted when the image is used. 442way that pixels outside the image area are painted when the image is used.
443 443
444=over 4 444=over
445 445
446=item tile $img 446=item tile $img
447 447
448Tiles the whole plane with the image and returns this new image - or in 448Tiles the whole plane with the image and returns this new image - or in
449other words, it returns a copy of the image in plane tiling mode. 449other words, it returns a copy of the image in plane tiling mode.
524dimensions. They are not (Perl-) variables, they just return stuff that 524dimensions. They are not (Perl-) variables, they just return stuff that
525varies. Most of them make your expression sensitive to some events, for 525varies. Most of them make your expression sensitive to some events, for
526example using C<TW> (terminal width) means your expression is evaluated 526example using C<TW> (terminal width) means your expression is evaluated
527again when the terminal is resized. 527again when the terminal is resized.
528 528
529=over 4 529=over
530 530
531=item TX 531=item TX
532 532
533=item TY 533=item TY
534 534
627 627
628=head2 SHAPE CHANGING OPERATORS 628=head2 SHAPE CHANGING OPERATORS
629 629
630The following operators modify the shape, size or position of the image. 630The following operators modify the shape, size or position of the image.
631 631
632=over 4 632=over
633 633
634=item clip $img 634=item clip $img
635 635
636=item clip $width, $height, $img 636=item clip $width, $height, $img
637 637
824 824
825=head2 COLOUR MODIFICATIONS 825=head2 COLOUR MODIFICATIONS
826 826
827The following operators change the pixels of the image. 827The following operators change the pixels of the image.
828 828
829=over 4 829=over
830 830
831=item tint $color, $img 831=item tint $color, $img
832 832
833Tints the image in the given colour. 833Tints the image in the given colour.
834 834
999=head2 OTHER STUFF 999=head2 OTHER STUFF
1000 1000
1001Anything that didn't fit any of the other categories, even after applying 1001Anything that didn't fit any of the other categories, even after applying
1002force and closing our eyes. 1002force and closing our eyes.
1003 1003
1004=over 4 1004=over
1005 1005
1006=item keep { ... } 1006=item keep { ... }
1007 1007
1008This operator takes a code block as argument, that is, one or more 1008This operator takes a code block as argument, that is, one or more
1009statements enclosed by braces. 1009statements enclosed by braces.
1042OSC sequences for setting a background image. These settings are 1042OSC sequences for setting a background image. These settings are
1043B<deprecated> and will be removed in future versions. 1043B<deprecated> and will be removed in future versions.
1044 1044
1045=head2 OPTIONS AND RESOURCES 1045=head2 OPTIONS AND RESOURCES
1046 1046
1047=over 4 1047=over
1048 1048
1049=item B<-pixmap> I<file[;oplist]> 1049=item B<-pixmap> I<file[;oplist]>
1050 1050
1051=item B<backgroundPixmap:> I<file[;oplist]> 1051=item B<backgroundPixmap:> I<file[;oplist]>
1052 1052
1054optionally specify a colon separated list of operations to modify it. 1054optionally specify a colon separated list of operations to modify it.
1055Note that you may need to quote the C<;> character when using the 1055Note that you may need to quote the C<;> character when using the
1056command line option, as C<;> is usually a metacharacter in shells. 1056command line option, as C<;> is usually a metacharacter in shells.
1057Supported operations are: 1057Supported operations are:
1058 1058
1059=over 4 1059=over
1060 1060
1061=item B<WxH+X+Y> 1061=item B<WxH+X+Y>
1062 1062
1063sets scale and position. B<"W" / "H"> specify the horizontal/vertical 1063sets scale and position. B<"W" / "H"> specify the horizontal/vertical
1064scale (percent), and B<"X" / "Y"> locate the image centre (percent). A 1064scale (percent), and B<"X" / "Y"> locate the image centre (percent). A
1081 1081
1082The default scale and position setting is C<100x100+50+50>. 1082The default scale and position setting is C<100x100+50+50>.
1083Alternatively, a predefined set of templates can be used to achieve 1083Alternatively, a predefined set of templates can be used to achieve
1084the most common setups: 1084the most common setups:
1085 1085
1086=over 4 1086=over
1087 1087
1088=item B<style=tiled> 1088=item B<style=tiled>
1089 1089
1090the image is tiled with no scaling. Equivalent to 0x0+0+0:op=tile 1090the image is tiled with no scaling. Equivalent to 0x0+0+0:op=tile
1091 1091
1149 1149
1150=back 1150=back
1151 1151
1152=head2 OSC sequences 1152=head2 OSC sequences
1153 1153
1154This extension will react to the following OSC sequences. Note that
1155this extension will not be autoloaded when these are used currently,
1156so to make urxvt recognize them, you have to enable the C<background>
1157extension. One way to achieve that is to use the C<--background-expr ''>
1158command line argument or by specifying an empty C<URxvt.background.expr:>>
1159resource.
1160
1154=over 4 1161=over
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
1158=item B<< C<ESC ] 20 ; Pt ST> >> Change/Query background image 1165=item B<< C<ESC ] 20 ; Pt ST> >> Change/Query background image
1159parameters: the value of B<< C<Pt> >> can be one of the following 1166parameters: the value of B<< C<Pt> >> can be one of the following
1160commands: 1167commands:
1161 1168
1162=over 4 1169=over
1163 1170
1164=item B<< C<?> >> 1171=item B<< C<?> >>
1165 1172
1166display scale and position in the title 1173display scale and position in the title
1167 1174
1214=cut 1221=cut
1215 1222
1216} 1223}
1217 1224
1218sub parse_expr { 1225sub 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
1230sub set_expr { 1247sub 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
1351sub old_bg_opts { 1374sub 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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines