DSL Ideas and Suggestions :: My  wallpaper changing script!!!!!!



I made this script to make it more easy to change the wallpaper.

You cant get it HERE

to use it just cd to the one its in and type ./bg-script

-King_moo

here is the text of the script, for whrn geocities dies on him.

Code Sample
#!/bin/sh
#script by Zak Tarbet
clear
echo "=========================="
echo "= DSL bg changing script ="
echo "==========1.0============="
echo
echo "========"
echo "= Menu ="
echo "==================="
echo "= 1- Specify file ="
echo "= 2- Quit         ="
echo "==================="
read slct
if [ "$slct" = "1" ]; then
echo "What is the bg location? (i.e. /home/dsl/Wallpaper/myfile.jpg)"
read paper2
bsetbg -f $paper2
fi
if [ "$slct" = "2" ]; then
bash
fi

s'ok for suggestions?  I wish more people would criticize my scripts :D

You have a lot of extra bytes that aren't needed.  Rather than putting an echo command on every line, you could do one echo, adding linebreaks within the quotes:
echo "==========================
= DSL bg changing script =
==========1.0=============

========
= Menu =
===================
= 1- Specify file =
= 2- Quit         =
==================="

Another way is by using cat instead of echo:
cat << EOF
==========================
= DSL bg changing script =
==========1.0=============

========
= Menu =
===================
= 1- Specify file =
= 2- Quit         =
===================
EOF

Second, the check for '2' isn't really necessary.  You could do something like this to save some bytes:
if [ "$slct" = "1" ]; then
echo "What is the bg location? (i.e. /home/dsl/Wallpaper/myfile.jpg)"
read paper2
bsetbg -f $paper2
else bash
fi

But for multiple choice input, I've always preferred case:
case $slct in
1) echo "What is the bg location? (i.e. /home/dsl/Wallpaper/myfile.jpg)"
read paper2
bsetbg -f $paper2;;
*) bash;;
esac

One more thing...
If you launch bash from a shell, you are starting a second shell.  This is no problem if you start a script in an x shell and want to keep the window open after you choose "2", but if you are already in a shell and you start the script directly, you'll end up in a second shell.  Not a big deal, but personally i'd find it annoying to have to exit twice to leave the original shell.

Thanks for the advise, I only really started trying to program in linux. I made the unfortunate mistake of learning four Windows programming languages, none of wich are portable. Now I cant stand Windows and trying my hand in linux. So I still have lots to learn.  :D
If you are wanting easily portable code, learn a standard language, like C or C++.

Python, perl, and lua are well known interpreted languages, and would be good to know too.

Next Page...
original here.