summaryrefslogtreecommitdiffstats
path: root/lib/Xconfig/resolution_and_depth.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-02-21 17:07:22 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-02-21 17:07:22 +0000
commitc8126ed5aee0dba7b1b6f51e1f256d66ef4e9a02 (patch)
tree1285198313bda279ab36376306185bc625bc80b7 /lib/Xconfig/resolution_and_depth.pm
parent618400118f7ec17f484815cc0a206cce71ab21ee (diff)
downloaddrakx-kbd-mouse-x11-c8126ed5aee0dba7b1b6f51e1f256d66ef4e9a02.tar
drakx-kbd-mouse-x11-c8126ed5aee0dba7b1b6f51e1f256d66ef4e9a02.tar.gz
drakx-kbd-mouse-x11-c8126ed5aee0dba7b1b6f51e1f256d66ef4e9a02.tar.bz2
drakx-kbd-mouse-x11-c8126ed5aee0dba7b1b6f51e1f256d66ef4e9a02.tar.xz
drakx-kbd-mouse-x11-c8126ed5aee0dba7b1b6f51e1f256d66ef4e9a02.zip
- XFdrake:
o when setting background for the resolution, handle "hour"-based backgrounds
Diffstat (limited to 'lib/Xconfig/resolution_and_depth.pm')
-rw-r--r--lib/Xconfig/resolution_and_depth.pm39
1 files changed, 26 insertions, 13 deletions
diff --git a/lib/Xconfig/resolution_and_depth.pm b/lib/Xconfig/resolution_and_depth.pm
index d5c502b..21af695 100644
--- a/lib/Xconfig/resolution_and_depth.pm
+++ b/lib/Xconfig/resolution_and_depth.pm
@@ -254,21 +254,34 @@ sub set_default_background {
my $ratio = $resolution->{X} / $resolution->{Y};
my $dir = "$::prefix/usr/share/mdk/backgrounds";
my %theme = getVarsFromSh("$::prefix/etc/sysconfig/bootsplash");
- my @l =
+
+ my @l = map {
+ if (my ($X, $Y, undef, $hour) = /^\Q$theme{THEME}\E-(\d+)x(\d+)(-(.*))?.png$/) {
+ { file => $_, X => $X, Y => $Y, hour => $hour };
+ } else { () }
+ } all($dir);
+
+ my ($best, $_other) =
sort {
- $a->[1] <=> $b->[1] || $b->[2] <=> $a->[2] || $a->[3] <=> $b->[3];
+ $a->[2] <=> $b->[2] || $b->[3] <=> $a->[3] || $a->[4] <=> $b->[4];
} map {
- if (my ($X, $Y) = /^\Q$theme{THEME}\E-(\d+)x(\d+).png$/) {
- [
- $_,
- int(abs($ratio - $X / $Y) * 100), #- we want the nearest ratio (precision .01)
- $X >= $resolution->{X}, #- then we don't want a resolution smaller
- abs($X - $resolution->{X}), #- the nearest resolution
- ];
- } else { () }
- } all($dir);
-
- symlinkf $l[0][0], "$dir/default.png";
+ [
+ $_->{X}, $_->{Y},
+ int(abs($ratio - $_->{X} / $_->{Y}) * 100), #- we want the nearest ratio (precision .01)
+ $_->{X} >= $resolution->{X}, #- then we don't want a resolution smaller
+ abs($_->{X} - $resolution->{X}), #- the nearest resolution
+ ];
+ } @l;
+
+ my @wanted = grep { $best->[0] == $_->{X} && $best->[1] == $_->{Y} } @l;
+
+ foreach (@wanted) {
+ if ($_->{hour}) {
+ symlinkf $_->{file}, "$dir/$theme{THEME}-$_->{hour}.png";
+ } else {
+ symlinkf $_->{file}, "$dir/default.png";
+ }
+ }
}
sub is_915resolution_configured() {
my $f = "$::prefix/etc/sysconfig/915resolution";