3 # splash_resize -- a helper script to automatically create theme configs
4 # for different resolutions
6 # (c) 2004 Michal Januszewski <spock@gentoo.org>
8 # NOTE: This script only creates config files, it doesn't provide the necessary
9 # images - they have to be created by hand.
11 # Usage: splash_resize <theme> <old_res> <new_res>
13 # $Header: /srv/cvs/splash/utils/scripts/splash_resize,v 1.2 2004/11/12 17:42:16 spock Exp $
16 print "splash_resize/splashutils-@PACKAGE_VERSION@\n";
17 print "Usage: splash_resize <theme> <old_res> <new_res>\n";
25 open IN
,"<@themedir@/$theme/$old_res.cfg" || die "Can't open source config file.";
26 open OUT
,">@themedir@/$theme/$new_res.cfg" || die "Can't write to destination config file.";
28 $old_res =~ /(\d+)x(\d+)/; $old_x = $1; $old_y = $2;
29 $new_res =~ /(\d+)x(\d+)/; $new_x = $1; $new_y = $2;
33 if (/^\s*tx=(\d+)/ || /^\s*tw=(\d+)/ || /^\s*text_x=(\d+)/) {
34 $t = int(($1/$old_x)*$new_x);
36 } elsif (/^\s*ty=(\d+)/ || /^\s*th=(\d+)/ || /^\s*text_y=(\d+)/) {
37 $t = int(($1/$old_y)*$new_y);
39 } elsif (/^\s*text_size=(\d+)/) {
40 $t = int(($1/$old_y)*$new_y);
43 } elsif (/^\s*box\s*[a-zA-Z ]*\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/) {
45 $x0 = int(($1/$old_x)*$new_x);
46 $x1 = int(($3/$old_x)*$new_x);
47 $y0 = int(($2/$old_y)*$new_y);
48 $y1 = int(($4/$old_y)*$new_y);
49 s/box\s*([a-zA-Z ]*)\s*\d+\s+\d+\s+\d+\s+\d+\s*(.*)/box $1 $x0 $y0 $x1 $y1 $2/;
51 } elsif (/^\s*(silent)?pic(256)?=(.*)\n/) {
57 if ($src =~ /$max_res/) {
59 $dest =~ s/$old_res/$new_res/g;
62 $dest =~ s/\.[^\.]+$//g;
63 $dest .= "-$new_res.jpeg";
67 s/$old_res/$new_res/g;
75 print "Resized config file for theme '$theme' for '$new_res' resolution successfully created.\n";