I'm developing a script that chooses a random wallpaper on bootup for puppy linux.
I change the wallpaper by inserting the path and filename of the picture into the puppypin file. This works very nicely most of the time but I have noticed that if there is an '&' character in the filename then disaster will strike and your entire desktop will be whisked into the void and you will see it no more.
I have got around this problem by ignoring all such files but I would like to know what other characters are not supported in the puppypin file but which are allowed in filenames.
Any ideas?
Thanks...
Random wallpaper script
Any forbidden Bash characters I`d think. "&, #, |, [, ], {, }, (, ), <, >, *, $, @, `, /, \"
You know... Most of them! . ; )
You could remove the characters from the file names before using them.
This removes most of them, "/" doesn`t need to be included of course.
You can try others by adding them and test it to see if it works.
You know... Most of them! . ; )
You could remove the characters from the file names before using them.
This removes most of them, "/" doesn`t need to be included of course.
Code: Select all
NewName=`echo "FileName | sed 's#[\#\$\&\*\:\;\=\(\)\{\}\[\]\|\\<\>]##g'`
Hello,
Could you call them as variables?
Something like:
for i in `cat /usr/share/backgrounds`
do
a=$i
cp $a /usr/share/backgrounds/default
done
Set up a counter to prevent repeating, and set the default randomly each time...
Just a thought...
Could you call them as variables?
Something like:
for i in `cat /usr/share/backgrounds`
do
a=$i
cp $a /usr/share/backgrounds/default
done
Set up a counter to prevent repeating, and set the default randomly each time...
Just a thought...
Close the Windows, and open your eyes, to a whole new world
I am Lead Dog of the
Puppy Linux Users Group on Facebook
Join us!
Puppy since 2.15CE...
I am Lead Dog of the
Puppy Linux Users Group on Facebook
Join us!
Puppy since 2.15CE...
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
here is a stub that can be use to randomize any passed parameters
just modify the sleep value and pipe it to a program that accepts pipes or use VAR=`eval echo \${$NEWVALUE}` to store the random arg
notes
while ([ ! $EXIT ]) do <<<just a random variable it could have been anything, but I don't like to use true, because it can hog cpu
while ([ $NEWVALUE -eq $OLDVALUE ]) do << b/c we don't want the same thing twice in a row, even if it _is_ random (just remove this loop except for the random value part if this is ok)
$((integer math here))
$RANDOM generates a random number
% give the modulus (integer remainder on N%M yeilds integer values of 0 to M-1)
......we have to add 1 because $0 is the command name
eval echo \${$NEWVALUE} <<< because I don't know a better way to do this in standard shell (bash has redirection using ! but it is not portable)
just modify the sleep value and pipe it to a program that accepts pipes or use VAR=`eval echo \${$NEWVALUE}` to store the random arg
Code: Select all
#!/bin/sh
NEWVALUE=1
while ([ ! $EXIT ]) do
OLDVALUE=$NEWVALUE
while ([ $NEWVALUE -eq $OLDVALUE ]) do
NEWVALUE=$(($(($RANDOM%$#))+1))
done
eval echo \${$NEWVALUE}
sleep 1
done
while ([ ! $EXIT ]) do <<<just a random variable it could have been anything, but I don't like to use true, because it can hog cpu
while ([ $NEWVALUE -eq $OLDVALUE ]) do << b/c we don't want the same thing twice in a row, even if it _is_ random (just remove this loop except for the random value part if this is ok)
$((integer math here))
$RANDOM generates a random number
% give the modulus (integer remainder on N%M yeilds integer values of 0 to M-1)
......we have to add 1 because $0 is the command name
eval echo \${$NEWVALUE} <<< because I don't know a better way to do this in standard shell (bash has redirection using ! but it is not portable)
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
Thanks for all the replies, some pretty interesting stuff there.
puppyluvr you've jogged my mind into thinking of a really simple solution which is just to copy the file to a different filename - say 'wallpaper' in the same directory and have that in the puppypin file. Then there are no more filename restrictions (apart from those on the filenames themselves)
Thank you very much...
puppyluvr you've jogged my mind into thinking of a really simple solution which is just to copy the file to a different filename - say 'wallpaper' in the same directory and have that in the puppypin file. Then there are no more filename restrictions (apart from those on the filenames themselves)
Thank you very much...