We have moved to a new Sailfish OS Forum. Please start new discussions there.
1

[answered] How to run script from QML ?

asked 2015-12-23 09:44:17 +0300

Schturman gravatar image

updated 2016-10-26 15:22:26 +0300

jiit gravatar image

Hi
Guys, i need your help..
I want to run my script from qml file. I know it's possible. Coderus told me to check the sailfish-utilities as example and I did it. But I still can't get to work my button...
For example, I created page with slider and button, slider working and save parameter, and when I press on button it should start my script with command that included slider parameter. But it always show me message "failed" :(
I also tried to create identical copy of Lipstick restart button and changed only to my script and it also show me message "failed".
And yes I checked my script it work and permission is correct... I even added content of my script instead content of Lipstick restart script and in this case original button of lipstick restart working and run my script....
This is a reason that I don't understand why my button not working even it copy of original Lipstick restart button.

Maybe I need to run any specific command to activate it somehow before it will start working ? Really don't know...

Can someone, who understand, check my files and fix them if needed PLEEEEEEASE :)
https://dl.dropboxusercontent.com/u/17706605/Jolla1/speaker_test_button.zip
Folders "pages" and "entries" should be inside /usr/share/jolla-settings
Thanks

EDIT (25.12.15):
I found answer by myself :)
Look in to tools.js file in my zip and change this line:

exports.restartSpeaker = make_system_action("restart_speaker");

to this one:

exports.restartSpeaker = function(msg, ctx) {
    var os = require("os");
    os.system("/bin/sh", ["/usr/share/jolla-settings/pages/openrepos-testbutton/restart_speaker.sh"]);
};

and button starts working ! That's all :)

edit retag flag offensive close delete

Comments

1

Thanks, but it not really what I need (i think... already saw this links). Also I'm not programmer to understand all this stuff...
As I said a good example in my case is a sailfish-utilities app. Just look and see how it start scripts, for example Lipstick restart... And after this see my files...

Schturman ( 2015-12-23 12:14:03 +0300 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2015-12-23 21:26:44 +0300

Schturman gravatar image

Problem solved! I found solution :)

edit flag offensive delete publish link more

Comments

1

Is it a state secret?

objectifnul ( 2015-12-23 22:55:11 +0300 )edit

No :), just don't have time now to update my first post normally..
The quick answer is, change this line in .js file:
exports.restartSpeaker = make_system_action("restart_speaker"
To this:
exports.restartSpeaker = function(msg, ctx) { var os = require("os"); os.system("/bin/sh", ["/usr/share/jolla-settings/pages/openrepos-testbutton/restart_speaker.sh"]); };
;)

Schturman ( 2015-12-23 23:10:27 +0300 )edit

@schturman, could you test if that script runs in background and will not be paused by display turned off?

lakutalo ( 2015-12-25 11:18:39 +0300 )edit

I don't need it in my case.. I need to run only one command from my script, once...
If your script include loop and sleep command, as far as I know sleep command paused in deep screen sleep.

Schturman ( 2015-12-25 13:43:01 +0300 )edit
Login/Signup to Answer

Question tools

Follow
2 followers

Stats

Asked: 2015-12-23 09:44:17 +0300

Seen: 1,166 times

Last updated: Dec 25 '15