View Single Post
Posts: 339 | Thanked: 1,623 times | Joined on Oct 2013 @ France
#29
Hi,

I am looking at an ambience switch action.

I have a lot to learn in the process, from qml (I'm a widget guy...) to dbus, through packaging hell.


Anyway, here are what I found so far:

Ambiances can be changed using the following dbus command:
Code:
$ dbus-send --type=method_call --dest=com.jolla.ambienced /com/jolla/ambienced com.jolla.ambienced.setAmbience string:"file:///usr/share/ambience/storm/storm.ambience"
The string containing the image to use as an ambience.

Then, to discover which ambiences exist, and in particular which ones are favorited (so that they can contain ringtone/volume parameters), we need to dig into a hidden sqlite database which requires root access so far (or at least privileged rights):

Code:
# echo "SELECT file.displayName, directory.path,file.filename FROM ambience INNER JOIN file ON file.id = ambience.fileId INNER JOIN directory ON directory.id = file.directoryId WHERE ambience.favorite = 1;" | sqlite3 /home/nemo/.local/share/system/privileged/Ambienced/ambienced.sqlite | sed -e "s/|/ : /" -e "s/|/\//"
This returns the favorited ambiences only (you can remove this condition in the query if you want all) in the following format "name : path", like shown here:
Code:
Home : /usr/share/ambience/babyflower/babyflower.ambience
Night : /usr/share/ambience/redtrain/redtrain.ambience
Work : /usr/share/ambience/storm/storm.ambience
By the way, custom ambiences have a jpeg (or other) extension, not ".ambience".

My next step will be to integrate the DBus command (using proper Qt class, bash commands where simply used to test the functionnality) into an AmbienceAction plugin, hardcoding the ambiances path in the GUI.
Then we will need a way to get the favorited ambiances without needing privilege access to read the sqlite database...

I'll let you know when I reach the next step.
 

The Following 5 Users Say Thank You to Zeta For This Useful Post: