Pages : 1
#1 Le 03/06/2006, à 06:56
- phoenix818
[LTS] Usplash - script perl
Hello!
aimant bien customiser mon ordi dans tous les sens, je me suis amusé à reprendre les différentes commandes présentes sur https://wiki.ubuntu.com/USplashCustomizationHowto et en ai fait un petit script perl bien cool.
Je me permets de vous le soumettre:
#!/usr/bin/perl
use strict;
use Getopt::Std;
use Getopt::Long;
#####################
# We have to give a #
# picture in input. #
# We have to give #
# an output name. #
#####################
my %iName=();
my %oName=();
my $verbose = '';
GetOptions('i:s' => \$iName{0},
'o:s' => \$oName{0},
'v|verbose' => \$verbose);
my $display='2>/dev/null 1>/dev/null';
if ($verbose) {
$display='';
}
my $img = `file $iName{0}`;
print "$img\n";
$img =~ / ((?:\d){1,4}) x ((?:\d){1,4}).{2}(\d){1,2}-bit/i;
if($1 > 640 || $2 > 400 || $3 >4) {
die "\nYour image must be 640x400px!\n\n";
}
if(( $iName{0}=~ /.+/) && ( $oName{0}=~ /.+/)) {
print "Copying your image to usplash-artwork.png: ";
system ("cp -v $iName{0} usplash-artwork.png $display")==0
or die "\nUnable to copy file. Be sure you have correct rights!\n\n";
print "done.\n";
print "Generating usplash-artwork.c: ";
system ("pngtobogl usplash-artwork.png > usplash-artwork.c")==0
or die "\nUnable to generate file. Reason: $! \n\n";
print "done.\n";
print "Generating usplash-artwork.o: ";
system("gcc -Os -g -I/usr/include/bogl -fPIC -c usplash-artwork.c -o usplash-artwork.o")==0
or die "\nUnable to generate file. Reason: $! \n\n";
print "done.\n";
print "Generatinf $oName{0}.so file: ";
system("gcc -shared -Wl,-soname,usplash-artwork.so usplash-artwork.o -o $oName{0}.so")==0
or die "\nUnable to generate file. Reason: $! \n\n";
print "done.\n";
if( ! -e "/usr/local/lib/usplash/") {
print "Creating /usr/local/lib/usplash/: ";
system("sudo mkdir -p /usr/local/lib/usplash/ $display")==0
or die "\nUnable to create: /usr/local/lib/usplash/. Reason: $! \n\n";
print "done.\n";
}
print "Copying your image: ";
system("sudo cp -iv $oName{0}.so /usr/local/lib/usplash/ $display")==0
or die "\nUnable to copy $oName{0}.so to /usr/local/lib/usplash/\n\n";
print "done.\n";
print "Updating configuration: ";
system("sudo update-alternatives --install /usr/lib/usplash/usplash-artwork.so usplash-artwork.so /usr/local/lib/usplash/$oName{0}.so 55 $display")==0
or die "\nUnable to update configuration!\n\n";
my @tmp = </usr/local/lib/usplash/*.so>;
if(($#tmp+1)>1) {
print "Please choose your usplash file in list below:\n";
system("sudo update-alternatives --config usplash-artwork.so")==0
or die "\nFatal Error!\n\n";
}
print "Removing files : ";
system("rm usplash*")==0
or die "\nUnable to remove files ! Please do it by yourself\n\n";
print "Upgrading all the stuff: ";
system("sudo dpkg-reconfigure linux-image-$(uname -r) $display")==0
or die "\nUnable to update your configuration!\n\n";
print "done.\nYou can reboot your system to check if all is as you expected!\n\n";
} else {
print "\nUsage:\n splashGen -i <input image> -o <output name> [v]\n\n";
}
Si vous avez des soucis d'utilisation, ou des idées pour le rendre plus "convivial" ou autres.... bin hésitez surtout pas!
je m'amuse avec perl de temps en temps pour... bin pour m'amuser
@@++
PS: une section "scripts purs" pourrait être intéressante, parce que y a pas que les menus clicables, dans Linux
Serveur: http://voltaic.is-a-geek.org
Site: http://www.phoenix818.ch
Hors ligne
Pages : 1