1 | #! perl |
1 | #! perl |
2 | |
2 | |
3 | #:META:X_RESOURCE:%.expr:string:background expression |
3 | #:META:RESOURCE:%.expr:string:background expression |
4 | #:META:X_RESOURCE:%.border:boolean:respect the terminal border |
4 | #:META:RESOURCE:%.border:boolean:respect the terminal border |
5 | #:META:X_RESOURCE:%.interval:seconds:minimum time between updates |
5 | #:META:RESOURCE:%.interval:seconds:minimum time between updates |
6 | |
6 | |
7 | =head1 NAME |
7 | =head1 NAME |
8 | |
8 | |
9 | background - manage terminal background |
9 | background - manage terminal background |
10 | |
10 | |
… | |
… | |
54 | |
54 | |
55 | urxvt --background-expr 'scale keep { load "/path/to/mybg.png" }' |
55 | urxvt --background-expr 'scale keep { load "/path/to/mybg.png" }' |
56 | |
56 | |
57 | Or specified as a X resource: |
57 | Or specified as a X resource: |
58 | |
58 | |
59 | URxvt.background-expr: scale keep { load "/path/to/mybg.png" } |
59 | URxvt.background.expr: scale keep { load "/path/to/mybg.png" } |
60 | |
60 | |
61 | =head1 THEORY OF OPERATION |
61 | =head1 THEORY OF OPERATION |
62 | |
62 | |
63 | At startup, just before the window is mapped for the first time, the |
63 | At startup, just before the window is mapped for the first time, the |
64 | expression is evaluated and must yield an image. The image is then |
64 | expression is evaluated and must yield an image. The image is then |
… | |
… | |
132 | get a percentage): |
132 | get a percentage): |
133 | |
133 | |
134 | scale 2, load "$HOME/mypic.png" |
134 | scale 2, load "$HOME/mypic.png" |
135 | |
135 | |
136 | This enlarges the image by a factor of 2 (200%). As you can see, C<scale> |
136 | This enlarges the image by a factor of 2 (200%). As you can see, C<scale> |
137 | has now two arguments, the C<200> and the C<load> expression, while |
137 | has now two arguments, the C<2> and the C<load> expression, while |
138 | C<load> only has one argument. Arguments are separated from each other by |
138 | C<load> only has one argument. Arguments are separated from each other by |
139 | commas. |
139 | commas. |
140 | |
140 | |
141 | Scale also accepts two arguments, which are then separate factors for both |
141 | Scale also accepts two arguments, which are then separate factors for both |
142 | horizontal and vertical dimensions. For example, this halves the image |
142 | horizontal and vertical dimensions. For example, this halves the image |
… | |
… | |
562 | |
562 | |
563 | A common use case is to fade the background image when the terminal loses |
563 | A common use case is to fade the background image when the terminal loses |
564 | focus, often together with the C<-fade> command line option. In fact, |
564 | focus, often together with the C<-fade> command line option. In fact, |
565 | there is a special function for just that use case: C<focus_fade>. |
565 | there is a special function for just that use case: C<focus_fade>. |
566 | |
566 | |
567 | Example: use two entirely different bacckground images, depending on |
567 | Example: use two entirely different background images, depending on |
568 | whether the window has focus. |
568 | whether the window has focus. |
569 | |
569 | |
570 | FOCUS ? keep { load "has_focus.jpg" } : keep { load "no_focus.jpg" } |
570 | FOCUS ? keep { load "has_focus.jpg" } : keep { load "no_focus.jpg" } |
571 | |
571 | |
572 | =cut |
572 | =cut |
… | |
… | |
956 | =item focus_fade $factor, $img |
956 | =item focus_fade $factor, $img |
957 | |
957 | |
958 | =item focus_fade $factor, $color, $img |
958 | =item focus_fade $factor, $color, $img |
959 | |
959 | |
960 | Fades the image by the given factor (and colour) when focus is lost (the |
960 | Fades the image by the given factor (and colour) when focus is lost (the |
961 | same as the C<-fade>/C<-fadecolo> command line options, which also supply |
961 | same as the C<-fade>/C<-fadecolor> command line options, which also supply |
962 | the default values for C<factor> and C<$color>. Unlike with C<-fade>, the |
962 | the default values for C<factor> and C<$color>. Unlike with C<-fade>, the |
963 | C<$factor> is the real value, not a percentage value (that is, 0..1, not |
963 | C<$factor> is a real value, not a percentage value (that is, 0..1, not |
964 | 0..100). |
964 | 0..100). |
965 | |
965 | |
966 | Example: do the right thing when focus fading is requested. |
966 | Example: do the right thing when focus fading is requested. |
967 | |
967 | |
968 | focus_fade load "mybg.jpg"; |
968 | focus_fade load "mybg.jpg"; |
… | |
… | |
1186 | # } |
1186 | # } |
1187 | |
1187 | |
1188 | # set background pixmap |
1188 | # set background pixmap |
1189 | |
1189 | |
1190 | $self->set_background ($img, $self->{border}); |
1190 | $self->set_background ($img, $self->{border}); |
1191 | $self->scr_recolour (0); |
1191 | $self->scr_recolor (0); |
1192 | $self->want_refresh; |
1192 | $self->want_refresh; |
1193 | } |
1193 | } |
1194 | |
1194 | |
1195 | sub on_start { |
1195 | sub on_start { |
1196 | my ($self) = @_; |
1196 | my ($self) = @_; |