QML: onTriggered run shell-script

The last function to finish my first SailfishOS-App is to execute a shell script with the onTriggered-Tag:

I try on Cover action:

import QProcess 1.0

onTriggered: QProcess::execute(“sh /usr/share/harbour-myapp/script.sh”);

But it doesn´t work.

I like the clean QML-Approach of @BlacksheepGER of Hafenschau.

Beautiful, clean, coal (code) :grin:

So after i solve the Problem above i want to build/transform the functionality from the shell-script into pure QML.

The used Shellscript-Functions are:

  • Load text from Webserver
  • Load Image from Webserver
  • Set ambiece through busctl (com.jolla.ambienced)
  • Send a Notification trough gdbus call (org.freedesktop.Notifications)

:slight_smile: But, it’s a question of what you get from the web server. If you ‘know’ the the uri structure to images, you can just ‘assign’ that to Image{ src: } EDIT: look at harbour-hafenschau/blob/master/qml/models/NewsModel.qml to see how he uses API.

The ambienced question is probably one for @nephros?

Blacksheeps Code did far more than i need. I dunno want to copy his work 1:1. My first App is like a study for me so i will not release anything until my own base template works 100%.

I know that there are other great ways to combine c++, javascript or phyton to it but when things can get realised with pure QML i will try it. The QtBuilder-Environment is a great help but i prefer to “live hack” on my device because it’s a fast way to develop and i’m output-driven. :grinning:

But, it’s a question of what you get from the web server. If you ‘know’ the the uri structure to images, you can just ‘assign’ that to Image{ src: }

I’m in control of my Webspace and have there my own PHP-Scripts which can convert text/image like i want. Surely they can be exchanged later with native Sailfish-Functions.

About ambiences: do you want to create a completely new ambience or switch to an existing one?

 busctl --user introspect com.jolla.ambienced /com/jolla/ambienced

lists the methods, there is createAmbience but I don’t know its payload/parameter. It’s either a path to an image, or a JSON string I guess. There’s also setAmbience for switching to an existing one.

1 Like

Notifications are easy. Just use the Nemo.Notifications plugin.

1 Like

Images: if as you say you have control of the server, you can make an XHR call, have it return a data: url string for images and just assign that to Image::source.
That way you don’t have to deal with binary data in the response.

1 Like