maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Newbie (https://talk.maemo.org/forumdisplay.php?f=26)
-   -   Newbie: How do I code/write scripts? (https://talk.maemo.org/showthread.php?t=27307)

Palmleavr 2009-03-05 17:10

Newbie: How do I code/write scripts?
 
Hi,
I'm trying to execute the suggestions by more senior members in order to install/use multiple GVM installations* on my n810 and also to set up shortcuts to launch individual Palm apps. I'd also like to do a script to set the Hotsync ID (since it often gets lost after a Hotsync).

My question:
What script editor would people recommend? How should line breaks be set?

I have TextWrangler (donateware) on my Powerbook G4 and it has worked well with Supermemo files, but it gives 3 options for line breaks: CR (Mac), LF (Unix) and CRLF (Windows). I assume LF would be the correct choice for scripts in Maemo.

I've also read that some people use nano to edit--what's that? Another poster mentioned vim. My Application Manager says that I have vim installed, but I can't find an icon to launch it in the launch menu.

[If I understand the procedure:
1. I should create the script file and save it as a *.sh file where "*" is, of course, the name of your file.
2. copy the *.sh file to the /home/user folder
3. become root, i.e.: sudo gainroot [with Becomeroot, rootSH or OpenSSH installed]
4. change to the correct directory with: cd /home/user
5. execute a command to change the *.sh files to *.desktop files: chmod +x *.sh
6. copy the new *.desktop file to the "Extra's" directory: copy to /usr/share/applications/hildon
7. Use Control Panel-->Panels-->Organize to move the application to the panel of my choice

For one-line scripts, I've found options listed by bunanson here:

http://www.internettablettalk.com/fo...9&postcount=10

Both bunanson and Mara have posted directions for saving scripts as applications. Mara's are here:

http://www.internettablettalk.com/fo...0&postcount=12

For creating multiple GVM installations, I found burmashave's code here:

http://www.internettablettalk.com/fo...ad.php?t=15518

TA-t3's instructions for launching individual Palm apps (bypassing the GVM launcher) via shortcuts:

http://www.internettablettalk.com/fo...ad.php?t=12297

Thanks!]

jmjanzen 2009-03-05 18:29

Re: Newbie: How do I code/write scripts?
 
it looks like you've figured out many pieces to this puzzle, but you're missing a few that i can offer:

".desktop" files are not scripts. they're shortcuts to scripts/programs. the format of these files is explained in the wiki.
"chmod +x" merely makes a script file executable. it's a necessary step, but it won't change your .sh file into a .desktop file. you don't want to do that anyway. you just want to create a .desktop file that links/points to your .sh/script file.

oh, and as far as text editors go, i use the one that's built into emelfm2. then again, i don't do much scripting.... you should download emelfm2 regardless. it's the best file manager out there. very powerful, once you figure out what each button does.

pelago 2009-03-05 18:34

Re: Newbie: How do I code/write scripts?
 
nano and vim and text mode (X-Terminal) editors. You probably would prefer a graphical mode one while starting out. Leafpad might be a good choice.

nhanquy 2009-03-05 18:41

Re: Newbie: How do I code/write scripts?
 
Quote:

Originally Posted by Palmleavr (Post 269175)

My question:
What script editor would people recommend? How should line breaks be set?

....

1. I assume LF would be the correct choice for scripts in Maemo.

....

2. My Application Manager says that I have vim installed, but I can't find an icon to launch it in the launch menu.

1. Correct. LF is used for unix text files.

2. vim is invoked by using in a command line. (vim is a vi editor compatible.)
You have to go to a xterm and type: vim <filename>

Google "vi commands" and test vim out!

Palmleavr 2009-03-06 17:41

Re: Newbie: How do I code/write scripts?
 
jmjanzen, pelago, nhanquy, thank you!

I will try the script + shortcut thing soon, but I have another question:

I looked at the format of the .desktop file in the wiki and saw nothing about the icon. Is there a way to assign a user-defined icon to each script shortcut?


All times are GMT. The time now is 09:25.

vBulletin® Version 3.8.8