… | |
… | |
11 | #:META:RESOURCE:tintColor:color:tint background with color |
11 | #:META:RESOURCE:tintColor:color:tint background with color |
12 | #:META:RESOURCE:sh:number:shade background by number % |
12 | #:META:RESOURCE:sh:number:shade background by number % |
13 | #:META:RESOURCE:shading:number:shade background by number % |
13 | #:META:RESOURCE:shading:number:shade background by number % |
14 | #:META:RESOURCE:blr:HxV:gaussian-blur background with radii |
14 | #:META:RESOURCE:blr:HxV:gaussian-blur background with radii |
15 | #:META:RESOURCE:blurRadius:HxV:gaussian-blur background with radii |
15 | #:META:RESOURCE:blurRadius:HxV:gaussian-blur background with radii |
|
|
16 | #:META:OSC:20:change/query background image |
|
|
17 | #:META:OSC:705:change transparent background tint colour |
16 | |
18 | |
17 | =head1 NAME |
19 | =head1 NAME |
18 | |
20 | |
19 | background - manage terminal background |
21 | background - manage terminal background |
20 | |
22 | |
… | |
… | |
24 | --background-border |
26 | --background-border |
25 | --background-interval seconds |
27 | --background-interval seconds |
26 | |
28 | |
27 | =head1 QUICK AND DIRTY CHEAT SHEET |
29 | =head1 QUICK AND DIRTY CHEAT SHEET |
28 | |
30 | |
29 | Just load a random jpeg image and tile the background with it without |
31 | Load a random jpeg image and tile the background with it without scaling |
30 | scaling or anything else: |
32 | or anything else: |
31 | |
33 | |
32 | load "/path/to/img.jpg" |
34 | load "/path/to/img.jpg" |
33 | |
35 | |
34 | The same, but use mirroring/reflection instead of tiling: |
36 | The same, but use mirroring/reflection instead of tiling: |
35 | |
37 | |
… | |
… | |
54 | is behind the text, replacing the normal background colour. |
56 | is behind the text, replacing the normal background colour. |
55 | |
57 | |
56 | It does so by evaluating a Perl expression that I<calculates> the image on |
58 | It does so by evaluating a Perl expression that I<calculates> the image on |
57 | the fly, for example, by grabbing the root background or loading a file. |
59 | the fly, for example, by grabbing the root background or loading a file. |
58 | |
60 | |
59 | While the full power of Perl is available, the operators have been design |
61 | While the full power of Perl is available, the operators have been |
60 | to be as simple as possible. |
62 | designed to be as simple as possible. |
61 | |
63 | |
62 | For example, to load an image and scale it to the window size, you would |
64 | For example, to load an image and scale it to the window size, you would |
63 | use: |
65 | use: |
64 | |
66 | |
65 | urxvt --background-expr 'scale keep { load "/path/to/mybg.png" }' |
67 | urxvt --background-expr 'scale keep { load "/path/to/mybg.png" }' |
… | |
… | |
259 | |
261 | |
260 | =head1 REFERENCE |
262 | =head1 REFERENCE |
261 | |
263 | |
262 | =head2 COMMAND LINE SWITCHES |
264 | =head2 COMMAND LINE SWITCHES |
263 | |
265 | |
264 | =over 4 |
266 | =over |
265 | |
267 | |
266 | =item --background-expr perl-expression |
268 | =item --background-expr perl-expression |
267 | |
269 | |
268 | Specifies the Perl expression to evaluate. |
270 | Specifies the Perl expression to evaluate. |
269 | |
271 | |
… | |
… | |
310 | |
312 | |
311 | These functions provide an image, by loading it from disk, grabbing it |
313 | These functions provide an image, by loading it from disk, grabbing it |
312 | from the root screen or by simply generating it. They are used as starting |
314 | from the root screen or by simply generating it. They are used as starting |
313 | points to get an image you can play with. |
315 | points to get an image you can play with. |
314 | |
316 | |
315 | =over 4 |
317 | =over |
316 | |
318 | |
317 | =item load $path |
319 | =item load $path |
318 | |
320 | |
319 | Loads the image at the given C<$path>. The image is set to plane tiling |
321 | Loads the image at the given C<$path>. The image is set to plane tiling |
320 | mode. |
322 | mode. |
… | |
… | |
439 | =head2 TILING MODES |
441 | =head2 TILING MODES |
440 | |
442 | |
441 | The following operators modify the tiling mode of an image, that is, the |
443 | The following operators modify the tiling mode of an image, that is, the |
442 | way that pixels outside the image area are painted when the image is used. |
444 | way that pixels outside the image area are painted when the image is used. |
443 | |
445 | |
444 | =over 4 |
446 | =over |
445 | |
447 | |
446 | =item tile $img |
448 | =item tile $img |
447 | |
449 | |
448 | Tiles the whole plane with the image and returns this new image - or in |
450 | Tiles the whole plane with the image and returns this new image - or in |
449 | other words, it returns a copy of the image in plane tiling mode. |
451 | other words, it returns a copy of the image in plane tiling mode. |
… | |
… | |
524 | dimensions. They are not (Perl-) variables, they just return stuff that |
526 | dimensions. They are not (Perl-) variables, they just return stuff that |
525 | varies. Most of them make your expression sensitive to some events, for |
527 | varies. Most of them make your expression sensitive to some events, for |
526 | example using C<TW> (terminal width) means your expression is evaluated |
528 | example using C<TW> (terminal width) means your expression is evaluated |
527 | again when the terminal is resized. |
529 | again when the terminal is resized. |
528 | |
530 | |
529 | =over 4 |
531 | =over |
530 | |
532 | |
531 | =item TX |
533 | =item TX |
532 | |
534 | |
533 | =item TY |
535 | =item TY |
534 | |
536 | |
… | |
… | |
627 | |
629 | |
628 | =head2 SHAPE CHANGING OPERATORS |
630 | =head2 SHAPE CHANGING OPERATORS |
629 | |
631 | |
630 | The following operators modify the shape, size or position of the image. |
632 | The following operators modify the shape, size or position of the image. |
631 | |
633 | |
632 | =over 4 |
634 | =over |
633 | |
635 | |
634 | =item clip $img |
636 | =item clip $img |
635 | |
637 | |
636 | =item clip $width, $height, $img |
638 | =item clip $width, $height, $img |
637 | |
639 | |
… | |
… | |
824 | |
826 | |
825 | =head2 COLOUR MODIFICATIONS |
827 | =head2 COLOUR MODIFICATIONS |
826 | |
828 | |
827 | The following operators change the pixels of the image. |
829 | The following operators change the pixels of the image. |
828 | |
830 | |
829 | =over 4 |
831 | =over |
830 | |
832 | |
831 | =item tint $color, $img |
833 | =item tint $color, $img |
832 | |
834 | |
833 | Tints the image in the given colour. |
835 | Tints the image in the given colour. |
834 | |
836 | |
… | |
… | |
984 | |
986 | |
985 | return $img |
987 | return $img |
986 | if FOCUS; |
988 | if FOCUS; |
987 | |
989 | |
988 | my $fade = @_ >= 1 ? $_[0] : defined $self->resource ("fade") ? $self->resource ("fade") * 0.01 : 0; |
990 | my $fade = @_ >= 1 ? $_[0] : defined $self->resource ("fade") ? $self->resource ("fade") * 0.01 : 0; |
989 | my $color = @_ >= 2 ? $_[1] : $self->resource ("color+" . urxvt::Color_fade); |
991 | my $color = @_ >= 2 ? $_[1] : $self->resource ("color+" . &urxvt::Color_fade ()); # Color_fade not always available |
990 | |
992 | |
991 | $img = $img->tint ($color) if $color ne "rgb:00/00/00"; |
993 | $img = $img->tint ($color) if $color ne "rgb:00/00/00"; |
992 | $img = $img->muladd (1 - $fade, 0) if $fade; |
994 | $img = $img->muladd (1 - $fade, 0) if $fade; |
993 | |
995 | |
994 | $img |
996 | $img |
… | |
… | |
999 | =head2 OTHER STUFF |
1001 | =head2 OTHER STUFF |
1000 | |
1002 | |
1001 | Anything that didn't fit any of the other categories, even after applying |
1003 | Anything that didn't fit any of the other categories, even after applying |
1002 | force and closing our eyes. |
1004 | force and closing our eyes. |
1003 | |
1005 | |
1004 | =over 4 |
1006 | =over |
1005 | |
1007 | |
1006 | =item keep { ... } |
1008 | =item keep { ... } |
1007 | |
1009 | |
1008 | This operator takes a code block as argument, that is, one or more |
1010 | This operator takes a code block as argument, that is, one or more |
1009 | statements enclosed by braces. |
1011 | statements enclosed by braces. |
… | |
… | |
1042 | OSC sequences for setting a background image. These settings are |
1044 | OSC sequences for setting a background image. These settings are |
1043 | B<deprecated> and will be removed in future versions. |
1045 | B<deprecated> and will be removed in future versions. |
1044 | |
1046 | |
1045 | =head2 OPTIONS AND RESOURCES |
1047 | =head2 OPTIONS AND RESOURCES |
1046 | |
1048 | |
1047 | =over 4 |
1049 | =over |
1048 | |
1050 | |
1049 | =item B<-pixmap> I<file[;oplist]> |
1051 | =item B<-pixmap> I<file[;oplist]> |
1050 | |
1052 | |
1051 | =item B<backgroundPixmap:> I<file[;oplist]> |
1053 | =item B<backgroundPixmap:> I<file[;oplist]> |
1052 | |
1054 | |
… | |
… | |
1054 | optionally specify a colon separated list of operations to modify it. |
1056 | optionally specify a colon separated list of operations to modify it. |
1055 | Note that you may need to quote the C<;> character when using the |
1057 | Note that you may need to quote the C<;> character when using the |
1056 | command line option, as C<;> is usually a metacharacter in shells. |
1058 | command line option, as C<;> is usually a metacharacter in shells. |
1057 | Supported operations are: |
1059 | Supported operations are: |
1058 | |
1060 | |
1059 | =over 4 |
1061 | =over |
1060 | |
1062 | |
1061 | =item B<WxH+X+Y> |
1063 | =item B<WxH+X+Y> |
1062 | |
1064 | |
1063 | sets scale and position. B<"W" / "H"> specify the horizontal/vertical |
1065 | sets scale and position. B<"W" / "H"> specify the horizontal/vertical |
1064 | scale (percent), and B<"X" / "Y"> locate the image centre (percent). A |
1066 | scale (percent), and B<"X" / "Y"> locate the image centre (percent). A |
… | |
… | |
1081 | |
1083 | |
1082 | The default scale and position setting is C<100x100+50+50>. |
1084 | The default scale and position setting is C<100x100+50+50>. |
1083 | Alternatively, a predefined set of templates can be used to achieve |
1085 | Alternatively, a predefined set of templates can be used to achieve |
1084 | the most common setups: |
1086 | the most common setups: |
1085 | |
1087 | |
1086 | =over 4 |
1088 | =over |
1087 | |
1089 | |
1088 | =item B<style=tiled> |
1090 | =item B<style=tiled> |
1089 | |
1091 | |
1090 | the image is tiled with no scaling. Equivalent to 0x0+0+0:op=tile |
1092 | the image is tiled with no scaling. Equivalent to 0x0+0+0:op=tile |
1091 | |
1093 | |
… | |
… | |
1149 | |
1151 | |
1150 | =back |
1152 | =back |
1151 | |
1153 | |
1152 | =head2 OSC sequences |
1154 | =head2 OSC sequences |
1153 | |
1155 | |
|
|
1156 | This extension will react to the following OSC sequences. Note that |
|
|
1157 | this extension will not be autoloaded when these are used currently, |
|
|
1158 | so to make urxvt recognize them, you have to enable the C<background> |
|
|
1159 | extension. One way to achieve that is to use the C<--background-expr ''> |
|
|
1160 | command line argument or by specifying an empty C<URxvt.background.expr:>> |
|
|
1161 | resource. |
|
|
1162 | |
1154 | =over 4 |
1163 | =over |
1155 | |
1164 | |
1156 | =item B<< C<ESC ] 705 ; Pt ST> >> Change transparent background tint colour to B<< C<Pt> >>. |
1165 | =item B<< C<ESC ] 705 ; Pt ST> >> Change transparent background tint colour to B<< C<Pt> >>. |
1157 | |
1166 | |
1158 | =item B<< C<ESC ] 20 ; Pt ST> >> Change/Query background image |
1167 | =item B<< C<ESC ] 20 ; Pt ST> >> Change/Query background image |
1159 | parameters: the value of B<< C<Pt> >> can be one of the following |
1168 | parameters: the value of B<< C<Pt> >> can be one of the following |
1160 | commands: |
1169 | commands: |
1161 | |
1170 | |
1162 | =over 4 |
1171 | =over |
1163 | |
1172 | |
1164 | =item B<< C<?> >> |
1173 | =item B<< C<?> >> |
1165 | |
1174 | |
1166 | display scale and position in the title |
1175 | display scale and position in the title |
1167 | |
1176 | |
… | |
… | |
1214 | =cut |
1223 | =cut |
1215 | |
1224 | |
1216 | } |
1225 | } |
1217 | |
1226 | |
1218 | sub parse_expr { |
1227 | sub parse_expr { |
|
|
1228 | my ($expr) = @_; |
|
|
1229 | |
|
|
1230 | # an empty expression is valid and represents the default background |
|
|
1231 | if ($expr !~ /\S/) { |
|
|
1232 | $expr = sub { |
|
|
1233 | undef |
|
|
1234 | }; |
|
|
1235 | } else { |
1219 | my $expr = eval |
1236 | $expr = eval |
1220 | "sub {\n" |
1237 | "sub {\n" |
1221 | . "package urxvt::bgdsl;\n" |
1238 | . "package urxvt::bgdsl;\n" |
1222 | . "#line 0 'background expression'\n" |
1239 | . "#line 0 'background expression'\n" |
1223 | . "$_[0]\n" |
1240 | . "$expr\n" |
1224 | . "}"; |
1241 | . "}"; |
1225 | die if $@; |
1242 | die if $@; |
|
|
1243 | } |
|
|
1244 | |
1226 | $expr |
1245 | $expr |
1227 | } |
1246 | } |
1228 | |
1247 | |
1229 | # compiles a parsed expression |
1248 | # compiles a parsed expression |
1230 | sub set_expr { |
1249 | sub set_expr { |
… | |
… | |
1302 | return; |
1321 | return; |
1303 | } |
1322 | } |
1304 | |
1323 | |
1305 | $arg_self->{next_refresh} = urxvt::NOW + $MIN_INTERVAL; |
1324 | $arg_self->{next_refresh} = urxvt::NOW + $MIN_INTERVAL; |
1306 | |
1325 | |
|
|
1326 | unless ($arg_self->has_render) { |
|
|
1327 | warn "background extension needs RENDER extension 0.11 or higher, ignoring background-expr.\n"; |
|
|
1328 | return; |
|
|
1329 | } |
|
|
1330 | |
1307 | # set environment to evaluate user expression |
1331 | # set environment to evaluate user expression |
1308 | |
1332 | |
1309 | local $self = $arg_self; |
1333 | local $self = $arg_self; |
1310 | local $HOME = $ENV{HOME}; |
1334 | local $HOME = $ENV{HOME}; |
1311 | local $frame = $self->{root}; |
1335 | local $frame = $self->{root}; |
… | |
… | |
1316 | # evaluate user expression |
1340 | # evaluate user expression |
1317 | |
1341 | |
1318 | my @img = eval { $self->{expr}->() }; |
1342 | my @img = eval { $self->{expr}->() }; |
1319 | die $@ if $@; |
1343 | die $@ if $@; |
1320 | die "background-expr did not return anything.\n" unless @img; |
1344 | die "background-expr did not return anything.\n" unless @img; |
|
|
1345 | |
|
|
1346 | if ($img[0]) { |
1321 | die "background-expr: expected image(s), got something else.\n" |
1347 | die "background-expr: expected image(s), got something else.\n" |
1322 | if grep { !UNIVERSAL::isa $_, "urxvt::img" } @img; |
1348 | if grep { !UNIVERSAL::isa $_, "urxvt::img" } @img; |
1323 | |
1349 | |
1324 | my $img = urxvt::bgdsl::merge @img; |
1350 | my $img = urxvt::bgdsl::merge @img; |
1325 | |
1351 | |
1326 | $frame->[FR_AGAIN]{size} = 1 |
1352 | $frame->[urxvt::bgdsl::FR_AGAIN]{size} = 1 |
1327 | if $img->repeat_mode != urxvt::RepeatNormal; |
1353 | if $img->repeat_mode != urxvt::RepeatNormal; |
1328 | |
1354 | |
1329 | # if the expression is sensitive to external events, prepare reevaluation then |
1355 | # if the expression is sensitive to external events, prepare reevaluation then |
1330 | $self->compile_frame ($frame, sub { $arg_self->recalculate }); |
1356 | $self->compile_frame ($frame, sub { $arg_self->recalculate }); |
1331 | |
1357 | |
1332 | # clear stuff we no longer need |
1358 | # clear stuff we no longer need |
1333 | |
1359 | |
1334 | # unless (%{ $frame->[FR_STATE] }) { |
1360 | # unless (%{ $frame->[FR_STATE] }) { |
1335 | # delete $self->{state}; |
1361 | # delete $self->{state}; |
1336 | # delete $self->{expr}; |
1362 | # delete $self->{expr}; |
1337 | # } |
1363 | # } |
1338 | |
1364 | |
1339 | # set background pixmap |
1365 | # set background pixmap |
1340 | |
1366 | |
1341 | $self->set_background ($img, $self->{border}); |
1367 | $self->set_background ($img, $self->{border}); |
|
|
1368 | } else { |
|
|
1369 | $self->clr_background; |
|
|
1370 | } |
|
|
1371 | |
1342 | $self->scr_recolor (0); |
1372 | $self->scr_recolor (0); |
1343 | $self->want_refresh; |
1373 | $self->want_refresh; |
1344 | } |
1374 | } |
1345 | |
1375 | |
1346 | sub old_bg_opts { |
1376 | sub old_bg_opts { |
… | |
… | |
1353 | return unless $str[0] or $self->{bg_opts}->{path}; |
1383 | return unless $str[0] or $self->{bg_opts}->{path}; |
1354 | |
1384 | |
1355 | my $bg_opts = $self->{bg_opts}; |
1385 | my $bg_opts = $self->{bg_opts}; |
1356 | |
1386 | |
1357 | if ($str[0]) { |
1387 | if ($str[0]) { |
1358 | $bg_opts->{tile} = 0; |
1388 | $bg_opts->{tile} = 0; |
1359 | $bg_opts->{keep_aspect} = 0; |
1389 | $bg_opts->{keep_aspect} = 0; |
1360 | $bg_opts->{root_align} = 0; |
1390 | $bg_opts->{root_align} = 0; |
1361 | $bg_opts->{h_scale} = $bg_opts->{v_scale} = 100; |
1391 | $bg_opts->{h_scale} = $bg_opts->{v_scale} = 100; |
1362 | $bg_opts->{h_align} = $bg_opts->{v_align} = 50; |
1392 | $bg_opts->{h_align} = $bg_opts->{v_align} = 50; |
1363 | $bg_opts->{path} = unpack "H*", $str[0]; |
1393 | $bg_opts->{path} = $str[0]; |
1364 | } |
1394 | } |
1365 | |
1395 | |
1366 | my @oplist = split /:/, $str[1]; |
1396 | my @oplist = split /:/, $str[1]; |
1367 | |
1397 | |
1368 | for (@oplist) { |
1398 | for (@oplist) { |
… | |
… | |
1396 | $bg_opts->{root_align} = 1; |
1426 | $bg_opts->{root_align} = 1; |
1397 | $bg_opts->{h_scale} = $bg_opts->{v_scale} = 0; |
1427 | $bg_opts->{h_scale} = $bg_opts->{v_scale} = 0; |
1398 | $bg_opts->{h_align} = $bg_opts->{v_align} = 0; |
1428 | $bg_opts->{h_align} = $bg_opts->{v_align} = 0; |
1399 | } elsif (/op=tile/i) { |
1429 | } elsif (/op=tile/i) { |
1400 | $bg_opts->{tile} = 1; |
1430 | $bg_opts->{tile} = 1; |
1401 | } elsif (/op=keep_aspect/i) { |
1431 | } elsif (/op=keep-aspect/i) { |
1402 | $bg_opts->{keep_aspect} = 1; |
1432 | $bg_opts->{keep_aspect} = 1; |
1403 | } elsif (/op=root_align/i) { |
1433 | } elsif (/op=root-align/i) { |
1404 | $bg_opts->{root_align} = 1; |
1434 | $bg_opts->{root_align} = 1; |
1405 | } elsif (/^ =? ([0-9]+)? (?:[xX] ([0-9]+))? ([+-][0-9]+)? ([+-][0-9]+)? $/x) { |
1435 | } elsif (/^ =? ([0-9]+)? (?:[xX] ([0-9]+))? ([+-][0-9]+)? ([+-][0-9]+)? $/x) { |
1406 | my ($w, $h, $x, $y) = ($1, $2, $3, $4); |
1436 | my ($w, $h, $x, $y) = ($1, $2, $3, $4); |
1407 | |
1437 | |
1408 | if ($str[0]) { |
1438 | if ($str[0]) { |
… | |
… | |
1417 | $bg_opts->{v_align} = $y if defined $y; |
1447 | $bg_opts->{v_align} = $y if defined $y; |
1418 | } |
1448 | } |
1419 | } |
1449 | } |
1420 | } |
1450 | } |
1421 | |
1451 | |
|
|
1452 | # helper function, quote string as perl without allowing |
|
|
1453 | # any code execution or other shenanigans. |
|
|
1454 | sub q0 { |
|
|
1455 | "qq\x00\Q$str\E\x00" |
|
|
1456 | } |
|
|
1457 | |
1422 | sub old_bg_expr { |
1458 | sub old_bg_expr { |
1423 | my ($self) = @_; |
1459 | my ($self) = @_; |
1424 | |
1460 | |
1425 | my $expr; |
1461 | my $expr; |
1426 | |
1462 | |
… | |
… | |
1441 | } |
1477 | } |
1442 | |
1478 | |
1443 | my $tint = $bg_opts->{tint}; |
1479 | my $tint = $bg_opts->{tint}; |
1444 | |
1480 | |
1445 | if ($tint) { |
1481 | if ($tint) { |
|
|
1482 | $tint = q0 $tint; |
1446 | $expr .= "tint $tint, "; |
1483 | $expr .= "tint $tint,"; |
1447 | } |
1484 | } |
1448 | |
1485 | |
1449 | my $blur = $bg_opts->{blur}; |
1486 | my $blur = $bg_opts->{blur}; |
1450 | |
1487 | |
1451 | if ($blur and $blur =~ /^ =? ([0-9]+)? (?:[xX] ([0-9]+))? $/x) { |
1488 | if ($blur and $blur =~ /^ =? ([0-9]+)? (?:[xX] ([0-9]+))? $/x) { |
… | |
… | |
1482 | if ($h_scale != 0 and $v_scale != 0) { |
1519 | if ($h_scale != 0 and $v_scale != 0) { |
1483 | my $op = $bg_opts->{keep_aspect} ? "fit" : "resize"; |
1520 | my $op = $bg_opts->{keep_aspect} ? "fit" : "resize"; |
1484 | $file_expr .= "$op TW * $h_scale, TH * $v_scale, "; |
1521 | $file_expr .= "$op TW * $h_scale, TH * $v_scale, "; |
1485 | } |
1522 | } |
1486 | |
1523 | |
|
|
1524 | my $path = q0 $bg_opts->{path}; |
|
|
1525 | |
1487 | $file_expr .= "keep { load pack \"H*\", \"$bg_opts->{path}\" })"; |
1526 | $file_expr .= "keep { load $path })"; |
1488 | |
1527 | |
1489 | if ($expr) { |
1528 | if ($expr) { |
1490 | $expr .= ", tint (\"[50]white\", $file_expr)"; |
1529 | $expr .= ", tint (\"[50]white\", $file_expr)"; |
1491 | } else { |
1530 | } else { |
1492 | $expr = $file_expr; |
1531 | $expr = $file_expr; |
… | |
… | |
1494 | } |
1533 | } |
1495 | |
1534 | |
1496 | $expr |
1535 | $expr |
1497 | } |
1536 | } |
1498 | |
1537 | |
|
|
1538 | sub find_resource { |
|
|
1539 | my ($self, $res, $opt) = @_; |
|
|
1540 | |
|
|
1541 | my $v = $self->x_resource ($opt); |
|
|
1542 | $v = $self->x_resource ($res) unless defined $v; |
|
|
1543 | |
|
|
1544 | $v |
|
|
1545 | } |
|
|
1546 | |
|
|
1547 | sub parse_bgopts { |
|
|
1548 | my ($self) = @_; |
|
|
1549 | |
|
|
1550 | my $expr = $self->x_resource ("%.expr"); |
|
|
1551 | |
|
|
1552 | if (!$expr) { |
|
|
1553 | $self->{bg_opts} = { h_scale => 100, v_scale => 100, |
|
|
1554 | h_align => 50, v_align => 50 }; |
|
|
1555 | |
|
|
1556 | $self->{bg_opts}{shade} = $self->find_resource ("shading", "sh"); |
|
|
1557 | $self->{bg_opts}{tint} = $self->find_resource ("tintColor", "tint"); |
|
|
1558 | $self->{bg_opts}{blur} = $self->find_resource ("blurRadius", "blr"); |
|
|
1559 | $self->{bg_opts}{root} = $self->find_resource ("transparent", "tr"); |
|
|
1560 | |
|
|
1561 | $self->old_bg_opts ($self->find_resource ("backgroundPixmap", "pixmap")); |
|
|
1562 | $expr = $self->old_bg_expr; |
|
|
1563 | } |
|
|
1564 | |
|
|
1565 | $self->set_expr (parse_expr $expr); |
|
|
1566 | $self->{border} = $self->x_resource_boolean ("%.border"); |
|
|
1567 | |
|
|
1568 | $MIN_INTERVAL = $self->x_resource ("%.interval"); |
|
|
1569 | } |
|
|
1570 | |
|
|
1571 | sub on_start { |
|
|
1572 | my ($self) = @_; |
|
|
1573 | |
|
|
1574 | $self->parse_bgopts; |
|
|
1575 | |
|
|
1576 | () |
|
|
1577 | } |
|
|
1578 | |
1499 | sub on_osc_seq { |
1579 | sub on_osc_seq { |
1500 | my ($self, $op, $arg) = @_; |
1580 | my ($self, $op, $arg) = @_; |
1501 | |
1581 | |
|
|
1582 | $op eq "20" or $op eq "706" |
|
|
1583 | or return; |
|
|
1584 | |
1502 | $self->{bg_opts} or return; |
1585 | $self->{bg_opts} |
1503 | |
1586 | or $self->parse_bgopts; |
1504 | $op =~ /^(20|705)$/ or return; |
|
|
1505 | |
1587 | |
1506 | if ($op eq "20") { |
1588 | if ($op eq "20") { |
1507 | if ($arg eq "?") { |
1589 | if ($arg eq "?") { |
1508 | my $h_scale = $self->{bg_opts}->{h_scale}; |
1590 | my $h_scale = $self->{bg_opts}{h_scale}; |
1509 | my $v_scale = $self->{bg_opts}->{v_scale}; |
1591 | my $v_scale = $self->{bg_opts}{v_scale}; |
1510 | my $h_align = $self->{bg_opts}->{h_align}; |
1592 | my $h_align = $self->{bg_opts}{h_align}; |
1511 | my $v_align = $self->{bg_opts}->{v_align}; |
1593 | my $v_align = $self->{bg_opts}{v_align}; |
1512 | $self->cmd_parse ("\033]2;[${h_scale}x${v_scale}+${h_align}+${v_align}]\007"); |
1594 | $self->cmd_parse ("\033]2;[${h_scale}x${v_scale}+${h_align}+${v_align}]\007"); |
1513 | } else { |
1595 | } else { |
1514 | $self->old_bg_opts ($arg); |
1596 | $self->old_bg_opts ($arg); |
1515 | my $expr = $self->old_bg_expr; |
1597 | my $expr = $self->old_bg_expr; |
1516 | $self->set_expr (parse_expr $expr) if $expr; |
1598 | $self->set_expr (parse_expr $expr) if $expr; |
1517 | } |
1599 | } |
1518 | } elsif ($op eq "705") { |
1600 | } elsif ($op eq "705") { |
1519 | $self->{bg_opts}->{tint} = $arg; |
1601 | $self->{bg_opts}{tint} = $arg; |
1520 | my $expr = $self->old_bg_expr; |
1602 | my $expr = $self->old_bg_expr; |
1521 | $self->set_expr (parse_expr $expr) if $expr; |
1603 | $self->set_expr (parse_expr $expr) if $expr; |
1522 | } |
1604 | } |
1523 | |
1605 | |
1524 | 1 |
1606 | 1 |
1525 | } |
1607 | } |
1526 | |
1608 | |
1527 | sub find_resource { |
|
|
1528 | my ($self, $res, $opt) = @_; |
|
|
1529 | |
|
|
1530 | my $v = $self->x_resource ($opt); |
|
|
1531 | $v = $self->x_resource ($res) unless defined $v; |
|
|
1532 | |
|
|
1533 | $v |
|
|
1534 | } |
|
|
1535 | |
|
|
1536 | sub on_start { |
|
|
1537 | my ($self) = @_; |
|
|
1538 | |
|
|
1539 | my $expr = $self->x_resource ("%.expr"); |
|
|
1540 | |
|
|
1541 | if (!$expr) { |
|
|
1542 | $self->{bg_opts} = { h_scale => 100, v_scale => 100, |
|
|
1543 | h_align => 50, v_align => 50 }; |
|
|
1544 | |
|
|
1545 | $self->{bg_opts}->{shade} = $self->find_resource ("shading", "sh"); |
|
|
1546 | $self->{bg_opts}->{tint} = $self->find_resource ("tintColor", "tint"); |
|
|
1547 | $self->{bg_opts}->{blur} = $self->find_resource ("blurRadius", "blr"); |
|
|
1548 | $self->{bg_opts}->{root} = $self->find_resource ("transparent", "tr"); |
|
|
1549 | |
|
|
1550 | $self->old_bg_opts ($self->find_resource ("backgroundPixmap", "pixmap")); |
|
|
1551 | $expr = $self->old_bg_expr; |
|
|
1552 | } |
|
|
1553 | |
|
|
1554 | $expr or return; |
|
|
1555 | |
|
|
1556 | $self->has_render |
|
|
1557 | or die "background extension needs RENDER extension 0.10 or higher, ignoring background-expr.\n"; |
|
|
1558 | |
|
|
1559 | $self->set_expr (parse_expr $expr); |
|
|
1560 | $self->{border} = $self->x_resource_boolean ("%.border"); |
|
|
1561 | |
|
|
1562 | $MIN_INTERVAL = $self->x_resource ("%.interval"); |
|
|
1563 | |
|
|
1564 | () |
|
|
1565 | } |
|
|
1566 | |
|
|