maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   [M5] start clock app from terminal or script (https://talk.maemo.org/showthread.php?t=94821)

rasmarc 2015-04-07 16:30

start clock app from terminal or script
 
How can the clock app be started from command line? "/usr/bin/worldclock" won't show up the clock gui, nor will "run-standalone.sh worldclock".

I want to put the command in an autostart-script:

/etc/event.d/autostart:
Code:

start on started hildon-desktop
exec su user -c /home/user/autostart.sh

/home/user/autostart.sh:
Code:

#!/bin/sh

/COMMAND TO START CLOCK
sleep 3
run-standalone.sh /opt/cooktimer/cooktimer


peterleinchen 2015-04-07 19:45

Re: start clock app from terminal or script
 
First: cooktimer is not worldclock ;)
Second: in general worldclock can be started via command line just like hou described (but you should detach with a trai'ing ampersand '&')
Third: is your script executable? [chmod +x ...]
Fourth: / is not a comment, exchange with #
try once more

ade 2015-04-07 20:53

Re: start clock app from terminal or script
 
Cooktimer is just something else he wants to have at startup (used as example I guess)

I am afraid Rasmarc is not lucky enough to have CSSU-testing or the worldclock replacement installed.

The default worldclock is not a standalone executable, but a shared object. It cannot be launched as a standard executable.

This should do the trick:

Code:

dbus-send --type=method_call --dest=com.nokia.HildonDesktop.AppMgr /com/nokia/HildonDesktop/AppMgr com.nokia.HildonDesktop.AppMgr.LaunchApplication string:"worldclock"

rasmarc 2015-04-09 15:29

Re: start clock app from terminal or script
 
As Ade said, the autostart.sh script should launch worldclock and cooktimer. And with the provided code everything works fine as long as the script ist started from a terminal (worldclock is launched and the script is detached after cooktimer is launched).

Code:

#!/bin/sh

dbus-send --type=method_call --dest=com.nokia.HildonDesktop.AppMgr /com/nokia/HildonDesktop/AppMgr com.nokia.HildonDesktop.AppMgr.LaunchApplication string:"worldclock"
sleep 3
run-standalone.sh /opt/cooktimer/cooktimer &

When started automatically from /etc/event.d/autostart the dbus command doen't work. Adding the line "start on started dbus" into that script (without knowing what i'm doing) brought no success.

Seaching brought me to this thread: Run script on startup with access to dbus session bus... but i don't know if the problem there is similar. :o

I cannot install the worldclock replacement. The application manager doesn't list it and installing by launching the .deb file is refused because of incompatibility.

sixwheeledbeast 2015-04-09 21:11

Re: start clock app from terminal or script
 
Is it not better to make a upstart script instead of triggering a script with upstart.
http://upstart.ubuntu.com/cookbook/

rasmarc 2015-04-13 21:31

Re: start clock app from terminal or script
 
Quote:

Originally Posted by sixwheeledbeast (Post 1466269)
Is it not better to make a upstart script instead of triggering a script with upstart.
http://upstart.ubuntu.com/cookbook/

Probably it is, but that won't resolve the dbus problem. The only reason i triggered a script was to avoid a recurring "exec su user -c".

So i would like to know either how to get access to the relevant dbus session (i guess :confused:) or how to get the clock replacement installed (in fact i'm interested in both).

peterleinchen 2015-04-14 10:35

Re: start clock app from terminal or script
 
Tested the dbus command and it works fine when executed as root (and also as 'su user -c ...', so no idea. I did not test to execute it as service.

About worldclock installment:
please read from here and download the deb, extract it and simply replace /usr/bin/worldclock. Should do the trick.


--edit
just checked with file in /etc/event.d and indeed it fails with "Failed to open connection to "session" message bus: (null)"
But simply preceeding with run-standalone.sh works.

Quote:

description "start worldclock on boot"

author "peterleinchen"

start on started hildon-desktop

#respawn

exec su user -c "run-standalone.sh dbus-send --type=method_call --dest=com.nokia.HildonDesktop.AppMgr /com/nokia/HildonDesktop/AppMgr com.nokia.HildonDesktop.AppMgr.LaunchApplication string:\"worldclock\""

Please note the escaped " around worldclock.

rasmarc 2015-04-15 10:21

Re: start clock app from terminal or script
 
Solved, many thanks. Just an ampersand was missing again at the end of the line in order to get subsequent lines executed. And if there's more than one command the lines "script" and "end script" must be inserted. Finally I copied the clock replacement. :cool:

peterleinchen 2015-04-15 11:58

Re: start clock app from terminal or script
 
Quote:

Originally Posted by rasmarc (Post 1467235)
Solved, many thanks. Just an ampersand was missing again at the end of the line in order to get subsequent lines executed.

Talking about your script? Or the one in event.d?

Quote:

more than one command the lines "script" and "end script" must be inserted.
.
True. But then you do not need the 'exec' anymore. :p

So in above script there should not be the need for ampersands. Except you call a full binary directly. As this line would wait for termination of that binary ().

rasmarc 2015-04-15 14:04

Re: start clock app from terminal or script
 
If a script is triggered no ampersand is needed in /etc/event.d/autostart:
Code:

start on started hildon-desktop

script

sleep 30
exec su user -c "/home/user/autostart.sh"

end script

But in the triggered script:
Code:

#!/bin/sh

run-standalone.sh /usr/bin/worldclock &
sleep 1
run-standalone.sh /opt/cooktimer/cooktimer &

Otherwise subsequent lines will not be executed until the "blocking" application is closed.

Without a triggered script /etc/event.d/autostart looks like this:
Code:

start on started hildon-desktop

script

sleep 30
exec su user -c "run-standalone.sh /usr/bin/worldclock" &
sleep 1
exec su user -c "run-standalone.sh /opt/cooktimer/cooktimer" &

end script

The ampersands have to be added at the end. If put inside the quotation marks subsequent lines will not be executed even if the blocking application is closed.

If "exec..." is omitted the applications run as root even inside "script" / "end script" (at least on my N900).

Maybe there's something strange with my maemo installation. "ssh status and switcher" blocked my hildon status menu until I added an "&" to the relevant lines in the script, see this thread.


All times are GMT. The time now is 23:06.

vBulletin® Version 3.8.8