Didier-T a écritragamatrix a écrit@Tous
Salut !
J'essaie de faire un conky "astronomique" mais comme me l'a expliqué Didier-T, je multiplie les scripts "imagesat.pl" pour afficher plusieurs images trouvées sur le net...Je voulais savoir s'il était possible de modifier ce script pour en faire un unique qui s'occupe de plusieurs images...??
...
Merci 🙂
Bonjour,
tu as déjà le script, mais je le poste pour le cas où sa intéresserait d'autres personnes.
#!/usr/bin/perl -w
use strict;
use warnings;
use constant VERSION => 0.03;
if(scalar @ARGV < 6) {
&help;
}
my @image_web;
my @dimensions;
my @file_name;
my $nb;
# Détermination des arguments
$nb = 0;
for(my $i = 0; $i < scalar @ARGV; $i +=2) {
if($ARGV[$i] eq "-s") {
$nb = $nb + 1;
$dimensions[$nb] = $ARGV[$i + 1];
}
elsif($ARGV[$i] eq "-i") {
$image_web[$nb] = $ARGV[$i + 1];
}
elsif($ARGV[$i] eq "-f") {
$file_name[$nb] = $ARGV[$i + 1];
}
else {
print STDERR "Argument $ARGV[$i] inconnu\n";
&help;
}
}
for(my $j = 1; $j <= $nb; $j +=1) {
# Détermination du nom de l'image
my @decoupage = split "/", $image_web[$j];
my $image_sat = $decoupage[$#decoupage];
@decoupage = split "/", $file_name[$j];
my $chemin = substr($file_name[$j], 0, length($file_name[$j]) - 1 - length($decoupage[$#decoupage]));
# On regarde si le fichier existe déjà
if(-e "$chemin/$image_sat") {
# Récupération des informations de l'image
my @infos_ancienne_image = (stat("$chemin/$image_sat"))[7..10];
# Téléchargement de l'image si besoin
&telecharger($image_web[$j], "-m -nd", "$chemin/$image_sat");
# Récupération des informations de l'image
my @infos_nouvelle_image = (stat("$chemin/$image_sat"))[7..10];
# Comparaison des informations pour déterminer si on a téléchargé une image
my $comparaison = 0;
for(my $i = 0; $i < scalar @infos_ancienne_image; $i++) {
if($infos_ancienne_image[$i] != $infos_nouvelle_image[$i]) {
$comparaison++;
last;
}
}
# Si l'image est nouvelle, il faut refaire un découpage
if($comparaison) {
&nouvelle_image("$chemin/$image_sat", $dimensions[$j], $file_name[$j]);
}
}
else {
&telecharger($image_web[$j], "", "$chemin/$image_sat");
&nouvelle_image("$chemin/$image_sat", $dimensions[$j], $file_name[$j]);
}
}
#######################
# Début des fonctions #
#######################
sub help {
print "Utilisation : $0 [arguments]\n"
. "arguments :\n"
. " -i : Permet d'indiquer l'emplacement où se trouve l'image\n"
. " -s : Permet d'indiquer le découpage de l'image\n"
. " -f : Permet d'indiquer où stoquer l'image créé et son nom\n";
exit(0);
}
sub nouvelle_image {
my ($image, $decoupage, $sauvegarde) = @_;
# Sauvegarde de l'image actuelle
system("cp $image imagesattmp.jpg");
# Découpage de l'image
system("convert imagesattmp.jpg -crop $decoupage $sauvegarde");
# Suppression de l'image temporaire
unlink "imagesattmp.jpg";
}
sub telecharger {
my ($emplacement, $options, $sauvim) = @_;
system("wget -q $options $emplacement -O $sauvim");
}
__END__
=encoding utf8
=head1 Nom
Imagesat
=head1 SYNOPSIS
Il permet de télécharger et réduire une image
=head1 DESCRIPTION
Ce script Perl permet de télécharger une image, de la redimensionner pour ensuite l'afficher dans conky. Le script prend B<obligatoirement> deux paramètres à savoir l'emplacement de l'image à
télécharger ainsi que les dimensions de la future image.
Les différentes images (en fonction de vos envies) où vous pouvez trouver votre bonheur se trouvent ici :
L<http://oiswww.eumetsat.org/IPPS/html/latestImages.html>
=head1 AUTEUR
Chipster Julien
=head1 Programmes externes
Pour fonctionner, ce script a besoin de deux logiciels :
=over 4
=item wget
=item imagemagick
=back
=head1 UTILISATION
Ce script s'utilise comme ceci :
C<${exec perl Imagesat} [arguments]>
Si vous avez fait un chmod +x Imagesat :
C<${exec ./Imagesat} [arguments]>
[arguments] doit être défini comme ceci :
=over 4
=item -s 200x200+0+0
=item -i http://......../mon_image.jpg
=item -f ~/.../image(x).jpg
=back
=head2 Exemple
C<${exec perl Imagesat -s 1274x657+0+110 -i http://oiswww.eumetsat.org/IPPS/html/latestImages/EUMETSAT_MSG_RGB-naturalcolor-westernEurope.jpg -f ~/conky/image.jpg}>
Allez, je suis sympa, voici comment ça s'utilise dans conky après la balise TEXT
${exec perl /home/user/.conky/Imagesat -s 1274x657+0+110 -i http://oiswww.eumetsat.org/IPPS/html/latestImages/EUMETSAT_MSG_RGB-naturalcolor-westernEurope.jpg -f ~/conky/image.jpg}${image /home/user/.conky/image.jpg -p -5,-5 -s 400x220}
=head1 BOGUES
Aucun connu actuellement
=head1 Évolutions
=head1 Changelog
=item1 Rajout de l'option -q à wget. Il était trop bavard :D Ceci avait tendance à faire boguer gnome
=over 4
=item 30/08/2009
Création du script
=item Big Bang
Création de l'univers connu :D
=back
ce code à été écrit par
Chipster Julien du forum
Archlinux.fr, je me suis contenté d'y apporter quelques modifications, de manière à gérer le nom du fichier créé pour l'affichage par conky, ainsi que sa position dans votre arborescence (à savoir que le téléchargement s'effectuera lui aussi dans ce répertoire)
utilisation dans conky :
${exec perl /home/user/.conky/Imagesat -s 1274x657+0+110 -i http://oiswww.eumetsat.org/IPPS/html/latestImages/EUMETSAT_MSG_RGB-naturalcolor-westernEurope.jpg -f ~/conky/image.jpg}
${image ~/conky/image.jpg -p -5,-5 -s 400x220 -f 60}
avec cette exemple vous téléchargé l'image
EUMETSAT_MSG_RGB-naturalcolor-westernEurope.jpg dans le répertoire
~/conky puis créé si besoin l'image
image.jpg dans le même répertoire, de manière a pouvoir l'afficher via
${image ~/conky/image.jpg -p -5,-5 -s 400x220 -f 60}
Voici un conky qui ne sert pas à grand chose; les planètes de notre système solaire affichées sur le bureau avec la date d'aujourd'hui, ainsi que l'activité solaire en direct...Ceci grâce au script mis à jour de Didier-T permettant de récupérer plusieurs images avec un seul script.
A modifier à votre goût :
imagesat_multi.pl :
#!/usr/bin/perl -w
use strict;
use warnings;
use constant VERSION => 0.03;
if(scalar @ARGV < 6) {
&help;
}
my @image_web;
my @dimensions;
my @file_name;
my $nb;
# Détermination des arguments
$nb = 0;
for(my $i = 0; $i < scalar @ARGV; $i +=2) {
if($ARGV[$i] eq "-s") {
$nb = $nb + 1;
$dimensions[$nb] = $ARGV[$i + 1];
}
elsif($ARGV[$i] eq "-i") {
$image_web[$nb] = $ARGV[$i + 1];
}
elsif($ARGV[$i] eq "-f") {
$file_name[$nb] = $ARGV[$i + 1];
}
else {
print STDERR "Argument $ARGV[$i] inconnu\n";
&help;
}
}
for(my $j = 1; $j <= $nb; $j +=1) {
# Détermination du nom de l'image
my @decoupage = split "/", $image_web[$j];
my $image_sat = $decoupage[$#decoupage];
@decoupage = split "/", $file_name[$j];
my $chemin = substr($file_name[$j], 0, length($file_name[$j]) - 1 - length($decoupage[$#decoupage]));
# On regarde si le fichier existe déjà
if(-e "$chemin/$image_sat") {
# Récupération des informations de l'image
my @infos_ancienne_image = (stat("$chemin/$image_sat"))[7..10];
# Téléchargement de l'image si besoin
&telecharger($image_web[$j], "-m -nd", "$chemin/$image_sat");
# Récupération des informations de l'image
my @infos_nouvelle_image = (stat("$chemin/$image_sat"))[7..10];
# Comparaison des informations pour déterminer si on a téléchargé une image
my $comparaison = 0;
for(my $i = 0; $i < scalar @infos_ancienne_image; $i++) {
if($infos_ancienne_image[$i] != $infos_nouvelle_image[$i]) {
$comparaison++;
last;
}
}
# Si l'image est nouvelle, il faut refaire un découpage
if($comparaison) {
&nouvelle_image("$chemin/$image_sat", $dimensions[$j], $file_name[$j]);
}
}
else {
&telecharger($image_web[$j], "", "$chemin/$image_sat");
&nouvelle_image("$chemin/$image_sat", $dimensions[$j], $file_name[$j]);
}
}
#######################
# Début des fonctions #
#######################
sub help {
print "Utilisation : $0 [arguments]\n"
. "arguments :\n"
. " -i : Permet d'indiquer l'emplacement où se trouve l'image\n"
. " -s : Permet d'indiquer le découpage de l'image\n"
. " -f : Permet d'indiquer où stoquer l'image créé et son nom\n";
exit(0);
}
sub nouvelle_image {
my ($image, $decoupage, $sauvegarde) = @_;
# Sauvegarde de l'image actuelle
system("cp $image imagesattmp.jpg");
# Découpage de l'image
system("convert imagesattmp.jpg -crop $decoupage $sauvegarde");
# Suppression de l'image temporaire
unlink "imagesattmp.jpg";
}
sub telecharger {
my ($emplacement, $options, $sauvim) = @_;
system("wget -q $options $emplacement -O $sauvim");
}
__END__
=encoding utf8
=head1 Nom
Imagesat
=head1 SYNOPSIS
Il permet de télécharger et réduire une image
=head1 DESCRIPTION
Ce script Perl permet de télécharger une image, de la redimensionner pour ensuite l'afficher dans conky. Le script prend B<obligatoirement> deux paramètres à savoir l'emplacement de l'image à
télécharger ainsi que les dimensions de la future image.
Les différentes images (en fonction de vos envies) où vous pouvez trouver votre bonheur se trouvent ici :
L<http://oiswww.eumetsat.org/IPPS/html/latestImages.html>
=head1 AUTEUR
Chipster Julien
=head1 Programmes externes
Pour fonctionner, ce script a besoin de deux logiciels :
=over 4
=item wget
=item imagemagick
=back
=head1 UTILISATION
Ce script s'utilise comme ceci :
C<${exec perl Imagesat} [arguments]>
Si vous avez fait un chmod +x Imagesat :
C<${exec ./Imagesat} [arguments]>
[arguments] doit être défini comme ceci :
=over 4
=item -i http://......../mon_image.jpg
=item -s 200x200+0+0
=back
=head2 Exemple
C<${exec perl Imagesat -s 1274x657+0+110 -i http://oiswww.eumetsat.org/IPPS/html/latestImages/EUMETSAT_MSG_RGB-naturalcolor-westernEurope.jpg}>
Allez, je suis sympa, voici comment ça s'utilise dans conky après la balise TEXT
${exec perl /home/user/.conky/Imagesat -s 1274x657+0+110 -i http://oiswww.eumetsat.org/IPPS/html/latestImages/EUMETSAT_MSG_RGB-naturalcolor-westernEurope.jpg}${image /home/user/.conky/image.jpg -p -5,-5 -s 400x220}
=head1 BOGUES
Aucun connu actuellement
=head1 Évolutions
=head1 Changelog
=item1 Rajout de l'option -q à wget. Il était trop bavard :D Ceci avait tendance à faire boguer gnome
=over 4
=item 30/08/2009
Création du script
=item Big Bang
Création de l'univers connu :D
=back
conkyrc_sys_sol2 :
# Create own window instead of using desktop (required in nautilus)
own_window yes
own_window_hints undecorated,below,skip_taskbar
background no
# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes
# fiddle with window
use_spacer yes
use_xft yes
# Update interval in seconds
update_interval 1
# Minimum size of text area
minimum_size 1500 900
maximum_width 1500
# Draw shades?
draw_shades yes
# Text stuff
draw_outline no # amplifies text if yes
draw_borders no
uppercase no # set to yes if you want all text to be in uppercase
# Stippled borders?
stippled_borders 3
# border margins
#border_margin 9
# border width
#border_width 4
# Default colors and also border colors, grey90 == #e5e5e5
default_color white
default_shade_color black
default_outline_color white
own_window_colour brown
own_window_transparent yes
# Text alignment, other possible values are commented
alignment top_left
#alignment top_right
#alignment bottom_left
#alignment bottom_right
# Gap between borders of screen and text
gap_x 15
gap_y 15
# stuff after 'TEXT' will be formatted on screen
#override_utf8_locale no
#xftfont font Helvetica LT Std:bold:size=8 #Terminus:size=8
#xftalpha 0.8
#override_utf8_locale yes
# -- Text settings -- #
override_utf8_locale yes
use_xft yes
font Helvetica LT Std:bold:size=8
TEXT
${voffset 10}${goto 60}${font Spaceship Bullet:style=Bold:size=18}${color ffe595}Système Solaire ${font Spaceship Bullet:style=Bold:size=18}${color C1CDCD}${font}
#####################CARTES###############################
#SYSTèME_SOLAIRE#
${execpi 1200 perl ~/conky/script/imagesat_multi.pl -s 600x400+0+0 -i http://xplanet.jcweather.us/venus-sun.jpg -f /home/ragamatrix/image1.jpg}
${image /home/ragamatrix/image1.jpg -p 10,30 -s 500x300 -f 60}
${execpi 1200 perl ~/conky/script/imagesat_multi.pl -s 600x400+0+0 -i http://xplanet.jcweather.us/mars-sun.jpg -f /home/ragamatrix/image2.jpg}
${image /home/ragamatrix/image2.jpg -p 10,305 -s 500x300 -f 60}
${execpi 1200 perl ~/conky/script/imagesat_multi.pl -s 600x400+0+0 -i http://xplanet.jcweather.us/jupiter-sun.jpg -f /home/ragamatrix/image3.jpg}
${image /home/ragamatrix/image3.jpg -p 507,305 -s 500x300 -f 60}
${execpi 1200 perl ~/conky/script/imagesat_multi.pl -s 600x400+0+0 -i http://xplanet.jcweather.us/saturn-sun.jpg -f /home/ragamatrix/image4.jpg}
${image /home/ragamatrix/image4.jpg -p 507,30 -s 500x300 -f 60}
${execpi 1200 perl ~/conky/script/imagesat_multi.pl -s 600x400+0+0 -i http://xplanet.jcweather.us/uranus-sun.jpg -f /home/ragamatrix/image5.jpg}
${image /home/ragamatrix/image5.jpg -p 507,605 -s 500x300 -f 60}
${execpi 1200 perl ~/conky/script/imagesat_multi.pl -s 600x400+0+0 -i http://xplanet.jcweather.us/neptune-sun.jpg -f /home/ragamatrix/image6.jpg}
${image /home/ragamatrix/image6.jpg -p 10,605 -s 500x300 -f 60}
${execpi 1200 perl ~/conky/script/imagesat_multi.pl -s 600x400+0+0 -i http://xplanet.jcweather.us/mercury-sun.jpg -f /home/ragamatrix/image7.jpg}
${image /home/ragamatrix/image7.jpg -p 1005,605 -s 500x300 -f 60}
${execpi 1200 perl ~/conky/script/imagesat_multi.pl -s 600x400+0+0 -i http://xplanet.jcweather.us/pluto-sun.jpg -f /home/ragamatrix/image8.jpg}
${image /home/ragamatrix/image8.jpg -p 1005,305 -s 500x300 -f 60}
${execpi 1200 perl ~/conky/script/imagesat_multi.pl -s 512x512+0+0 -i http://sohowww.nascom.nasa.gov/data/screensaver/eit_171.jpg -f /home/ragamatrix/image9.jpg}
${image /home/ragamatrix/image9.jpg -p 1005,20 -s 320x320 -f 60}
Résutlat :

En attendand un script Meteo-Lua avec la météo sat sur Mars...:lol:
Un petit coup d'oeil là dessus :
google_mars
https://developers.google.com/earth/documentation/sky_mars_moon#mars
...
Pour chez moi la carte graphique ne suit pas toujours.