De acordo com as Leis 12.965/2014 e 13.709/2018, que regulam o uso da Internet e o tratamento de dados pessoais no Brasil, ao me inscrever na newsletter do portal DICAS-L, autorizo o envio de notificações por e-mail ou outros meios e declaro estar ciente e concordar com seus Termos de Uso e Política de Privacidade.
Colaboração: Jansen Carlo Sena
Data de Publicação: 09 de Janeiro de 2002
O Jansen me enviou um script em perl, que pode ser incluído no arquivo bash_profile do diretório de trabalho de um usuário para alternar aleatoriamente o papel de parede sempre que se usar o ambiente Gnome.
O script em perl encontra-se a seguir:
#!/usr/bin/perl # # Copyright 2001 Jansen Sena # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # -------------------------------------------------------------------------------- # # Este script é utilizado para alternar os papéis de parede utilizados pelo Gnome # Sua execução pode ser feita a partir do arquivo .profile fazendo com que todas # as vezes que um usuário entre no Gnome, um novo papel de parede, escolhido # aleatoriamente, seja configurado. # # -------------------------------------------------------------------------------- # # $User_home = $ENV{'HOME'}; $Gnome_directory = $User_home . "/.gnome"; $Gnome_background_file = $Gnome_directory . "/Background"; $Figures_directory = $User_home . "/wallpapers"; # # Parameters evaluation # if (($#ARGV + 1) > 2 || ($#ARGV + 1) == 1) { print "Parameters number invalid. Use ./wallpapers -d <wallpapers directory>\n"; exit 1; } elsif ((($#ARGV + 1) == 2) && ($ARGV[0] ne "-d")) { print "Invalid parameter $ARGV[0]. Use ./wallpapers -d <wallpapers directory>\n"; exit 1; } elsif ((($#ARGV + 1) == 2) && (! -e $ARGV[1])) { print "Directory $ARGV[1] no exists\n"; exit 1; } elsif (($#ARGV + 1) == 2) { $Figures_directory = $ARGV[1]; } # # Verify the files in figures directory # opendir(DIR,$Figures_directory) || die "Can't open $Figures_directory directory: $!\n"; @Figure_files = readdir(DIR); closedir(DIR); $No_figure_files = @Figure_files; if ($No_figure_files == 2){ print "The directory of wallpapers $ARGV[1] is empty\n"; exit 1; } # # Verify the gnome directory and background file # if (! -e $Gnome_directory) { print "Gnome directory is not present in your homedir\n"; exit 1; } if (! -e $Gnome_background_file) { print "Gnome background file is not present in $Gnome_directory directory\n"; exit 1; } # # open(FILE,"+<$Gnome_background_file") || die "Can't open $Gnome_background_file: $!\n"; @Temp_file = <FILE>; close(FILE); $Count = -1; do { $Count++; ($Field,$Value) = split(/=/,$Temp_file[$Count]); } until ($Field eq "wallpaper"); # # Generate a random new wallpaper # srand(time|$$); $Index = 0; while ($Index == 0 || $Index == 1) { # Evita a seleção dos diretórios "." e ".." $Index = int(rand $No_figure_files); } $Value = $Figures_directory . "/" . $Figure_files[$Index] . "\n"; $Temp_file[$Count] = join('=',$Field,$Value); # # Save Background file with the new random wallpaper # open(FILE,">$Gnome_background_file"); print FILE @Temp_file; close(FILE); exit 0; # # # End of script
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Comentários