in reply to Re: Random Desktop Background for IceWM
in thread Random Desktop Background for IceWM
Thank you for taking the time to reply and suggest improvements. Taking them in order:
I have been trying to remember to use single quotes but I keep forgetting. I will keep working on that.
If I understand you right, I should do something like this:
Meaning that I don't use specific close PREF and close NEW_PREF commands.my $pref = "preferences"; my $new_pref = "preferences.tmp"; my $bak = "preferences.bak"; { my $pref = "preferences"; my $new_pref = "preferences.tmp"; my $bak = "preferences.bak"; open PREF, "< $pref"; open NEW_PREF, ">> $new_pref"; while (<PREF>) { s#$image_directory/.*#$wallpaper"#; print 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"; }
I had not seen the three-argument form of open but I looked it up after reading your post. That makes sense.
There is no extra tmp file hanging around. It is renamed to preferences in line 35. But I will do the suggested research for future use.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Random Desktop Background for IceWM
by CountZero (Bishop) on Apr 07, 2009 at 05:58 UTC | |
by Texadan (Monk) on Apr 07, 2009 at 19:00 UTC | |
by wazoox (Prior) on Apr 07, 2009 at 19:51 UTC | |
by Texadan (Monk) on Apr 08, 2009 at 03:10 UTC |