Use TOH to trigger shell scripts [answered]
I really like the idea of having different ambiences for different circumstances. I fear, however, that it will take the brave Jolla engineers quite some time to develop a more elaborate ambience system.
One quick workaround would be to allow to trigger shell scripts when a TOH is replaced by another one. This shouldn't be too much work for Jolla, but would allow us to create our own crude ambience system. Frankly, I don't know how much aspects of the phone you can control by CLI, e.g. changing the ambience, but some basic linux stuff like vpn connection should be possible -- and this would be really helpful for me!
Edit: I wrote a python script which takes the ID of a newly attached TOH and executes a shell script named $TOH_ID.sh. This was easier than I thought -- thanks again for your answers!
#!/usr/bin/env python
def start_toh_script(sender, dict, array):
if 'TOHID' in dict:
print dict['TOHID']
cmd = "./"+dict['TOHID']+".sh"
try:
subprocess.Popen([cmd])
except OSError:
print 'Please create file: '+dict['TOHID']+'.sh'
import dbus, gobject, subprocess, os
from dbus.mainloop.glib import DBusGMainLoop
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
bus.add_signal_receiver(start_toh_script,dbus_interface='org.freedesktop.DBus.Properties',path='/com/jolla/tohd')
loop = gobject.MainLoop()
loop.run()
try running dbus-monitor from cli when attaching a TOH. it triggers events and should be straight forward to trap dbus events with a shell script and do whatever you want then.
droll ( 2014-02-03 13:47:13 +0200 )editSeems as if I asked my question just in time ;)
Just ordered the two new TOH so I can play around with the script: http://shop.jolla.com/cat-the-other-half.html
gehowa ( 2014-02-04 17:09:17 +0200 )editAlthough technically it's all nice and wow, but how useful is something like this? I mean changing a TOH is not too easy -- at least mine is attached quite well to the phone body, so it takes time and considerable effort to "peal it off". Much easier to swipe and change the ambience or execute some script file from the phone (which might have a "shortcut icon" on the UI, so it is just a simple tap). Or what I miss? ;)
CsTom ( 2014-02-05 10:18:41 +0200 )editOkay, a GUI button would be easier, but changing the TOH is way cooler -- and it can be used to show off Jolla's capabilities. For example, the white TOH now enables my work email account and displays a "work" background, and the red one disables work emails, so there is only private mail left. Pretty cool for two days of hacking :D
gehowa ( 2014-02-05 11:31:32 +0200 )editChange profile work/personal - nice feature, but this may be switched via gesture as is on BB10. And .. IMHO this feature will not be on SailfishOS in this year .. not with current amount developers in Jolla for work on this Jolla closed things. :(
Kaacz ( 2014-02-05 14:33:23 +0200 )edit