You are not logged in.

#1 2008-11-25 09:30:09

Cronanius
Member
From: Alberta Canada
Registered: 2006-07-31
Posts: 15

xfce4 - some trouble doing dynamic background switching with cron

Hi there,
I'm attempting to get my background to change dynamically every 10 minutes or so in xfce4.
After poking around a bit, a buddy wrote up a short perl script for me that should get the job done. However, I'm severely handicapped when it comes to modifying any code that isn't C++. I've also never used a script to modify my system before, and can't find anything useful in the wiki or the bbs to help me understand what exactly I'm doing sad.

However, after some asking around, I've concluded that I need to use crond to run the script at the specified interval (preferably 10 minutes). Is this correct? If so, I have posted the original code below, and my modifications to it below that; if somebody wouldn't mind telling me whether or not they are syntactically correct, I'd be greatly appreciative. The script is supposed to pick a random image file from the specified folder and reload the background with that image.

Lastly, if somebody wouldn't mind explaining how to write up the command for crond, at the least to put it in the hourly folder, I'd be very appreciative, and if somebody wanted to take that a step further and explain how to convince crond to do it every 10 minutes, I'd give you a big e-hug wink.

Thanks guys, here's the code (original):

#!/usr/bin/perl
## Xfce Auto Wallpaper Changer (wrote by s0ulslack)

# where are your wallpapers? (no trailing slash)
$bgs="$ENV{HOME}/.gfx";

my @files = (<$bgs/*>);
my $randf = $files[rand @files];
my $bglist="$ENV{HOME}/.config/xfce4/desktop/backdrops.list";

system("echo '# xfce backdrop list' > $bglist");
system("echo '$randf' >> $bglist");
system("xfdesktop --reload");

And here's my (probably messed up) modification:

#!/usr/bin/perl
## Xfce Auto Wallpaper Changer (wrote by s0ulslack)

# where are your wallpapers? (no trailing slash)
$bgs="/home/harrison/arch/media/other/wallpapers/fixer";

my @files = (<$bgs/*>);
my $randf = $files[rand @files];
my $bglist="/home/harrison/.config/xfce4/desktop/backdrops.list";

system("echo '# xfce backdrop list' > $bglist");
system("echo '$randf' >> $bglist");
system("xfdesktop --reload");

Perpetually an Arch Newbie. I'm here for the operating system, not the philosophy.

Offline

#2 2008-11-25 10:41:05

robmaloy
Member
From: Germany
Registered: 2008-05-14
Posts: 263

Re: xfce4 - some trouble doing dynamic background switching with cron

did you set xfdesktop to use the list?


to have cron execute a command every 10 minutes just put "*/10* in the minutes field in your crontab


edit: dont forget the newline at the bottom of your crontab

my crontab:

 crontab -l
*/2 * * * * /home/rob/scripts/xbg

-> every 2 minutes background is changing

Last edited by robmaloy (2008-11-25 10:46:46)


☃ Snowman ☃

Offline

Board footer

Powered by FluxBB