Advertisement
hackloper775

autofeh

Jun 8th, 2013
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.65 KB | None | 0 0
  1. #!/usr/bin/env perl
  2.  
  3. use feature qw { switch };
  4.  
  5. my $user = getlogin();  
  6.  
  7. my $folder = "/Imagenes/" ;# El folder de tus imagenes(no es necesario poner tu nombre de usuario)
  8.  
  9. my $dir = "/home/" . $user . $folder;
  10.  
  11. my (@archivos,@imagenes) = ((),());
  12.  
  13. my $time = 60; # Tiempo entre cada wallpaper
  14.  
  15. =pod
  16. Eso es todo ahora entra en accion el script
  17. Para saber como funciona date una vuelta por los tutoriales de Tiempo de Tux sobre perl
  18. http://www.itimetux.com
  19. =cut
  20.  
  21. opendir(my $recorrer, $dir) || die "Error :( $! \n";  
  22.  
  23. while(readdir $recorrer)  {  
  24.    if (-f $dir . "/" . $_) {
  25.      push (@archivos,$_);  
  26.    }  
  27. }
  28.  
  29. closedir $recorrer;  
  30.  
  31. if (scalar(@archivos) == 0 ) {
  32. print "No se encontraron archivos en $dir\n";
  33. exit;
  34. }
  35.  
  36. foreach my $files(@archivos) {
  37.    given ($files) {
  38.       when(/.*jpeg/)
  39.       {
  40.           push (@imagenes,$files);  
  41.       }
  42.       when(/.*png/)
  43.       {
  44.           push (@imagenes,$files);  
  45.       }
  46.       when(/.*jpg/)
  47.       {
  48.           push (@imagenes,$files);  
  49.       }
  50.       default
  51.       {
  52.           undef;
  53.       }
  54.    }
  55. }
  56.  
  57. if (scalar(@imagenes) > 1 ) {
  58.     while (1) {
  59.         foreach my $files(sort(@imagenes)) {
  60.             #print "$files\n"; # Para desarrollo
  61.            `feh --bg-scale "$dir$files"`;
  62.             sleep($time);
  63.         }
  64.     }
  65. }
  66. else {
  67.     print "No se encontraron imagenes en $dir\n";
  68. }
  69.  
  70. =head LICENSE
  71.  
  72. This library is free software; you can redistribute it and/or modify it under
  73. the terms of the GNU Library General Public License as published by the Free
  74. Software Foundation; either version 2.1 of the License, or (at your option) any
  75. later version.
  76.  
  77. =cut
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement