wmclockmon: remove old BUGS file and add a note to the INSTALL file about the require...
[dockapps.git] / wmgrabimage / wmGrabImage / GrabImage
blobcb208942122721e8d865db092285b01dac308af5
1 #!/usr/bin/perl
4 # Grabs an image on the WWW and resizes it (with antialiasing) down so that it can be
5 # displayed in a WindowMaker DockApp.
7 # Need to give it the URL of the image like so;
9 # GrabWeather http://whatever.com/image.gif
13 require "ctime.pl";
17 # Change to users home directory. We used to dump into /tmp
18 # but using home dir instead avoids multiple users interfering
19 # with one another. (Yeah, we could "unique-ize" the filenames, but
20 # this is easier for now...)
22 $home = (getpwuid($<))[7];
23 $ok = chdir() || chdir($home);
27 # Check to see if .wmGrabImage exists.
28 # If not, make it and move to it.
30 if ( !(-e ".wmGrabImage") ){
31 mkdir(".wmGrabImage", 0775);
33 chdir(".wmGrabImage");
39 $URL = $ARGV[0];
40 $Geometry = $ARGV[1];
41 $ImageName = $URL;
42 $ImageName =~ s/.*\/(.*)$/\1/;
43 if ($URL =~ /^file:\/\//) {
45 $ImagePath = $URL;
46 $ImagePath =~ s+file://(.*)+\1+;
47 system("cp $ImagePath $home/.wmGrabImage/$ImageName");
49 } else {
53 # I think some of these wget command line options may cause problems
54 # for some people? Dont know why...
56 $GrabCmd = "wget --proxy=off --passive-ftp --tries 0 -q -O $home/.wmGrabImage/$ImageName $URL";
57 system "$GrabCmd";
62 if (! ($Geometry eq "") ) {
63 system "convert -crop $Geometry $home/.wmGrabImage/${ImageName} $home/.wmGrabImage/${ImageName}.tmp.gif" ;
64 system "convert -geom 54x54 $home/.wmGrabImage/${ImageName}.tmp.gif ${home}/.wmGrabImage/${ImageName}.tmp.xpm";
65 } else {
66 system "convert -geom 54x54 $home/.wmGrabImage/${ImageName} ${home}/.wmGrabImage/${ImageName}.tmp.xpm";
68 system "cat ${home}/.wmGrabImage/${ImageName}.tmp.xpm | sed -e \"s/Transparent/Black/\" \> ${home}/.wmGrabImage/${ImageName}.xpm; rm ${home}/.wmGrabImage/${ImageName}.tmp.xpm";