Retourner au contenu associé (entrée de forum : Gnome 2.6 : rotation de fond d'écran)
Posté par g_remy le 26 août 2004 à 23:00. En réponse au message Gnome 2.6 : rotation de fond d'écran. Évalué à 2.
./change_background.pl 10000 /home/g-remy/Wallpaper
#!/usr/bin/perl -w use strict; use Gtk2 -init; use Gnome2::GConf; die("Usage: ./change_background.pl time wallpapers_path\n") if (scalar(@ARGV) != 2); my $directory = $ARGV[1]; opendir(DIR, $directory) || die "can’t opendir $directory: $!"; my @background = grep { !/^\./ && (/\.png$/ || /\.jpg$/ || /\.bmp$/) } readdir(DIR); closedir DIR; my $client = Gnome2::GConf::Client->get_default; my $key = "/desktop/gnome/background/picture_filename"; my $idx; srand(); sub change_background { $idx = int(rand(scalar(@background))); $client->set($key, { type => 'string', value => $directory."/".$background[$idx] }); print "Changing background to: $background[$idx]\n"; } my $timer= Glib::Timeout->add($ARGV[0] ,\&change_background); Gtk2->main;
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
[^] # Re: En Gtk2 Perl
Posté par g_remy . En réponse au message Gnome 2.6 : rotation de fond d'écran. Évalué à 2.
#!/usr/bin/perl -w use strict; use Gtk2 -init; use Gnome2::GConf; die("Usage: ./change_background.pl time wallpapers_path\n") if (scalar(@ARGV) != 2); my $directory = $ARGV[1]; opendir(DIR, $directory) || die "can’t opendir $directory: $!"; my @background = grep { !/^\./ && (/\.png$/ || /\.jpg$/ || /\.bmp$/) } readdir(DIR); closedir DIR; my $client = Gnome2::GConf::Client->get_default; my $key = "/desktop/gnome/background/picture_filename"; my $idx; srand(); sub change_background { $idx = int(rand(scalar(@background))); $client->set($key, { type => 'string', value => $directory."/".$background[$idx] }); print "Changing background to: $background[$idx]\n"; } my $timer= Glib::Timeout->add($ARGV[0] ,\&change_background); Gtk2->main;