My wallpaper changing script!!!!!!Forum: DSL Ideas and Suggestions Topic: My wallpaper changing script!!!!!! started by: King_moo Posted by King_moo on July 24 2005,03:24
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 Posted by SaidinUnleashed on July 24 2005,06:30
here is the text of the script, for whrn geocities dies on him.
Posted by mikshaw on July 24 2005,18:38
s'ok for suggestions? I wish more people would criticize my scripts 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. Posted by King_moo on July 24 2005,19:35
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.
Posted by SaidinUnleashed on July 24 2005,20:09
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. |