Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use File::Basename;
- ### Whoever takes this:
- # If this is being run by cron, be sure to set dbus and display settings.
- # I just saved you research time.
- my $directory = '/path/to/wallpapers';
- my @walls;
- my $current_wall = `gsettings get org.cinnamon.desktop.background picture-uri`;
- chomp $current_wall;
- $current_wall =~ s/\'//g;
- $current_wall = basename($current_wall);
- opendir (DIR, $directory) or die $!;
- while(my $file = readdir(DIR)){
- next if($file =~ m/^\./); #ignore . & ..
- next if($file !~ m/\.(png|jpe?g)/);
- next if($file eq $current_wall);
- push @walls, $file;
- }
- my $new_wall_path = "'" . "file://" . $directory . $walls[int(rand(scalar(@walls)))] . "'";
- `gsettings set org.gnome.desktop.background picture-uri $new_wall_path`
- #print $new_wall_path;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement