Active Topics

 


Reply
Thread Tools
Posts: 6 | Thanked: 14 times | Joined on Mar 2014
#1
I tried to create a more elaborated Ambience system -- just changing the background and ringtones gets rather dull after a while. My first small steps are documented on TJC. I also got a lot of inspiration from the "Tinkering with DBUS" thread here on TMO.

Now I that I got the whole thing to work, I thought I'd share it with you. Please note that this still involves rather a lot of console work.

At the heart of this custom ambience system is the following python script, let's call it custom_ambiences.py. This script first executes boot.sh (so that you can run something when your Jolla starts up), and then listens to the DBIS and executes $TOHID.sh when a TOH is attached. Besides that, it executes [I]$AMBIENCE_NAME[I].sh when a new ambience is selected. It looks for those scripts in /home/nemo/scripts.

The content of /home/nemo/scripts/custom_ambiences.py:

PHP Code:
#!/usr/bin/python

def start_script(cmd):
    try:
        
subprocess.Popen([cmd])
    
except OSError:
            
with open(cmd"w") as text_file:
                    
text_file.write("#!/bin/sh")

def start_toh_script(senderdict, array):
        if 
'TOHID' in dict:
                print 
dict['TOHID']
                
cmd "/home/nemo/scripts/"+dict['TOHID']+".sh"

def start_ambience_script(var1,var2,var3,var4):
        
pathos.popen("gconftool-2 -g /desktop/meego/background/portrait/picture_filename").read()
        
path=path.split("/")
        
ambience=path[len(path)-1].split(".ambience")[0]
        
cmd="/home/nemo/scripts/"+ambience+".sh"
    
start_script(cmd)


import dbusgobjectsubprocessos
from dbus
.mainloop.glib import DBusGMainLoop
dbus
.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus dbus.SystemBus()
session dbus.SessionBus()
object session.get_object('org.freedesktop.Notifications','/org/freedesktop/Notifications')
interface = 
dbus.Interface(object,'org.freedesktop.Notifications')

cmd "/home/nemo/scripts/boot.sh"
subprocess.Popen([cmd])

bus.add_signal_receiver(start_toh_script,dbus_interface='org.freedesktop.DBus.Properties',path='/com/jolla/tohd')
session.add_signal_receiver(start_ambience_script,dbus_interface='com.nokia.profiled'path='/com/nokia/profiled')

loop gobject.MainLoop()
loop.run() 
Then we have to turn this script into a service, so that it starts during booting the device and runs in the background the whole time. In order to achieve this, first create /home/nemo/.config/systemd/user/autostart-apps.service:

PHP Code:
[Unit]
Description=Run applications at startup
Requires
=lipstick.service
After
=lipstick.service

[Service]
Type=oneshot
ExecStart
=/home/nemo/.config/systemd/scripts/autostart-apps

[Install]
WantedBy=post-user-session.target 
Then create /home/nemo/.config/systemd/scripts/autostart-apps:

PHP Code:
#!/bin/sh -

invoker ---type=generic /home/nemo/scripts/custom_ambiences.py 
Then enable the service: systemctl --user enable /home/nemo/.config/systemd/user/autostart-apps.service

(I took this also from TJC)

And then you're good to go!

Some cool things you can do with this:
  • Overrule the ambience which is associated with a specific TOH: Just use dbus-send --session --print-reply --dest=com.jolla.ambienced /com/jolla/ambienced com.jolla.ambienced.setAmbience string:"file://path/to/ambience" in the $TOHID.sh script
  • Start a VPN connection
  • Hide some apps (e.g. no games when you should work ) by means of adding "NoDisplay=true" to the appropriate .desktop files
  • Enable/disable email: e.g. ag-tool enable-service 4 email

If you have any other ideas, I'd be glad to hear them.
 

The Following 8 Users Say Thank You to gehowa For This Useful Post:
Posts: 144 | Thanked: 242 times | Joined on Nov 2007 @ Finland
#2
Jolla is working with some extensions to ambiance framework with Rovio and their Angry Birds TOH. I do not know when those will be available in OS or if those already are.

I like this custom Ambience system idea. However in my opinion it should be installed properly under /usr and so that it would be possible to still create ambience rpms fully compatible with native ambiance support but with extensions this custom system would provide.

I do not support such short cutting solutions which alter system files or other applications files as those are like asking for troubles and average joe will only break his OS with those sooner or later.

Would be nice target to have a framework with custom-ambience-server and custom-ambience-gui to manage them, guidelines howto to create custom features into ambience packages, how those shall be installed into system so that custom framework will recognize those, common configuration guidelines for those (gconf?) etc...

I might be interested to contribute to such activity too. Currently I am too busy with custom keyboard framework and one commercial project but after those may be.
 

The Following User Says Thank You to Penguin For This Useful Post:
Posts: 959 | Thanked: 3,427 times | Joined on Apr 2012
#3
Would it be possible to set a custom ambiance from an app (or terminal command) for those of us with an N9 or other device that doesn't support Other Halfs?
 
Posts: 144 | Thanked: 242 times | Joined on Nov 2007 @ Finland
#4
Can't you just set any ambiance from UI as in Jolla if you are running Sailfish OS in your device?
__________________
Copy offers 20 GB free cloud storage
Register via this link -> confirm your email address -> install Copy client (Linux, OS X, Windows, iOS or Android) and you'll get 20 GB storage space in cloud.
 
Posts: 959 | Thanked: 3,427 times | Joined on Apr 2012
#5
Originally Posted by Penguin View Post
Can't you just set any ambiance from UI as in Jolla if you are running Sailfish OS in your device?
Sure, but not these extended ones, as the scripts are triggered by the OH if I understand correctly.
 
Posts: 144 | Thanked: 242 times | Joined on Nov 2007 @ Finland
#6
With that script may be, but it could be changed so that any ambience change triggers extensions too. Good start in that script but as I wrote IMO should be extended to more robust custom ambience framework.
__________________
Copy offers 20 GB free cloud storage
Register via this link -> confirm your email address -> install Copy client (Linux, OS X, Windows, iOS or Android) and you'll get 20 GB storage space in cloud.
 
Schturman's Avatar
Posts: 5,339 | Thanked: 4,133 times | Joined on Jan 2010 @ Israel
#7
gehowa, thank for this command:
Code:
dbus-send --session --print-reply --dest=com.jolla.ambienced /com/jolla/ambienced com.jolla.ambienced.setAmbience string:"file://path/to/ambience"
Going to use it
 

The Following User Says Thank You to Schturman For This Useful Post:
Schturman's Avatar
Posts: 5,339 | Thanked: 4,133 times | Joined on Jan 2010 @ Israel
#8
Can someone tell me how to check with dbus command which ambience active now ?
I found only this way to see the name of active ambience... :
Code:
grep 'ambience' /home/nemo/.gconf/desktop/meego/background/portrait/%gconf.xml|cut -d '/' -f6|cut -d '<' -f1
 
Posts: 144 | Thanked: 242 times | Joined on Nov 2007 @ Finland
#9
Not dbus but...

Execute as nemo user:
Code:
gconftool-2 --get /desktop/meego/background/portrait/picture_filename
or as root

Code:
su - nemo -c "gconftool-2 --get /desktop/meego/background/portrait/picture_filename"
__________________
Copy offers 20 GB free cloud storage
Register via this link -> confirm your email address -> install Copy client (Linux, OS X, Windows, iOS or Android) and you'll get 20 GB storage space in cloud.

Last edited by Penguin; 2014-03-26 at 09:35.
 

The Following User Says Thank You to Penguin For This Useful Post:
Schturman's Avatar
Posts: 5,339 | Thanked: 4,133 times | Joined on Jan 2010 @ Israel
#10
 
Reply


 
Forum Jump


All times are GMT. The time now is 18:07.