You are not logged in.

#1 2007-11-26 18:55:47

F
Member
Registered: 2006-10-09
Posts: 322

Perl wallpaper changer

Hi, I wanted a script that changes my wallpaper randomly, here it is in Perl. I have this run every 30 minutes with a cron job. Kind of nice since I have so many wallpapers but never really use any of them.

#!/usr/bin/perl -w
#randomly change my wallpaper.
#by F. 

use warnings;
use strict;

opendir(DIR, "/path/to/wallpaper/directory") || die "can't open directory: $!";
my @files = grep { $_ ne '.' and $_ ne '..' } readdir(DIR);
closedir DIR;

# perldoc -q "random element"
my $chosenwp = $files[rand @files];

#print "chosen wallpaper is: $chosenwp\n";
system("feh --bg-scale /path/to/wallpaper/directory/$chosenwp");

If anyone can play golf on this please let me know!

Offline

#2 2007-11-26 19:20:09

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: Perl wallpaper changer

f, you may wanna check out the wallapaper changer on xterminus' site.  ive never used it but from what ive read about it it is very feature rich. maybe you can pop some ideas off his project as well.


archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

Board footer

Powered by FluxBB