File: gbackgroundD

package info (click to toggle)
gbackground 1.0-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 124 kB
  • ctags: 22
  • sloc: perl: 118; makefile: 42
file content (43 lines) | stat: -rwxr-xr-x 985 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/perl
use strict;
use Proc::PID::File;

my($fondo_path, $segundos ,@archivos_png, @archivos_jpg, @TODOS_ARCHIVOS, $background, $configurando_pid);
my $home_directory = $ENV{HOME};
my $parte_del_path = "/.gbackground";
my $path = $home_directory . $parte_del_path;

sub crear_demonio {
	$configurando_pid = Proc::PID::File->running(dir => "$path", name => "gbackground" );
	while(1){
		system("gconftool-2 -t str -s /desktop/gnome/background/picture_options stretched");
		$background = $TODOS_ARCHIVOS[rand(scalar(@TODOS_ARCHIVOS))];
		system("gconftool-2 -t str -s /desktop/gnome/background/picture_filename $background");
		sleep($segundos);
	}
}

$fondo_path = $ARGV[0];
$segundos = $ARGV[1];


foreach (@archivos_jpg = glob("$fondo_path/*\.jpg")){
push @TODOS_ARCHIVOS, $_;
}

foreach (@archivos_png = glob("$fondo_path/*\.png")) {
push @TODOS_ARCHIVOS, $_;
}


if(-e "$path"){
	&crear_demonio;
}
else{
	mkdir("$path", 0777);
	chmod(0777, "$path");
	&crear_demonio;
}