Last active
February 13, 2022 19:52
-
-
Save ablakely/1d9b37257d0a508cf63c35a0749d3d23 to your computer and use it in GitHub Desktop.
Wallpaper Rotation Script for Elementary OS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
# changebg.pl: Wallpaper rotation script for ElementaryOS | |
# | |
# Tested on | |
# ElementaryOS v5.1.2 | |
# | |
# Written by Aaron Blakely <[email protected]> | |
# Copyright 2020 (C) Ephasic Software | |
use strict; | |
use warnings; | |
my $WPDIR = "~/Documents/Wallpapers"; | |
my $SLEEPTIME = 30; #in seconds | |
# resolve ~ | |
if ($^O eq "linux") { | |
my $whoami = `whoami`; chomp $whoami; | |
$WPDIR =~ s/\~/\/home\/$whoami/; | |
} | |
sub getWPList { | |
my @wallpapers; | |
opendir(WPS, $WPDIR) or die $!; | |
while (my $file = readdir(WPS)) { | |
if ($file =~ /\.png$/ || $file =~ /\.jpg$/) { | |
print "Found WP: $file\n"; | |
push(@wallpapers, $WPDIR."/".$file); | |
} | |
} | |
closedir(WPS); | |
return @wallpapers; | |
} | |
while (1) { | |
my @wps = getWPList(); | |
my $newwp = $wps[int(rand($#wps))]; | |
print "Changing background to: $newwp\n"; | |
system "gsettings set org.gnome.desktop.background picture-uri file://$newwp"; | |
print "Sleeping for $SLEEPTIME seconds\n"; | |
sleep($SLEEPTIME); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment