[info.pl, Perl] souci au lancement (résolu)

Ce qui ne concerne ni le forum ni des problèmes
Répondre
Avatar de l’utilisateur
wido
Chu Ko Nu
Messages : 497
Inscription : mar. 21 oct. 2008, 20:59

[info.pl, Perl] souci au lancement (résolu)

Message par wido »

Bonjour,
j'ai un souci pour lancer ce script, vous l'utilisez dans vos imprimes écran mais il me met un message d'erreur:

Code : Tout sélectionner

[wido@desktop ~]$ perl /home/wido/Desktop/info.pl
String found where operator expected at /home/wido/Desktop/info.pl line 82, near "case "Openbox""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 97, near "case "Metacity""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 104, near "case "Fluxbox""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 116, near "case "Blackbox""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 128, near "case "Xfwm4""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 140, near "case "Kwin""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 152, near "case "Enlightenment""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 160, near "case "IceWM""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 175, near "case "PekWM""
	(Do you need to predeclare case?)
syntax error at /home/wido/Desktop/info.pl line 81, near ") {"
syntax error at /home/wido/Desktop/info.pl line 97, near "case "Metacity""
syntax error at /home/wido/Desktop/info.pl line 103, near "}"
syntax error at /home/wido/Desktop/info.pl line 115, near "}"
syntax error at /home/wido/Desktop/info.pl line 127, near "}"
syntax error at /home/wido/Desktop/info.pl line 139, near "}"
syntax error at /home/wido/Desktop/info.pl line 151, near "}"
syntax error at /home/wido/Desktop/info.pl line 159, near "}"
syntax error at /home/wido/Desktop/info.pl line 174, near "}"
syntax error at /home/wido/Desktop/info.pl line 186, near "}"
/home/wido/Desktop/info.pl has too many errors.
voici le script:

Code : Tout sélectionner

#!/usr/bin/perl
use Switch;
use strict;
use File::Basename;
 
####################
## Config options ##
####################
 
## What distro logo to use to use, Available "Archlinux Debian Ubuntu None" ##
my $distro = "Archlinux";
my $myArchVersion = "ArchLinux (Overlord)";
 
## what values to display. Use "OS Kernel DE WM win_theme Theme Font Icons" ##
my $display = "OS Kernel DE WM Win_theme Theme Icons Font Background";
 
## What colors to use for the variables. ##
my $textcolor = "\e[0m";
 
## Prints little debugging messages if set to 0 ##
my $quite = 1;
 


 
########################
## Script starts here ##
########################
## Define some thing to work with strict ##
my @line = ();
my $found = 0;
my $DE = "NONE";
my $WM = "Beryl";
 
## Hash of WMs and the process they run #
my %WMlist = ("Beryl"           => "beryl",
              "Fluxbox"         => "fluxbox",
              "Openbox"         => "openbox",
              "Blackbox"        => "blackbox",
              "Xfwm4"           => "xfwm4",
              "Metacity"        => "metacity",
              "Kwin"            => "kwin",
              "FVWM"            => "fvwm",
              "Enlightenment"   => "enlightenment",
              "IceWM"           => "icewm",
              "Window Maker"    => "wmaker",
              "Compiz-Fusion"   => "compiz",
              "PekWM"           => "pekwm",
              "Awesome"         => "awesome",
              "Dwm"             => "dwm",
              "XMonad"          => "xmonad" );
 
## Hash of DEs and the process they run ##     
my %DElist = ("Gnome"   => "gnome-session",
              "Xfce4"   => "xfce-mcs-manage",
              "KDE"     => "ksmserver");
 
## Get Kernel version ##
if ( $display =~ "Kernel"){
  print "\::$textcolor Finding Kernel version\n" unless $quite == 1;
  my $kernel = `uname -r`;
  $kernel =~ s/\s+/ /g;
  $kernel = " Kernel:$textcolor $kernel";
  push(@line, "$kernel");
}
 
## Find running processes ##
print "\::$textcolor Getting processes \n" unless $quite == 1;
my $processes = `ps -A | awk {'print \$4'}`;
 
## Find DE ##
while( (my $DEname, my $DEprocess) = each(%DElist) ) {
  print "\::$textcolor Testing $DEname process: $DEprocess \n" unless $quite == 1;
  if ( $processes =~ m/$DEprocess/ ) {
    $DE = $DEname;
    print "\::$textcolor DE found as $DE\n" unless $quite == 1;
    if( $display =~ m/DE/ ) {
      push(@line, " DE:$textcolor $DE");
    }
    last;
  }
}
 
## Find WM ##
while( (my $WMname, my $WMprocess) = each(%WMlist) ) {
 print "\::$textcolor Testing $WMname process: $WMprocess \n" unless $quite == 1;
  if ( $processes =~ m/$WMprocess/ ) {
    $WM = $WMname;
    print "\::$textcolor WM found as $WM\n" unless $quite == 1;
    if( $display =~ m/WM/ ) {
      push(@line, " WM:$textcolor $WM");
    }
    last;
  }
}
 
## Find WM theme ##
if ( $display =~ m/Win_theme/ ){
  switch($WM) {
    case "Openbox" {
      print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
      open(FILE, "$ENV{HOME}/.config/openbox/rc.xml")
      || die "\e[0;31m<Failed>\n";
      while( <FILE> ) {
        if( /<name>(.+)<\/name>/ ) {
          while ( $found == 0 ) {
            print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
            push(@line, " WM Theme:$textcolor $1");
            $found = 1;
          }
        }
      }
      close(FILE);
    }
    case "Metacity" {
      print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
      my $gconf = `gconftool-2 -g /apps/metacity/general/theme`;
      print "\::$textcolor $WM theme found as $gconf\n" unless $quite == 1;
      chomp ($gconf);
      push(@line, " WM Theme:$textcolor $gconf");
    }
    case "Fluxbox" {
      print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
      open(FILE, "$ENV{HOME}/.fluxbox/init")
      || die "\e[0;31m<Failed>\n";
      while( <FILE> ) {
        if( /session.styleFile:.*\/(.+)/ ) {
          print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
          push(@line, " WM Theme:$textcolor $1");
        }
      }
      close(FILE);
    }
    case "Blackbox" {
      print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
      open(FILE, "$ENV{HOME}/.blackboxrc")
      || die "\e[0;31m<Failed>\n";
      while( <FILE> ) {
        if( /session.styleFile:.*\/(.+)/ ) {
          print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
          push(@line, " WM Theme:$textcolor $1");
        }
      }
      close(FILE);
    }
    case "Xfwm4" {
      print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
      open(FILE, "$ENV{HOME}/.config/xfce4/mcs_settings/xfwm4.xml")
      || die "\e[0;31m<Failed>\n";
      while( <FILE> ) {
        if( /<option name="Xfwm\/ThemeName" type="string" value="(.+)"\/>/ ) {
          print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
          push(@line, " WM Theme:$textcolor $1");
        }
  } 
      close(FILE);
    }
    case "Kwin" {
      print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
      open(FILE, "$ENV{HOME}/.kde/share/config/kwinrc")
      || die "\e[0;31m<Failed>\n";
      while( <FILE> ) {
        if( /PluginLib=kwin3_(.+)/ ) {
          print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
          push(@line, " WM Theme:$textcolor $1");
        }
      }
      close(FILE);
    }
    case "Enlightenment" {
      print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
      my $remote = `enlightenment_remote -theme-get theme` ;
      if( $remote =~ m/.*FILE="(.+).edj"/ ) {
        print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
        push(@line, " WM Theme:$textcolor $1");
      }     
    }       
    case "IceWM" { 
      print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
      open(FILE, "$ENV{HOME}/.icewm/theme")
      || die "\e[0;31m<Failed>\n";
      while( <FILE> ) {
        if( /Theme="(.+)\/.*.theme/ ) {
          while( $found == 0 ) {
            print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
            push(@line, " WM Theme:$textcolor $1");
            $found = 1;
          }
        }
      }   
      close(FILE);
    }   
    case "PekWM" {
      print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
      open(FILE, "$ENV{HOME}/.pekwm/config")
      || die "\e[0;31m<Failed>\n";
      while( <FILE> ) {
        if( /Theme.*\/(.*)"/ ) {
            print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
            push(@line, " WM Theme:$textcolor $1");
        }
      }
      close(FILE); 
    } 
  }   
}     
      
## Find Theme Icon and Font ##
if ( $display =~ m/[Theme, Icons, Font, Background]/) {
  switch($DE) {
    case "Gnome" {
      print "\::$textcolor Finding $DE variables\n" unless $quite == 1;
      if ( $display =~ m/Theme/ ) {
        my $gconf = `gconftool-2 -g /desktop/gnome/interface/gtk_theme`;
        chomp ($gconf);
        print "\::$textcolor GTK Theme found as $1\n" unless $quite == 1;
        push(@line, " GTK Theme:$textcolor $gconf");
      }
      if ( $display =~ m/Icons/ ) {
        my $gconf = `gconftool-2 -g /desktop/gnome/interface/icon_theme`;
        chomp ($gconf);
        push(@line, " Icons:$textcolor $gconf");
      } 
      if ( $display =~ m/Font/ ) {
        my $gconf = `gconftool-2 -g /desktop/gnome/interface/font_name`;
        chomp ($gconf);
        push(@line, " Font:$textcolor $gconf");
      }
	  if ( $display =~ m/Background/ ) {
        my $gconf = `gconftool-2 -g /desktop/gnome/background/picture_filename`;
        chomp ($gconf);
		my $bname = basename($gconf);
		push(@line, " Background:$textcolor $bname");
      }
 
    } 
    case "Xfce4" {
      my @sort = ();
      print "\::$textcolor Finding $DE variables\n" unless $quite == 1;
      open(FILE, "$ENV{HOME}/.config/xfce4/mcs_settings/gtk.xml")
      || die "\e[0;31m<Failed>\n";
      while( <FILE> ) {
     if ( $display =~ m/Theme/ ) {
          if (/<option name="Net\/ThemeName" type="string" value="(.+)"\/>/ ) {
            print "\::$textcolor GTK Theme found as $1\n" unless $quite == 1;
            unshift(@sort, " GTK Theme:$textcolor $1");
          } 
        }
        if ( $display =~ m/Icons/ ) {
          if (/<option name="Net\/IconThemeName" type="string" value="(.+)"\/>/ ) {
            print "\::$textcolor Icons found as $1\n" unless $quite == 1;
            unshift(@sort, " Icons:$textcolor $1");
          }
        }
        if ( $display =~ m/Font/ ) {
          if ( /<option name="Gtk\/FontName" type="string" value="(.+)"\/>/ ) {
            print "\::$textcolor Font found as $1\n" unless $quite == 1;
            unshift(@sort, " Font:$textcolor $1");
          } 
        }
      }
      close(FILE);
      ## Sort variables so they're ordered "Theme Icon Font" ##
      foreach my $i (@sort) {
        push(@line, "$i");
      }
    } 
    case "KDE" { 
      print "\::$textcolor Finding $DE variables\n" unless $quite == 1;
      open(FILE, "$ENV{HOME}/.kde/share/config/kdeglobals")
      || die "\e[0;31m<Failed>\n";
      while( <FILE> ) { 
        if ( $display =~ m/Theme/ ) {
          if ( /widgetStyle=(.+)/  ) {
            print "\::$textcolor Wiget Style found as $1\n" unless $quite == 1;
            push(@line, " Wiget Style:$textcolor $1");
          }
          if (/colorScheme=(.+).kcsrc/ ) {
            print "\::$textcolor Color Scheme found as $1\n" unless $quite == 1;
            push(@line, " Color Scheme:$textcolor $1");
          }
        }
        if ( $display =~ m/Icons/ ) {
          if ( /Theme=(.+)/ ) {
            print "\::$textcolor Icons found as $1\n" unless $quite == 1;
            push(@line, " Icons:$textcolor $1");
          } 
        }   
        if ( $display =~ m/Font/ ) {
          if ( /font=(.+)/ ) {
            my $font = (split/,/, $1)[0];
            print "\::$textcolor Font found as $font\n" unless $quite == 1;
            push(@line, " Font:$textcolor $font");
          }
        }
      }
      close(FILE);
  
    }
    else {
      my @files = ("$ENV{HOME}/.gtkrc-2.0", "$ENV{HOME}/.gtkrc.mine",);
      foreach my $file (@files) {
        if ( -e $file ) {
          print "\::$textcolor Opening $file\n" unless $quite == 1; 
          open(FILE, $file)
          || die "\e[0;31m<Failed>\n";
          while( <FILE> ) {
            if ( $display =~ m/Theme/ ) {
              if( /include ".*themes\/(.+)\/gtk-(1|2)\.0\/gtkrc"/ ){
                print "\::$textcolor GTK theme found as $1\n" unless $quite == 1;
                push(@line, " GTK Theme:$textcolor $1");
              }
            }
            if ( $display =~ m/Icons/ ) {
              if( /.*gtk-icon-theme-name.*"(.+)"/ ) {
                print "\::$textcolor Icons found as $1\n" unless $quite == 1;
                push(@line, " Icons:$textcolor $1");
              }
            }
            if ( $display =~ m/Font/ ) {
              if( /.*gtk-font-name.*"(.+)"/ ) {
                print "\::$textcolor Font found as $1\n" unless $quite == 1;
                push(@line, " Font:$textcolor $1");
             }
            }
          }
          close(FILE);
        }
      }
    }
  }
}
 
## Display the system info ##
 
