#!/usr/bin/perl -w # This program edits ~/.icewm/preferences to set a random wallpaper. # It then checks to see if IceWM is running. If it is, it restarts # icewmbg. If it isn't it starts icewm-session. use strict; my $image_directory = "/home/jivy/media/images/wallpaper"; my @image_files = glob "$image_directory/*"; my $wallpaper = $image_files[rand @image_files]; chdir "/home/jivy/.icewm" or die "Cannot change to .icewm: ($!)"; my $pref = "preferences"; my $new_pref = "preferences.tmp"; my $bak = "preferences.bak"; open PREF, "< $pref"; open NEW_PREF, ">> $new_pref"; while () { s#$image_directory/.*#$wallpaper"#; print NEW_PREF $_; } close PREF; close NEW_PREF; rename ($pref,$bak); rename($new_pref,$pref); chdir "/home/jivy" or die "Cannot change to jivy: ($!)"; if (`ps -e | grep icewm-session`) { exec "icewmbg -r"; } else { exec "icewm-session"; }