Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
 

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: My  wallpaper changing script!!!!!!, A handy little script< Next Oldest | Next Newest >
King_moo Offline





Group: Members
Posts: 2
Joined: July 2005
Posted: July 24 2005,03:24 QUOTE

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
Back to top
Profile PM 
SaidinUnleashed Offline





Group: Members
Posts: 1428
Joined: Mar. 2004
Posted: July 24 2005,06:30 QUOTE

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


--------------
They say if you play a Microsoft CD backwards, you hear satanic messages. That's nothing, cause if you play it forwards, it installs Windows.

Unleash the power of the TILDE~~~
Back to top
Profile PM AOL MSN YIM 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: July 24 2005,18:38 QUOTE

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.


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
King_moo Offline





Group: Members
Posts: 2
Joined: July 2005
Posted: July 24 2005,19:35 QUOTE

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
Back to top
Profile PM 
SaidinUnleashed Offline





Group: Members
Posts: 1428
Joined: Mar. 2004
Posted: July 24 2005,20:09 QUOTE

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.


--------------
They say if you play a Microsoft CD backwards, you hear satanic messages. That's nothing, cause if you play it forwards, it installs Windows.

Unleash the power of the TILDE~~~
Back to top
Profile PM AOL MSN YIM 
4 replies since July 24 2005,03:24 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

 
reply to topic new topic new poll
Quick Reply: My  wallpaper changing script!!!!!!

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code