if ( $distro =~ m/Archlinux/ ) {
 
## Get Archlinux version ##
if ( $display =~ "OS"){
  print "\::$textcolor Finding Archlinux version\n" unless $quite == 1;
  my $version = $myArchVersion;
  $version =~ s/\s+/ /g;
  $version = " OS:$textcolor $version";
  unshift(@line, "$version");
}
 
my $c1 = "\e[1;36m";
my $c2 = "\e[0;36m";
 
system("clear");
 
print "
${c1}                   -`                   
${c1}                  .o+`                  
${c1}                 `ooo/                  
${c1}                `+oooo:                 
${c1}               `+oooooo:
${c1}               -+oooooo+:
${c1}             `/:-:++oooo+:                       $c1@line[0]
${c1}            `/++++/+++++++:                      $c1@line[1]
${c1}           `/++++++++++++++:                     $c1@line[2]
${c1}          `/+++${c2}ooooooooooooo/`                   $c1@line[3]
${c2}         ./ooosssso++osssssso+`                  $c1@line[4]
${c2}        .oossssso-````/ossssss+`                 $c1@line[5]
${c2}       -osssssso.      :ssssssso.                $c1@line[6]
${c2}      :osssssss/        osssso+++.               $c1@line[7]
${c2}     /ossssssss/        +ssssooo/-               $c1@line[8]
${c2}   `/ossssso+/:-        -:/+osssso+-    
${c2}  `+sso+:-`                 `.-/+oso:   
${c2} `++:.                           `-/+/  
${c2} .`                                  ``
${c2} 
\e[0m";
}
 
system('scrot screen-%H-%M-%S.png -d 5 -q 90 -e \'mv $f ~/pics/Screens/\'');
et les paquets concernant perl:

Code : Tout sélectionner

[wido@desktop ~]$ yaourt -Qs perl
community/lib32-pcre 7.9-1 (lib32)
     A library that implements Perl 5-style regular expressions
core/pcre 7.9-1 (base)
     A library that implements Perl 5-style regular expressions
testing/perl 5.10.1-2 (base)
     Practical Extraction and Report Language
extra/perl-error 0.17015-1 
     Perl/CPAN Error module - Error/exception handling in an OO-ish way
community/perl-json-xs 2.232-1 
     JSON::XS - JSON serialising/deserialising, done correctly and fast
extra/perl-locale-gettext 1.05-4 
     Permits access from Perl to the gettext() family of functions.
community/perl-xml-namespacesupport 1.09-3 
     Generic namespace helpers (ported from SAX2)
community/perl-xml-sax 0.96-1 
     Simple API for XML
extra/perl-xml-simple 2.18-2 
     Simple XML parser for perl
extra/perlxml 2.36-2 
     XML::Parser - an XML parser module for perl
extra/sdl_perl 2.2.2.15-1 
     A Perl wrapper for SDL
Dernière modification par wido le lun. 28 sept. 2009, 20:45, modifié 1 fois.
Image
Avatar de l’utilisateur
chipster
Maître du Kyudo
Messages : 2063
Inscription : ven. 11 août 2006, 22:25
Localisation : Saint-Étienne (42)
Contact :

Re: [info.pl, Perl] souci au lancement (en cours)

Message par chipster »

J'ai repris strictement ton fichier perl et chez moi, aucun soucis particulier.
Ce type d'erreurs apparaît quand un module est installé de manière incomplète. Essaie de réinstaller perl pour voir si il y a une évolution
Avatar de l’utilisateur
Nic0
Chu Ko Nu
Messages : 454
Inscription : dim. 11 janv. 2009, 03:16
Localisation : Calvados (14)

Re: [info.pl, Perl] souci au lancement (en cours)

Message par Nic0 »

Salut,

Pour le script, il fonctionne également chez moi. Je viens de l'essayer en reprenant exactement celui que tu fourni.

Par contre, j'ai une version de perl antérieur à la tienne (tu dois l'avoir pris sur [testing])

Code : Tout sélectionner

core/perl 5.10.0-6 (base)
     Practical Extraction and Report Language
au cas où mes paquets concernant perl :

Code : Tout sélectionner

-10:35- [nicolas@sweet ~] $ yaourt -Qs perl
extra/cairo-perl 1.061-1 
     Perl wrappers for cairo
extra/dvdrip 0.98.10-2 
     A Gtk frontend for transcode writen in Perl
extra/glib-perl 1.222-1 
     Perl wrappers for glib 2.x, including GObject
extra/gtk2-perl 1.221-1 
     Gtk2-Perl allows Perl developers to write GTK+ 2.x applications.
extra/irssi 0.8.14-1 
     Modular text mode IRC client with Perl scripting
extra/pango-perl 1.220-1 
     Perl bindings for Pango
core/pcre 7.9-1 (base)
     A library that implements Perl 5-style regular expressions
core/perl 5.10.0-6 (base)
     Practical Extraction and Report Language
extra/perl-anyevent 5.12-1 
     Perl/CPAN AnyEvent module - Framework for multiple event loops
extra/perl-error 0.17015-1 
     Perl/CPAN Error module - Error/exception handling in an OO-ish way
extra/perl-event 1.12-1 
     Framework for GUI events
extra/perl-event-execflow 0.63-3 
     Framework for perl-events
extra/perl-gtk2-ex-formfactory 0.65-4 
     Framework for perl-gtk2 development
extra/perl-libintl-perl 1.20-1 
     Perl Module: Localization support
extra/perl-locale-gettext 1.05-4 
     Permits access from Perl to the gettext() family of functions.
extra/perl-net-ssleay 1.35-1 
     Perl extension for using OpenSSL
community/perl-time-format 1.09-1 
     Perl/CPAN Module Time::Format : Easytouse datetime formatting
community/perl-xml-libxml 1.69-2 
     Interface to the libxml library
community/perl-xml-libxml-common 0.13-3 
     Routines and Constants common for XML::LibXML and XML::GDOME
community/perl-xml-libxslt 1.68-1 
     Interface to the gnome libxslt library
community/perl-xml-namespacesupport 1.09-3 
     Generic namespace helpers (ported from SAX2)
community/perl-xml-sax 0.96-1 
     Simple API for XML
extra/perl-xml-simple 2.18-2 
     Simple XML parser for perl
extra/perlxml 2.36-2 
     XML::Parser - an XML parser module for perl
~ Yet Another DevOps Blog ~
Avatar de l’utilisateur
tuxce
Maître du Kyudo
Messages : 6677
Inscription : mer. 12 sept. 2007, 16:03

Re: [info.pl, Perl] souci au lancement (en cours)

Message par tuxce »

tu ne l'aurais pas mal copié ?
la ligne 82 dans l'erreur ne correspond pas à la bonne commande (il y a un bout qui manque :))
Avatar de l’utilisateur
wido
Chu Ko Nu
Messages : 497
Inscription : mar. 21 oct. 2008, 20:59

Re: [info.pl, Perl] souci au lancement (en cours)

Message par wido »

oui :shock: , j'ai alors pris celui là en totalité:
http://forums.archlinux.fr/topic2235-40.html

et message d'erreur:

Code : Tout sélectionner

[wido@desktop ~]$ perl /home/wido/Desktop/info.pl
String found where operator expected at /home/wido/Desktop/info.pl line 84, near "case "Openbox""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 99, near "case "Metacity""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 106, near "case "Fluxbox""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 118, near "case "Blackbox""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 130, near "case "Xfwm4""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 142, near "case "Kwin""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 154, near "case "Enlightenment""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 162, near "case "IceWM""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 177, near "case "PekWM""
	(Do you need to predeclare case?)
syntax error at /home/wido/Desktop/info.pl line 83, near ") {"
syntax error at /home/wido/Desktop/info.pl line 99, near "case "Metacity""
syntax error at /home/wido/Desktop/info.pl line 105, near "}"
syntax error at /home/wido/Desktop/info.pl line 117, near "}"
syntax error at /home/wido/Desktop/info.pl line 129, near "}"
syntax error at /home/wido/Desktop/info.pl line 141, near "}"
syntax error at /home/wido/Desktop/info.pl line 153, near "}"
syntax error at /home/wido/Desktop/info.pl line 161, near "}"
syntax error at /home/wido/Desktop/info.pl line 176, near "}"
syntax error at /home/wido/Desktop/info.pl line 188, near "}"
/home/wido/Desktop/info.pl has too many errors.
quelqu'un pourrait mettre son fichier dans pastebin ?
Image
Avatar de l’utilisateur
Skunnyk
Maître du Kyudo
Messages : 1137
Inscription : mer. 06 sept. 2006, 21:31
Localisation : IRC
Contact :

Re: [info.pl, Perl] souci au lancement (en cours)

Message par Skunnyk »

Plop,

Quelqu'un sait d'ou viens ce script à l'origine ? Il n'y a pas de crédits ou autre dans le code
Je vois qu'il est assez obsolete (par exemple il ne detecte pas xfce car il se base encore sur xfce_mcs_manager qui est obsolete depuis la 4.6). Il faudrait par exemple passer par un xfconf-query -c xfwm4 -p /general/theme

Ou alors je l'adapte, ça me fera faire un peu de perl
Avatar de l’utilisateur
tuxce
Maître du Kyudo
Messages : 6677
Inscription : mer. 12 sept. 2007, 16:03

Re: [info.pl, Perl] souci au lancement (en cours)

Message par tuxce »

Avatar de l’utilisateur
wido
Chu Ko Nu
Messages : 497
Inscription : mar. 21 oct. 2008, 20:59

Re: [info.pl, Perl] souci au lancement (en cours)

Message par wido »

Il n'y a que celui là qui fonctionne:
http://screenshotinfograb.googlecode.com/svn/

Code : Tout sélectionner

[wido@desktop Desktop]$ perl /home/wido/Desktop/info.pl
                       __       ___                                 
                      /\ \     /\_ \    __                          
     __     _ __   ___\ \ \___ \//\ \  /\_\    ___   __  __  __  _  
   /'__`\  /\`'__\/'___\ \  _ `\ \ \ \ \/\ \ /' _ `\/\ \/\ \/\ \/'\ 
  /\ \L\.\_\ \ \//\ \__/\ \ \ \ \ \_\ \_\ \ \/\ \/\ \ \ \_\ \/>  </ 
  \ \__/.\_\\ \_\\ \____\\ \_\ \_\/\____\\ \_\ \_\ \_\ \____//\_/\_\
   \/__/\/_/ \/_/ \/____/ \/_/\/_/\/____/ \/_/\/_/\/_/\/___/ \//\/_/
   
      Distro			ArchLinux  ()
      Kernel			2.6.31-ARCH 
      Window Manager		Xfwm4
et si je prends http://bbs.archlinux.org/viewtopic.php? ... 01#p589001

j'ai :

Code : Tout sélectionner

[wido@desktop Desktop]$ perl /home/wido/Desktop/info.pl
String found where operator expected at /home/wido/Desktop/info.pl line 85, near "case "Openbox""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 100, near "case "Metacity""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 107, near "case "Fluxbox""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 119, near "case "Blackbox""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 131, near "case "Xfwm4""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 134, near "case "Xfce4""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 145, near "case "Xfce4.6""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 152, near "case "Kwin""
	(Do you need to predeclare case?)
String found where operator expected at /home/wido/Desktop/info.pl line 164, near "case "Enlightenment""
	(Do you need to predeclare case?)
syntax error at /home/wido/Desktop/info.pl line 84, near ") {"
syntax error at /home/wido/Desktop/info.pl line 100, near "case "Metacity""
syntax error at /home/wido/Desktop/info.pl line 106, near "}"
syntax error at /home/wido/Desktop/info.pl line 118, near "}"
syntax error at /home/wido/Desktop/info.pl line 130, near "}"
syntax error at /home/wido/Desktop/info.pl line 133, near ") {"
syntax error at /home/wido/Desktop/info.pl line 144, near "}"
syntax error at /home/wido/Desktop/info.pl line 149, near "}"
syntax error at /home/wido/Desktop/info.pl line 163, near "}"
syntax error at /home/wido/Desktop/info.pl line 171, near "}"
/home/wido/Desktop/info.pl has too many errors.
Image
Avatar de l’utilisateur
Skunnyk
Maître du Kyudo
Messages : 1137
Inscription : mer. 06 sept. 2006, 21:31
Localisation : IRC
Contact :

Re: [info.pl, Perl] souci au lancement (en cours)

Message par Skunnyk »

Plop,

Bon la version ici : http://bbs.archlinux.org/viewtopic.php? ... 01#p589001 fonctionne bien.

J'en ai fait un paquet sur AUR: http://aur.archlinux.org/packages.php?ID=30517 pour tout ceux qui cherchent ce script. Ça serait bien de le maintenir. Si certains veulent tester, je filerais ensuite le lien sur le bbs.
matrhack
Hankyu
Messages : 28
Inscription : mar. 22 juil. 2008, 14:52

Re: [info.pl, Perl] souci au lancement (en cours)

Message par matrhack »

j'en ai 2 autres qui fonctionnent si ca interesse ..
Script 1

Code : Tout sélectionner

#!/usr/bin/perl
use Switch;
use strict;
use File::Basename;

####################
## Config options ##
####################

## What distro logo to use to use, Available "ArchlinuxNone" ##
my $distro = "Archlinux";
my $myArchVersion = "ArchLinux (Core Dump)";

## what values to display. Use "OS Kernel DE WM win_theme Theme Font Icons" ##
my $display = "OS Kernel DE WM Win_theme Theme Icons Font Background";

## Takes a screen shot if set to 0 ##
my $shot = 1;
## Command to run to take screen shot ##
my $command = "scrot -cd5";

## What colors to use for the variables. ##
my $textcolor = "\e[0m";

## Prints little debugging messages if set to 0 ##
my $quite = 1;



########################
## Script starts here ##
########################
## Define some thing to work with strict ##
my @line = ();
my $found = 0;
my $DE = "NONE";
my $WM = "Beryl";

## Hash of WMs and the process they run ##
my %WMlist = ("Beryl", "beryl",
              "Fluxbox", "fluxbox",
              "Openbox", "openbox",
              "Blackbox", "blackbox",
              "Xfwm4", "xfwm4",
              "Metacity", "metacity",
              "Kwin", "kwin",
              "FVWM", "fvwm",
              "Enlightenment", "enlightenment",
              "IceWM", "icewm",
              "Window Maker", "wmaker",
              "PekWM","pekwm" );

## Hash of DEs and the process they run ##     
my %DElist = ("Gnome", "gnome-session",
              "Xfce4", "xfce-mcs-manage",
              "KDE", "ksmserver");

## Get Kernel version ##
if ( $display =~ "Kernel"){
  print "\::$textcolor Finding Kernel version\n" unless $quite == 1;
  my $kernel = `uname -r`;
  $kernel =~ s/\s+/ /g;
  $kernel = " Kernel:$textcolor $kernel";
  push(@line, "$kernel");
}

## Find running processes ##
print "\::$textcolor Getting processes \n" unless $quite == 1;
my $processes = `ps -A | awk {'print \$4'}`;

## Find DE ##
while( (my $DEname, my $DEprocess) = each(%DElist) ) {
  print "\::$textcolor Testing $DEname process: $DEprocess \n" unless $quite == 1;
  if ( $processes =~ m/$DEprocess/ ) {
    $DE = $DEname;
    print "\::$textcolor DE found as $DE\n" unless $quite == 1;
    if( $display =~ m/DE/ ) {
      push(@line, " DE:$textcolor $DE");
    }
    last;
  }
}

## Find WM ##
while( (my $WMname, my $WMprocess) = each(%WMlist) ) {
print "\::$textcolor Testing $WMname process: $WMprocess \n" unless $quite == 1;
  if ( $processes =~ m/$WMprocess/ ) {
    $WM = $WMname;
    print "\::$textcolor WM found as $WM\n" unless $quite == 1;
    if( $display =~ m/WM/ ) {
      push(@line, " WM:$textcolor $WM");
    }
    last;
  }
}

## Find WM theme ##
if ( $display =~ m/Win_theme/ ){
  switch($WM) {
    case "Openbox" {
      print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
      open(FILE, "$ENV{HOME}/.config/openbox/rc.xml")
      || die "\e[0;31m<Failed>\n";
      while( <FILE> ) {
        if( /<name>(.+)<\/name>/ ) {
          while ( $found == 0 ) {
            print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
            push(@line, " WM Theme:$textcolor $1");
            $found = 1;
          }
        }
      }
      close(FILE);
    }
    case "Metacity" {
      print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
      my $gconf = `gconftool-2 -g /apps/metacity/general/theme`;
      print "\::$textcolor $WM theme found as $gconf\n" unless $quite == 1;
      chomp ($gconf);
      push(@line, " WM Theme:$textcolor $gconf");
    }
    case "Fluxbox" {
      print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
      open(FILE, "$ENV{HOME}/.fluxbox/init")
      || die "\e[0;31m<Failed>\n";
      while( <FILE> ) {
        if( /session.styleFile:.*\/(.+)/ ) {
          print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
          push(@line, " WM Theme:$textcolor $1");
        }
      }
      close(FILE);
    }
    case "Blackbox" {
      print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
      open(FILE, "$ENV{HOME}/.blackboxrc")
      || die "\e[0;31m<Failed>\n";
      while( <FILE> ) {
        if( /session.styleFile:.*\/(.+)/ ) {
          print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
          push(@line, " WM Theme:$textcolor $1");
        }
      }
      close(FILE);
    }
    case "Xfwm4" {
      print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
      open(FILE, "$ENV{HOME}/.config/xfce4/mcs_settings/xfwm4.xml")
      || die "\e[0;31m<Failed>\n";
      while( <FILE> ) {
        if( /<option name="Xfwm\/ThemeName" type="string" value="(.+)"\/>/ ) {
          print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
          push(@line, " WM Theme:$textcolor $1");
        }
  } 
      close(FILE);
    }
    case "Kwin" {
      print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
      open(FILE, "$ENV{HOME}/.kde/share/config/kwinrc")
      || die "\e[0;31m<Failed>\n";
      while( <FILE> ) {
        if( /PluginLib=kwin3_(.+)/ ) {
          print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
          push(@line, " WM Theme:$textcolor $1");
        }
      }
      close(FILE);
    }
    case "Enlightenment" {
      print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
      my $remote = `enlightenment_remote -theme-get theme` ;
      if( $remote =~ m/.*FILE="(.+).edj"/ ) {
        print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
        push(@line, " WM Theme:$textcolor $1");
      }     
    }       
    case "IceWM" { 
      print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
      open(FILE, "$ENV{HOME}/.icewm/theme")
      || die "\e[0;31m<Failed>\n";
      while( <FILE> ) {
        if( /Theme="(.+)\/.*.theme/ ) {
          while( $found == 0 ) {
            print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
            push(@line, " WM Theme:$textcolor $1");
            $found = 1;
          }
        }
      }   
      close(FILE);
    }   
    case "PekWM" {
      print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
      open(FILE, "$ENV{HOME}/.pekwm/config")
      || die "\e[0;31m<Failed>\n";
      while( <FILE> ) {
        if( /Theme.*\/(.*)"/ ) {
            print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
            push(@line, " WM Theme:$textcolor $1");
        }
      }
      close(FILE); 
    } 
  }   
}     
      
## Find Theme Icon and Font ##
if ( $display =~ m/[Theme, Icons, Font, Background]/) {
  switch($DE) {
    case "Gnome" {
      print "\::$textcolor Finding $DE variables\n" unless $quite == 1;
      if ( $display =~ m/Theme/ ) {
        my $gconf = `gconftool-2 -g /desktop/gnome/interface/gtk_theme`;
        chomp ($gconf);
        print "\::$textcolor GTK Theme found as $1\n" unless $quite == 1;
        push(@line, " GTK Theme:$textcolor $gconf");
      }
      if ( $display =~ m/Icons/ ) {
        my $gconf = `gconftool-2 -g /desktop/gnome/interface/icon_theme`;
        chomp ($gconf);
        push(@line, " Icons:$textcolor $gconf");
      } 
      if ( $display =~ m/Font/ ) {
        my $gconf = `gconftool-2 -g /desktop/gnome/interface/font_name`;
        chomp ($gconf);
        push(@line, " Font:$textcolor $gconf");
      }
     if ( $display =~ m/Background/ ) {
        my $gconf = `gconftool-2 -g /desktop/gnome/background/picture_filename`;
        chomp ($gconf);
      my $bname = basename($gconf);
      push(@line, " Background:$textcolor $bname");
      }

    } 
    case "Xfce4" {
      my @sort = ();
      print "\::$textcolor Finding $DE variables\n" unless $quite == 1;
      open(FILE, "$ENV{HOME}/.config/xfce4/mcs_settings/gtk.xml")
      || die "\e[0;31m<Failed>\n";
      while( <FILE> ) {
     if ( $display =~ m/Theme/ ) {
          if (/<option name="Net\/ThemeName" type="string" value="(.+)"\/>/ ) {
            print "\::$textcolor GTK Theme found as $1\n" unless $quite == 1;
            unshift(@sort, " GTK Theme:$textcolor $1");
          } 
        }
        if ( $display =~ m/Icons/ ) {
          if (/<option name="Net\/IconThemeName" type="string" value="(.+)"\/>/ ) {
            print "\::$textcolor Icons found as $1\n" unless $quite == 1;
            unshift(@sort, " Icons:$textcolor $1");
          }
        }
        if ( $display =~ m/Font/ ) {
          if ( /<option name="Gtk\/FontName" type="string" value="(.+)"\/>/ ) {
            print "\::$textcolor Font found as $1\n" unless $quite == 1;
            unshift(@sort, " Font:$textcolor $1");
          } 
        }
      }
      close(FILE);
      ## Sort variables so they're ordered "Theme Icon Font" ##
      foreach my $i (@sort) {
        push(@line, "$i");
      }
    } 
    case "KDE" { 
      print "\::$textcolor Finding $DE variables\n" unless $quite == 1;
      open(FILE, "$ENV{HOME}/.kde/share/config/kdeglobals")
      || die "\e[0;31m<Failed>\n";
      while( <FILE> ) { 
        if ( $display =~ m/Theme/ ) {
          if ( /widgetStyle=(.+)/  ) {
            print "\::$textcolor Wiget Style found as $1\n" unless $quite == 1;
            push(@line, " Wiget Style:$textcolor $1");
          }
          if (/colorScheme=(.+).kcsrc/ ) {
            print "\::$textcolor Color Scheme found as $1\n" unless $quite == 1;
            push(@line, " Color Scheme:$textcolor $1");
          }
        }
        if ( $display =~ m/Icons/ ) {
          if ( /Theme=(.+)/ ) {
            print "\::$textcolor Icons found as $1\n" unless $quite == 1;
            push(@line, " Icons:$textcolor $1");
          } 
        }   
        if ( $display =~ m/Font/ ) {
          if ( /font=(.+)/ ) {
            my $font = (split/,/, $1)[0];
            print "\::$textcolor Font found as $font\n" unless $quite == 1;
            push(@line, " Font:$textcolor $font");
          }
        }
      }
      close(FILE);
  
    }
    else {
      my @files = ("$ENV{HOME}/.gtkrc-2.0", "$ENV{HOME}/.gtkrc.mine",);
      foreach my $file (@files) {
        if ( -e $file ) {
          print "\::$textcolor Opening $file\n" unless $quite == 1; 
          open(FILE, $file)
          || die "\e[0;31m<Failed>\n";
          while( <FILE> ) {
            if ( $display =~ m/Theme/ ) {
              if( /include ".*themes\/(.+)\/gtk-(1|2)\.0\/gtkrc"/ ){
                print "\::$textcolor GTK theme found as $1\n" unless $quite == 1;
                push(@line, " GTK Theme:$textcolor $1");
              }
            }
            if ( $display =~ m/Icons/ ) {
              if( /.*gtk-icon-theme-name.*"(.+)"/ ) {
                print "\::$textcolor Icons found as $1\n" unless $quite == 1;
                push(@line, " Icons:$textcolor $1");
              }
            }
            if ( $display =~ m/Font/ ) {
              if( /.*gtk-font-name.*"(.+)"/ ) {
                print "\::$textcolor Font found as $1\n" unless $quite == 1;
                push(@line, " Font:$textcolor $1");
             }
            }
          }
          close(FILE);
        }
      }
    }
  }
}

## Display the system info ##

if ( $distro =~ m/Archlinux/ ) {

## Get Archlinux version ##
if ( $display =~ "OS"){
  print "\::$textcolor Finding Archlinux version\n" unless $quite == 1;
  my $version = $myArchVersion;
  $version =~ s/\s+/ /g;
  $version = " OS:$textcolor $version";
  unshift(@line, "$version");
}

my $c1 = "\e[0;36m";
my $c2 = "\e[0;34m";

print "$c1
$c1               +             
$c1               #             
$c1              ###               $c2@line[0] 
$c1             #####              $c2@line[1]
$c1             ######             $c2@line[2]
$c1            ; #####;            $c2@line[3]
$c1           +##.#####            $c2@line[4]
$c1          +##########           $c2@line[5]
$c1         #############;         $c2@line[6]       
$c1        ###############+        $c2@line[7] 
$c1       #######   #######        $c2@line[8]
$c1     .######;     ;###;`\".     
$c1    .#######;     ;#####.    
$c1    #########.   .########`     
$c1   ######'           '######   
$c1  ;####                 ####;  
$c1  ##'                     '##  
$c1 #'                         `# 
$c1'                            `
\e[0m";
}


if ( $distro =~ m/None/ ) {
my $color = "\e[0;34m";
  foreach my $filled ( @line ) {
    print "$color $filled\n"
  }
}

#return 0;      
## Run screen shot graper ##
`$command` unless $shot != 0;
script2 partie 1 :

Code : Tout sélectionner

#!/usr/bin/perl
#
# @title : Theme info script 0.1.2 revisited
# @author: rab
# @date  : 08/04/08
# @commnt: Maybe if people quit forking the hell outta this, it would be easier to maintain

## Configurations
# On = 1. Off = 0
my %display = (
                "OS"        => 1, # Displays the operating system's name
                "KL"        => 1, # Displays your kernel version
                "DE"        => 0, # Displays your desktop environment, if you have one
                "WM"        => 1, # Displays your window manager
                "WMT"       => 1, # Displays your window manager's theme
                "IC"        => 1, # Displays your icon theme, if you have one
                "FN"        => 1, # Displays your font 
                "UI"        => 1  # Displays your UI theme
              );

# The command to execute for taking a screenshot
# Escape ' with a backslash, \'
# Leave blank if you don't want a screenshot taken
#my $screenshot = 'scrot screen-%H-%M-%S.png -e \'mv $f ~/media/screens/\'';
my $screenshot = '';

# The Color to use for the variables, needs to be global for logos.pl
@colors = ( "\e[38;0;33m", "\e[38;1;37m", "\e[m" );

# Debugging
my $debug = 1;
## End of configuration

########################
## Script starts here ##
########################
@distros = ();
require '/home/matrhack/logo.pl';

my $nocolor = "\e[0m";
my @info = ();
my ($DE,$WM,$theme,$icon,$font,$cscheme) = "";
my $distro = &distro;

## Hash of WMs and the process they run #
my %WMlist = ("Beryl"           => "beryl",
              "Fluxbox"         => "fluxbox",
              "Openbox"         => "openbox",
              "Blackbox"        => "blackbox",
              "Xfwm4"           => "xfwm4",
              "Metacity"        => "metacity",
              "Kwin"            => "kwin",
              "FVWM"            => "fvwm",
              "Enlightenment"   => "enlightenment",
              "IceWM"           => "icewm",
              "Window Maker"    => "wmaker",
              "Compiz-Fusion"   => "compiz",
              "PekWM"           => "pekwm",
              "Awesome"         => "awesome",
              "Dwm"             => "dwm" );

## Hash of DEs and the process they run ##     
my %DElist = ("Gnome"   => "gnome-session",
              "Xfce4"   => "xfce-mcs-manage",
              "KDE"     => "ksmserver");

## Get Kernel version ##
if( $display{KL} ) {
    print "::$colors[0] Finding Kernel version$nocolor\n" 
        if $debug;

    my $kernel = `uname -r`; $kernel =~ s/\s+/ /g;
    push @info, "$colors[0]Kernel\t\t\t$colors[1]$kernel$nocolor";
}

## Find running processes ##
print "::$colors[0] Getting processes$nocolor\n" 
    if $debug;
my $processes = `ps -A | awk {'print \$4'}`;


## Find a Desktop Environment ##
DESKTOP:
goto WINDOWM if !$display{DE};
while(my($DEname,$DEprocess) = each(%DElist)) {
    next if $processes !~ /$DEprocess/s;

    $DE = $DEname;
    print "::$colors[0] Desktop Environment found as $colors[1]$DEname$nocolor\n" 
        if $debug;
    push @info, "$colors[0]Desktop Environment\t$colors[1]$DEname$nocolor";
    last;
}

## Find a Window Manager ##
WINDOWM:
goto ICON if !$display{WM};
while(my($WMname,$WMprocess) = each(%WMlist)) {
    next if $processes !~ /$WMprocess/sg;

    $WM = $WMname;
    print "::$colors[0] Window Manager found as $colors[1]$WMname$nocolor\n" 
        if $debug;
    push @info, "$colors[0]Window Manager\t\t$colors[1]$WMname$nocolor";
    last;
}

## Find a Window Manager Theme ##
WINDOWMT:
goto ICON if !$display{WMT} || !$display{WM} || $WM eq "";
print "::$colors[0] Finding $WM theme$nocolor\n" 
    if $debug;

$WM eq "Openbox" && do {
    ($theme) = fgrep(["$ENV{HOME}/.config/openbox/rc.xml"], ["<name>(.+?)</name>"]);
    goto ICON;
};

$WM eq "Beryl" && do {
    ($theme) = fgrep(["$ENV{HOME}/.emerald/theme/theme.ini"], ["description=(.*?)$/"]);
    goto ICON;
};

$WM eq "Metacity" && do {
    $theme = `gconftool-2 -g /apps/metacity/general/theme`;
    chomp $theme;
    goto ICON;
};

$WM eq "Fluxbox" && do {
    ($theme) = fgrep(["$ENV{HOME}/.fluxbox/init"], ["session.styleFile:\s*/.*?/(.+?)"]);
    goto ICON;
};

$WM eq "Blackbox" && do {
    ($theme) = fgrep(["$ENV{HOME}/.blackboxrc"], ["session.styleFile:\s*/.*?/(.+?)"]);
    goto ICON;
};

$WM eq "Xfwm4" && do {
    ($theme) = fgrep(["$ENV{HOME}/.config/xfce4/mcs_settings/xfwm4.xml"], ["<option name=\"Xfwm/ThemeName\" type=\"string\" value=\"(.+?)\"/>"]);
    goto ICON;
};

$WM eq "Kwin" && do {
    ($theme) = fgrep(["$ENV{HOME}/.kde/share/config/kwinrc"], ['PluginLib=kwin[34]_(.+?)\s']);
    goto ICON;
};

$WM eq "Enlightenment" && do {
    my $remote = `enlightenment_remote -theme-get theme`;
    ($theme) = $remote =~ /FILE="(.+?)\\.edj"/sg;
    goto ICON;
};

$WM eq "IceWM" && do {
    ($theme) = fgrep(["$ENV{HOME}/.icewm/theme"], ["Theme=\"(.+?)/.*?\\.theme"]);
    goto ICON;
};

$WM eq "PekWM" && do {
    ($theme) = fgrep(["$ENV{HOME}/.pekwm/config"], ["Theme.*?/(.*?)"]);
    goto ICON;
};

$WM eq "Dwm" && do {
    undef $theme; ## Unless you want to grab some values from the binary?
    goto ICON;
};

$WM eq "Awesome" && do {
    undef $theme;
    goto ICON;
};

ICON:
if( $theme ne "" ) {
    print "::$colors[0] $WM Theme found as $colors[1]$theme$nocolor\n" 
        if $debug;
    push @info, "$colors[0]$WM Theme $colors[1]\t\t$theme$nocolor";
}

$DE eq "Gnome" && do {
    $icon = `gconftool-2 -g /desktop/gnome/interface/icon_theme`;
    $font = `gconftool-2 -g /desktop/gnome/interface/font_name`;
    $theme = `gconftool-2 -g /desktop/gnome/interface/gtk_theme`;
    chomp $icon; chomp $font; chomp $theme; 
    goto PRINT;
};

$DE eq "Xfce4" && do {
    ($icon,$font,$theme) = fgrep(["$ENV{HOME}/.config/xfce4/mcs_settings/gtk.xml"],
                             ['<option name="Net/IconThemeName" type="string" value="(.+?)"/>',
                              '<option name="Gtk/FontName" type="string" value="(.+?)"/>',
                              '<option name="Net/ThemeName" type="string" value="(.+?)"/>']);
    goto PRINT;
};

$DE eq "KDE" && do {
    ($theme,$cscheme,$icon,$font) = fgrep(["$ENV{HOME}/.kde/share/config/kdeglobals"],
                                      ['widgetStyle=(.+?)\s',
                                       'colorScheme=(.+?)\.kcsrc\s',
                                       'Theme=(.+?)\s',
                                       'font=(.+?)\s']);
    $font = (split /,/, $font)[0];
    goto PRINT;
};

@vars = fgrep(["$ENV{HOME}/.gtkrc-2.0",
               "$ENV{HOME}/.gtkrc.mine"], 
              ['include ".*?themes/(.+?)/gtk-[12]\.0/gtkrc',
               '.*?gtk-icon-theme-name.*?"(.+?)"',
               '.*?gtk-font-name.*?"(.+?)"']);

$theme = $vars[0] ? $vars[0] : $vars[3] ? $vars[3] : "";
$icon  = $vars[1] ? $vars[1] : $vars[4] ? $vars[4] : "";
$font  = $vars[2] ? $vars[2] : $vars[5] ? $vars[5] : "";

## Lets print this bitch ##
PRINT:
push @info, $colors[0].($DE ? $DE : "GTK")." Theme \t\t$colors[1]".($DE eq "KDE" ? "$theme/$cscheme" : $theme).$nocolor
    if $display{UI} && $theme ne "";

push @info, "$colors[0]Icons\t\t\t$colors[1]$icon$nocolor"
    if $display{IC} && $icon ne "";

push @info, "$colors[0]Font\t\t\t$colors[1]$font$nocolor"
    if $display{FN} && $font ne "";

printf $distro, @info; sleep 3;
exec $screenshot 
    if $screenshot ne "";

sub fgrep(\@\@) {
    my($files,$regexps) = @_;
    my @retvals = ();
    my $slurp = $/; undef $/;

    foreach my $file (@$files) {
        next if !(-e $file);

        open FILE, "<", $file || die "$colors[0]Error opening $colors[1]'$file', $colors[0]$!$nocolor\n";
        $content = <FILE>;
        close FILE;

        foreach my $regexp (@$regexps) {
            my $expg = 0; $expg++ while( $regexp =~ /\(.*?\)/g );
            my @tmp = $content =~ /$regexp/sg;
            push @tmp, "" while( scalar @tmp < $expg );
            @retvals = (@retvals,@tmp);
        }
    }

    $/ = $slurp;
    @retvals;
}

sub distro {
    my $distro = "";
    my $slurp = $/; undef $/;

    foreach $ops (@distros) {
        next if !(-e @$ops[1]);

        $fdistro = $distro = @$ops[0];
        open FILE, "<", @$ops[1] || die "$colors[0]Error opening $colors[1]'@$ops[1]', $colors[0]$!$nocolor\n";
        $content = <FILE>;
        close FILE;
        
        if( defined @$ops[2] ) {
            $content =~ /@$ops[2]/sg;
            $fdistro .= "  ($1)";
        }
        
        chomp $distro; chomp $fdistro;
        last;
    }

    return ""
        if $distro eq "";

    $/ = $slurp; $distro = lc $distro;
    eval "\$distro = \$$distro;";
    push @info, "$colors[0]Distro\t\t\t$colors[1]$fdistro$nocolor";
    $distro;
}
partie 2 :

Code : Tout sélectionner

## Put your distrobutions logos here
#
# Format::
#   For a new distro
#       push @distros, ["DistroShowName", "/path/to/current/version", "Optional regexp to get & append to the DistroShowName"];
#       $distroname = "..distros logo..";
#   
#   The logo variable should be a lower-cased version of the DistroShowName.
#   With in the logo, Please escape unused %.
# 
#


push @distros, ["ArchLinux", "/etc/issue", "Arch Linux \\((.*?)\\)"];
$archlinux = "
$colors[1]
$colors[1]
$colors[1]
$colors[1]                       __       $colors[0]___                                 
$colors[1]                      /\\ \\    $colors[0] /\\_ \\    __                          
$colors[1]     __     _ __   ___\\ \\ \\___ $colors[0]\\//\\ \\  /\\_\\    ___   __  __  __  _  
$colors[1]   /'__`\\  /\\`'__\\/'___\\ \\  _ `\\ $colors[0]\\ \\ \\ \\/\\ \\ /' _ `\\/\\ \\/\\ \\/\\ \\/'\\ 
$colors[1]  /\\ \\L\\.\\_\\ \\ \\//\\ \\__/\\ \\ \\ \\ \\ $colors[0]\\_\\ \\_\\ \\ \\/\\ \\/\\ \\ \\ \\_\\ \\/>  </ 
$colors[1]  \\ \\__/.\\_\\\\ \\_\\\\ \\____\\\\ \\_\\ \\_\\$colors[0]/\\____\\\\ \\_\\ \\_\\ \\_\\ \\____//\\_/\\_\\
$colors[1]   \\/__/\\/_/ \\/_/ \\/____/ \\/_/\\/_/$colors[0]\\/____/ \\/_/\\/_/\\/_/\\/___/ \\//\\/_/
$colors[0]   
$colors[0]      $colors[2]%s
$colors[0]      $colors[2]%s
$colors[0]      $colors[2]%s
$colors[0]      $colors[2]%s     
$colors[0]      $colors[2]%s
$colors[0]      $colors[2]%s
$colors[0]      $colors[2]%s
$colors[0]      $colors[2]%s
$colors[0]      $colors[2]%s
$colors[1]
$colors[1]"
Mon bureau : > ici <
Avatar de l’utilisateur
wido
Chu Ko Nu
Messages : 497
Inscription : mar. 21 oct. 2008, 20:59

Re: [info.pl, Perl] souci au lancement (en cours)

Message par wido »

Le script de Skunnyk fonctionne nickel ainsi que le second script de matrhack mais toujours pas le 1er, c'est peut-être ma version de Xfce4.6.

Voici le résultat du script de skunnyk:

Code : Tout sélectionner

[wido@desktop ~]$ perl /home/wido/Desktop/logos.pl


                   -`                   
                  .o+`                  
                 `ooo/                  
                `+oooo:                 
               `+oooooo:
               -+oooooo+:
             `/:-:++oooo+:                        OS: ArchLinux (Core Dump)
            `/++++/+++++++:                       Kernel: 2.6.31-ARCH 
           `/++++++++++++++:                      DE: Xfce4.6
          `/+++ooooooooooooo/`                    WM: Xfwm4
         ./ooosssso++osssssso+`                   WM Theme: Default
        .oossssso-````/ossssss+`                  GTK Theme: Murrine Human Dark
       -osssssso.      :ssssssso.                 Icons: OxygenRefit2-green-version
      :osssssss/        osssso+++.                Font: Terminal Bold 11
     /ossssssss/        +ssssooo/-                Background: backdrop.list
   `/ossssso+/:-        -:/+osssso+-    
  `+sso+:-`                 `.-/+oso:   
 `++:.                           `-/+/  
 .`                                  ``
 
[wido@desktop ~]$ 
merci :bravo:

EDIT:au passage j'avais aussi downgrader perl mais les messages d'erreur restaient les mêmes.
Image
Avatar de l’utilisateur
Skunnyk
Maître du Kyudo
Messages : 1137
Inscription : mer. 06 sept. 2006, 21:31
Localisation : IRC
Contact :

Re: [info.pl, Perl] souci au lancement (résolu)

Message par Skunnyk »

Et bien, ça en fait des versions !
Le premier script ne fonctionne pas car il n'est pas adapté à xfce4.6 :)
En fait beaucop de monde à touché ce script, donc il y a plein de versions, il faudrait faire un merge de tout ça !
matrhack
Hankyu
Messages : 28
Inscription : mar. 22 juil. 2008, 14:52

Re: [info.pl, Perl] souci au lancement (résolu)

Message par matrhack »

Oui mais j'ai pas le niveau pour recoder / mettre a niveau ce genre de script xD
il est a peine commenté voir pas :/j'en avai 3 autres mais je m'en suis séparé xD
Mon bureau : > ici <
Avatar de l’utilisateur
chipster
Maître du Kyudo
Messages : 2063
Inscription : ven. 11 août 2006, 22:25
Localisation : Saint-Étienne (42)
Contact :

Re: [info.pl, Perl] souci au lancement (résolu)

Message par chipster »

matrhack a écrit :Oui mais j'ai pas le niveau pour recoder / mettre a niveau ce genre de script xD
il est a peine commenté voir pas :/j'en avai 3 autres mais je m'en suis séparé xD
Je veux bien aider sauf que perso chez moi ça fonctionne avec ce que tu as copier coller donc ...
Répondre