maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Maemo 5 / Fremantle (https://talk.maemo.org/forumdisplay.php?f=40)
-   -   Launching multiple websites/programs using terminal? (https://talk.maemo.org/showthread.php?t=69435)

sevep 2011-02-06 18:55

Launching multiple websites/programs using terminal?
 
Is there an equivalent to batch files in Linux? I want to be able to create an executable file which starts MicroB and then launches multiple websites from a single desktop widget. Can this be done on the N900?
Thanks.

amandalam 2011-02-06 19:29

Re: Launching multiple websites/programs using terminal?
 
You may try to do this in your shell script file, say, myScript...

Code:

/usr/bin/browser --url=http://google.com/ &
/usr/bin/browser --url=http://facebook.com/ &
/usr/bin/browser --url=http://yahoo.com/ &

As you can see, the key to run different instances of programs simultaneously is to put the "&" character at the end.

Now, set your file to be executable...

Code:

chmod +x myScript
and run it this way...

Code:

./myScript
There is a side-effect, though --- the Bookmarks page always displays first. I'm not sure how to get rid of it....:rolleyes:

Char 2011-02-06 19:45

Re: Launching multiple websites/programs using terminal?
 
Quote:

Originally Posted by amandalam (Post 937591)
There is a side-effect, though --- the Bookmarks page always displays first. I'm not sure how to get rid of it....:rolleyes:

Code:

dbus-send --system --type=method_call --dest=com.nokia.osso_browser /com/nokia/osso_browser/request com.nokia.osso_browser.load_url string:"google.com" &
dbus-send --system --type=method_call --dest=com.nokia.osso_browser /com/nokia/osso_browser/request com.nokia.osso_browser.load_url string:"yahoo.com" &
dbus-send --system --type=method_call --dest=com.nokia.osso_browser /com/nokia/osso_browser/request com.nokia.osso_browser.load_url string:"facebook.com"


Copernicus 2011-02-06 19:58

Re: Launching multiple websites/programs using terminal?
 
Quote:

Originally Posted by amandalam (Post 937591)
There is a side-effect, though --- the Bookmarks page always displays first. I'm not sure how to get rid of it....:rolleyes:

As it turns out, Firefox Mobile will (unless you specify otherwise) open new tabs in a running copy of the browser rather than create new instances of the browser. So,

Code:

/usr/bin/fennec http://google.com &
/usr/bin/fennec http://facebook.com &

brings up one browser window with two tabs. Pretty cool. :)

sevep 2011-02-06 23:17

Re: Launching multiple websites/programs using terminal?
 
Thanks for that, I've tried both MicroB suggestions and will try out FF later.
I'm not very good at this so could someone run by me again how to make this executable so it will work with a Queen BeeCon shortcut on the desktop.
Also can anyone tell me the command to start the stock RSS reader too please?
Thanks again:D

Copernicus 2011-02-07 01:02

Re: Launching multiple websites/programs using terminal?
 
Quote:

Originally Posted by sevep (Post 937770)
could someone run by me again how to make this executable so it will work with a Queen BeeCon shortcut on the desktop.

Hmm, I've actually not used Queen BeeCon before (I'm an n900 newbie), but I can tell you how to make an executable shell script.

First, you need a shell script. I played around a bit with Firefox, and discovered that if you don't already have it running, you need to give it a few seconds to start up before you start cramming additional websites down its throat. :) So, I added a "sleep" command to create a pause between requests to execute fennec:

Code:

/usr/bin/fennec http://www.cnn.com &
sleep 5
/usr/bin/fennec http://www.npr.org &

Save this in a text file, with a name you like, say, "OpenWebPages". You can then run the commands in the file by passing it to a shell, e.g. "sh OpenWebPages". However, you can use the magic #! flag to invoke a shell from within the text file itself; when Unix is presented with an executable text file whose first two characters are #!, it runs the program following those two characters and passes the rest of the lines as input to it. So, my amended shell script would now be:

Code:

#!/usr/bin/sh
/usr/bin/fennec http://www.cnn.com &
sleep 5
/usr/bin/fennec http://www.npr.org &

Then, you need to make the text file executable (I use "chmod +x OpenWebPages"), and you can now run it by just typing "OpenWebPages" at the xterm prompt.

I don't know if that's enough for Queen BeeCon to make use of it. There is also apparently a "Desktop Command Execution Widget" out there that can run arbitrary shell scripts from the desktop, but I haven't tried it. After digging around a bit, I found that you can also just write your own Hildon "desktop" file fairly easily, and thus make anything you want visible as an icon on the desktop. This seemed more appealing to me, so I gave it a try. (I stole my info from this thread: http://talk.maemo.org/showthread.php?t=58613 )

Here's the desktop file I used:

Code:

[Desktop Entry]
Encoding=UTF-8
Version=0.1
Type=Application
Terminal=true
Name=OpenWebPages
Exec=/home/user/OpenWebPages
Icon=Terminal
X-Osso-Type=application/x-executable

Unfortunately, I don't yet know what most of these entries signify, so I'm not 100% sure this is the best way to write a "desktop" file, but this did work for me. What you need to do is copy this file (named OpenWebPages.desktop, I'm not entirely sure you need to give it the name of your executable followed by .desktop, but the rest of the files follow that convention) into /usr/share/applications/hildon. (You'll need root access to do this.) Then, you should be able to to go to the desktop menu and choose "add shortcut", and your OpenWebPages executable should be visible as one of the icons there.

Hope this helps!

Copernicus 2011-02-07 01:36

Re: Launching multiple websites/programs using terminal?
 
Quote:

Originally Posted by sevep (Post 937770)
Also can anyone tell me the command to start the stock RSS reader too please?

Ah, yeah, a quick grep through /usr/bin shows that the name of the RSS executable is "osso_rss_feed_reader", so you can call that name to run it from the command line (or a shell script). :)

pursueky 2011-03-07 07:18

Re: Launching multiple websites/programs using terminal?
 
It is so helpful


All times are GMT. The time now is 03:14.

vBulletin® Version 3.8.8