… | |
… | |
11 | =head1 SYNOPSIS |
11 | =head1 SYNOPSIS |
12 | |
12 | |
13 | urxvt --background-expr 'background expression' |
13 | urxvt --background-expr 'background expression' |
14 | --background-border |
14 | --background-border |
15 | --background-interval seconds |
15 | --background-interval seconds |
|
|
16 | |
|
|
17 | =head1 QUICK AND DIRTY CHEAT SHEET |
|
|
18 | |
|
|
19 | Just load a random jpeg image and tile the background with it without |
|
|
20 | scaling or anything else: |
|
|
21 | |
|
|
22 | load "/path/to/img.jpg" |
|
|
23 | |
|
|
24 | The same, but use mirroring/reflection instead of tiling: |
|
|
25 | |
|
|
26 | mirror load "/path/to/img.jpg" |
|
|
27 | |
|
|
28 | Load an image and scale it to exactly fill the terminal window: |
|
|
29 | |
|
|
30 | scale keep { load "/path/to/img.jpg" } |
|
|
31 | |
|
|
32 | Implement pseudo-transparency by using a suitably-aligned root pixmap |
|
|
33 | as window background: |
|
|
34 | |
|
|
35 | rootalign root |
|
|
36 | |
|
|
37 | Likewise, but keep a blurred copy: |
|
|
38 | |
|
|
39 | rootalign keep { blur 10, root } |
16 | |
40 | |
17 | =head1 DESCRIPTION |
41 | =head1 DESCRIPTION |
18 | |
42 | |
19 | This extension manages the terminal background by creating a picture that |
43 | This extension manages the terminal background by creating a picture that |
20 | is behind the text, replacing the normal background colour. |
44 | is behind the text, replacing the normal background colour. |
… | |
… | |
74 | return load "$HOME/sunday.png"; |
98 | return load "$HOME/sunday.png"; |
75 | } |
99 | } |
76 | } |
100 | } |
77 | |
101 | |
78 | This inner expression is evaluated once per hour (and whenever the |
102 | This inner expression is evaluated once per hour (and whenever the |
79 | temrinal window is resized). It sets F<sunday.png> as background on |
103 | terminal window is resized). It sets F<sunday.png> as background on |
80 | Sundays, and F<weekday.png> on all other days. |
104 | Sundays, and F<weekday.png> on all other days. |
81 | |
105 | |
82 | Fortunately, we expect that most expressions will be much simpler, with |
106 | Fortunately, we expect that most expressions will be much simpler, with |
83 | little Perl knowledge needed. |
107 | little Perl knowledge needed. |
84 | |
108 | |
… | |
… | |
119 | width and doubles the image height: |
143 | width and doubles the image height: |
120 | |
144 | |
121 | scale 0.5, 2, load "$HOME/mypic.png" |
145 | scale 0.5, 2, load "$HOME/mypic.png" |
122 | |
146 | |
123 | IF you try out these expressions, you might suffer from some sluggishness, |
147 | IF you try out these expressions, you might suffer from some sluggishness, |
124 | because each time the terminal is resized, it loads the PNG image agin |
148 | because each time the terminal is resized, it loads the PNG image again |
125 | and scales it. Scaling is usually fast (and unavoidable), but loading the |
149 | and scales it. Scaling is usually fast (and unavoidable), but loading the |
126 | image can be quite time consuming. This is where C<keep> comes in handy: |
150 | image can be quite time consuming. This is where C<keep> comes in handy: |
127 | |
151 | |
128 | scale 0.5, 2, keep { load "$HOME/mypic.png" } |
152 | scale 0.5, 2, keep { load "$HOME/mypic.png" } |
129 | |
153 | |
… | |
… | |
159 | left corner of the terminal window)- the result is pseudo-transparency: |
183 | left corner of the terminal window)- the result is pseudo-transparency: |
160 | the image seems to be static while the window is moved around. |
184 | the image seems to be static while the window is moved around. |
161 | |
185 | |
162 | =head2 COLOUR SPECIFICATIONS |
186 | =head2 COLOUR SPECIFICATIONS |
163 | |
187 | |
164 | Whenever an oprator expects a "colour", then this can be specified in one |
188 | Whenever an operator expects a "colour", then this can be specified in one |
165 | of two ways: Either as string with an X11 colour specification, such as: |
189 | of two ways: Either as string with an X11 colour specification, such as: |
166 | |
190 | |
167 | "red" # named colour |
191 | "red" # named colour |
168 | "#f00" # simple rgb |
192 | "#f00" # simple rgb |
169 | "[50]red" # red with 50% alpha |
193 | "[50]red" # red with 50% alpha |
… | |
… | |
827 | latter in a white picture. |
851 | latter in a white picture. |
828 | |
852 | |
829 | Due to idiosyncrasies in the underlying XRender extension, biases less |
853 | Due to idiosyncrasies in the underlying XRender extension, biases less |
830 | than zero can be I<very> slow. |
854 | than zero can be I<very> slow. |
831 | |
855 | |
|
|
856 | You can also try the experimental(!) C<muladd> operator. |
|
|
857 | |
832 | =cut |
858 | =cut |
833 | |
859 | |
834 | sub contrast($$;$$;$) { |
860 | sub contrast($$;$$;$) { |
835 | my $img = pop; |
861 | my $img = pop; |
836 | my ($r, $g, $b, $a) = @_; |
862 | my ($r, $g, $b, $a) = @_; |
… | |
… | |
851 | $a = 1 if @_ < 4; |
877 | $a = 1 if @_ < 4; |
852 | |
878 | |
853 | $img = $img->clone; |
879 | $img = $img->clone; |
854 | $img->brightness ($r, $g, $b, $a); |
880 | $img->brightness ($r, $g, $b, $a); |
855 | $img |
881 | $img |
|
|
882 | } |
|
|
883 | |
|
|
884 | =item muladd $mul, $add, $img # EXPERIMENTAL |
|
|
885 | |
|
|
886 | First multipliesthe pixels by C<$mul>, then adds C<$add>. This cna be used |
|
|
887 | to implement brightness and contrast at the same time, with a wider value |
|
|
888 | range than contrast and brightness operators. |
|
|
889 | |
|
|
890 | Due to numerous bugs in XRender implementations, it can also introduce a |
|
|
891 | number of visual artifacts. |
|
|
892 | |
|
|
893 | Example: increase contrast by a factor of C<$c> without changing image |
|
|
894 | brightness too much. |
|
|
895 | |
|
|
896 | muladd $c, (1 - $c) * 0.5, $img |
|
|
897 | |
|
|
898 | =cut |
|
|
899 | |
|
|
900 | sub muladd($$$) { |
|
|
901 | $_[2]->muladd ($_[0], $_[1]) |
856 | } |
902 | } |
857 | |
903 | |
858 | =item blur $radius, $img |
904 | =item blur $radius, $img |
859 | |
905 | |
860 | =item blur $radius_horz, $radius_vert, $img |
906 | =item blur $radius_horz, $radius_vert, $img |
… | |
… | |
905 | C<keep> block so it only is reevaluated as required. |
951 | C<keep> block so it only is reevaluated as required. |
906 | |
952 | |
907 | Putting the blur into a C<keep> block will make sure the blur is only done |
953 | Putting the blur into a C<keep> block will make sure the blur is only done |
908 | once, while the C<rootalign> is still done each time the window moves. |
954 | once, while the C<rootalign> is still done each time the window moves. |
909 | |
955 | |
910 | rootlign keep { blur 10, root } |
956 | rootalign keep { blur 10, root } |
911 | |
957 | |
912 | This leaves the question of how to force reevaluation of the block, |
958 | This leaves the question of how to force reevaluation of the block, |
913 | in case the root background changes: If expression inside the block |
959 | in case the root background changes: If expression inside the block |
914 | is sensitive to some event (root background changes, window geometry |
960 | is sensitive to some event (root background changes, window geometry |
915 | changes), then it will be reevaluated automatically as needed. |
961 | changes), then it will be reevaluated automatically as needed. |
… | |
… | |
967 | |
1013 | |
968 | # compiles a parsed expression |
1014 | # compiles a parsed expression |
969 | sub set_expr { |
1015 | sub set_expr { |
970 | my ($self, $expr) = @_; |
1016 | my ($self, $expr) = @_; |
971 | |
1017 | |
972 | $self->{root} = []; |
1018 | $self->{root} = []; # the outermost frame |
973 | $self->{expr} = $expr; |
1019 | $self->{expr} = $expr; |
974 | $self->recalculate; |
1020 | $self->recalculate; |
975 | } |
1021 | } |
976 | |
1022 | |
977 | # takes a hash of sensitivity indicators and installs watchers |
1023 | # takes a hash of sensitivity indicators and installs watchers |
… | |
… | |
1039 | |
1085 | |
1040 | # set environment to evaluate user expression |
1086 | # set environment to evaluate user expression |
1041 | |
1087 | |
1042 | local $self = $arg_self; |
1088 | local $self = $arg_self; |
1043 | local $HOME = $ENV{HOME}; |
1089 | local $HOME = $ENV{HOME}; |
1044 | local $frame = []; |
1090 | local $frame = $self->{root}; |
1045 | |
1091 | |
1046 | ($x, $y, $w, $h) = $self->background_geometry ($self->{border}); |
1092 | ($x, $y, $w, $h) = $self->background_geometry ($self->{border}); |
1047 | |
1093 | |
1048 | # evaluate user expression |
1094 | # evaluate user expression |
1049 | |
1095 | |