| The Following 3 Users Say Thank You to slarti For This Useful Post: | ||
|
|
2014-11-22
, 04:52
|
|
|
Moderator |
Posts: 199 |
Thanked: 264 times |
Joined on May 2009
@ turku, finland
|
#1612
|
|
|
2014-11-22
, 05:40
|
|
Posts: 1,313 |
Thanked: 2,977 times |
Joined on Jun 2011
@ Finland
|
#1613
|
if both the 3g connection and a particular wlan is set to automatically connect, it doesn't seem possible to "switch to wlan x when available". Is this correct?
| The Following 2 Users Say Thank You to ajalkane For This Useful Post: | ||
|
|
2015-01-19
, 08:56
|
|
Posts: 3 |
Thanked: 1 time |
Joined on Aug 2013
|
#1614
|
|
|
2015-01-19
, 18:41
|
|
Posts: 1,313 |
Thanked: 2,977 times |
Joined on Jun 2011
@ Finland
|
#1615
|
Have you ever thought about creating similar app for BlackBerry 10? There are some profile changers in their store, but they are not even close to Profilematic. After few years with N9, this is probably the only app that I can't find replacement for to use with my new BB phone...
| The Following 4 Users Say Thank You to ajalkane For This Useful Post: | ||
|
|
2015-01-20
, 18:43
|
|
Posts: 3 |
Thanked: 1 time |
Joined on Aug 2013
|
#1616
|
Nice to hear apparently changing profile automatically is now possible. But I have unfortunately lost interest in BB10. Thank you for your nice words about ProfileMatic.
| The Following User Says Thank You to bakulik For This Useful Post: | ||
|
|
2015-02-17
, 22:09
|
|
Posts: 290 |
Thanked: 385 times |
Joined on Jan 2012
@ Madrid, Spain
|
#1617
|
Turns out setting an alarm from the command line is now extremely simple thanks to PMs executeAction method. Was that always there?
Here is a simple script that takes seconds as an argument. If you don't give it anything it defaults to 60 seconds. If you give it something that isn't a number it will fail with ValueError exception. Title, snooze and sound can, of course, be modified from within the script.
python and python-dbus need to be installed (apt-get install python python-dbus as root)
Argument is given simply with: python /path/to/script.py 120
This will set an alarm 120 seconds from now.
Other ProfileMatic actions can be executed by modifying certain parts of the actions_struct. I can post the relevant indices if anyone is interested.Code:#!/usr/bin/python import dbus import sys bus = dbus.SessionBus() pm_obj = bus.get_object('org.ajalkane.profilematic', '/org/ajalkane/profilematic') pm_intf = dbus.Interface(pm_obj, 'org.ajalkane.profilematic') actions_struct = ['', 0, -1, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, '', '', dbus.Array([], signature=dbus.Signature('(usis)')), '', 0, 1, [dbus.Array([], signature=dbus.Signature('s'))], -1, 0, ['', -1, -1, ''], -1, 0] if len(sys.argv) == 2: seconds = int(sys.argv[1]) else: seconds = 60 title = 'Timer' snooze = 10 sound = '' actions_struct[24] = [title, seconds, snooze, sound] pm_intf.executeAction(actions_struct) print 'Alarm set to go off in %s seconds from now.' %seconds
|
|
2015-02-21
, 20:00
|
|
Posts: 290 |
Thanked: 385 times |
Joined on Jan 2012
@ Madrid, Spain
|
#1618
|
org.ajalkane.profilematic.executeAction(QDBusRawType::(sbiibibibibibibssa(usis action)
|
|
2015-02-21
, 20:35
|
|
Posts: 1,313 |
Thanked: 2,977 times |
Joined on Jun 2011
@ Finland
|
#1619
|
Hi.
Sorry for bumping the thread, but I really would like to be able to set/modify clock alarms in my N9.
Somebody knows what's the meaning of the parameters in:
The example in my previous post just sets the values.... but does not explain them.Code:org.ajalkane.profilematic.executeAction(QDBusRawType::(sbiibibibibibibssa(usis action)
Thanks in advance.
Regards.
| The Following 3 Users Say Thank You to ajalkane For This Useful Post: | ||
|
|
2015-02-21
, 23:02
|
|
Posts: 290 |
Thanked: 385 times |
Joined on Jan 2012
@ Madrid, Spain
|
#1620
|
#!/usr/bin/python # Trigger Profilematic rule by BT connected/disconnected # author: slarti import dbus, gobject from ConfigParser import SafeConfigParser # Check for a configfile and create one if it doesn't exist cfgfile = open('scriptconfigfile.ini', 'a+') # Set up profilematic interface and get a list of rule names: sesbus = dbus.SessionBus() pm_obj = sesbus.get_object('org.ajalkane.profilematic', '/org/ajalkane/profilematic') pm_intf = dbus.Interface(pm_obj, 'org.ajalkane.profilematic') rulenames = pm_intf.getRuleNames() # Set up some functions to use when handling the dbus event: def menu(list_1, question): print (30 * '-') print ("Pick one from these:") for entry in list_1: print " ",1 + list_1.index(entry), print ") " + entry print (30 * '-') return list_1[(int(raw_input(question)) - 1)] def get_disconnected_rule(): rule_list = ["No action"] + rulenames disconnected_rule = menu(rule_list, "Pick the rule whose actions you want to execute when device is disconnected: ") print "The actions of (%s) will be executed on device disconnect" %disconnected_rule return disconnected_rule def get_connected_rule(): rule_list = ["No action"] + rulenames connected_rule = menu(rule_list, "Pick the rule whose actions you want to execute when device is connected: ") print "The actions of (%s) will be executed on device connect" %connected_rule return connected_rule def trigger_action(rulename): if rulename == 0: print "No action wanted." else: pm_intf.executeActionsByRuleName(rulename) print rulename, "executed." # Set up loop to listen for dbus signal: from dbus.mainloop.glib import DBusGMainLoop dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) # Get the BT adapter path and link device names to device paths in a dict: bus = dbus.SystemBus() bluez = bus.get_object('org.bluez', '/') adapter_path = bluez.ListAdapters(dbus_interface='org.bluez.Manager')[0] adapter = bus.get_object('org.bluez', adapter_path) devices = adapter.ListDevices(dbus_interface='org.bluez.Adapter') device_dict = {} for device_path in devices: deviceprops = bus.get_object('org.bluez', device_path).GetProperties(dbus_interface='org.bluez.Device') device_dict.update({deviceprops ['Alias']:device_path}) # Get device, connect rule and disconnect rule from user: settings = SafeConfigParser() settings.read('scriptconfigfile.ini') if settings.has_section('settings'): pass else: settings.add_section('settings') if settings.has_option('settings', 'device'): device = settings.get('settings', 'device') else: device = menu(device_dict.keys(),"The name of the device to follow: ") settings.set('settings', 'device', device) device_path = device_dict [device] print "Now following the device: ",device, "in path: ",device_path if settings.has_option('settings', 'connected_rule'): connected_rule = settings.get('settings', 'connected_rule') else: connected_rule = get_connected_rule() if connected_rule == "No action": device_connected = 0 else: device_connected = connected_rule settings.set('settings', 'connected_rule', connected_rule) if settings.has_option('settings', 'disconnected_rule'): disconnected_rule = settings.get('settings', 'disconnected_rule') else: disconnected_rule = get_disconnected_rule() if disconnected_rule == "No action": device_disconnected = 0 else: device_disconnected = disconnected_rule settings.set('settings', 'disconnected_rule', disconnected_rule) settings.write(cfgfile) cfgfile.close() print "Try connecting/disconnecting device %s now" %device # Handle dbus signal: def process_signal(property, message): if message == 0: print device, "disconnected. Triggering action." trigger_action(device_disconnected) else: print device, "connected. Triggering action." trigger_action(device_connected) # Add signal receiver: bus.add_signal_receiver(process_signal,path=device_path,dbus_interface='org.bluez.Device',signal_name='PropertyChanged') loop = gobject.MainLoop() loop.run()