Reply
Thread Tools
Posts: 277 | Thanked: 319 times | Joined on Jan 2010
#1021
Originally Posted by mangoicetea View Post
I tried this myself and despite many attempts I can't seem to get the script working properly. Running this script in terminal:
#!/bin/sh
xdg-open /usr/share/applications/toggleBT_harmattan.desktop
killall music-suite
Got me this:
:no process killede
- $ invoker ...toggleBT..
in which the bluetooth toggle works fine but the music application isn't killed.

Switching the lines in the script to this:
#!/bin/sh
killall music-suite
xdg-open /usr/share/applications/toggleBT_harmattan.desktop
Gets me:
no default action for the given PARAMS
Any advice?

Script is in a folder called /home/user/MyDocs/Scripts
Your script is probably written in windows and has MS-DOS formatting. Just go to terminal and use nano.

Code:
nano myscript.sh
Write your script there and save (the default /home/user is fine). It will work now.
 
Posts: 1,313 | Thanked: 2,977 times | Joined on Jun 2011 @ Finland
#1022
Please install and test the new beta to make sure the upcoming release works for your rules. Latest beta is available from here:
http://www.kolumbus.fi/~ks2877/profi...beta_armel.deb

To install, first remove the version you have installed from Nokia Store. Then install the version above.

Changelog (against current release 2.2.2):
- Automatic name for rule translateable (ie. if user has not filled rule name)
- New translations: polish, russian, swedish, Taiwanese
- Existing translations updated from transifex
__________________
My N9/N950 projects:

Last edited by ajalkane; 2013-07-15 at 22:55.
 

The Following 11 Users Say Thank You to ajalkane For This Useful Post:
Posts: 277 | Thanked: 319 times | Joined on Jan 2010
#1023
I may have found a bug. I have a rule set up as described here. Today, for some reason it didn't fire off the script when I locked the screen. A reboot cured this but I got some logs before doing that. The name of the rule is "UpdateBB".
Attached Files
File Type: zip profilematic.zip (4.4 KB, 86 views)
 

The Following User Says Thank You to slarti For This Useful Post:
Posts: 1,313 | Thanked: 2,977 times | Joined on Jun 2011 @ Finland
#1024
Originally Posted by slarti View Post
I may have found a bug. I have a rule set up as described here. Today, for some reason it didn't fire off the script when I locked the screen. A reboot cured this but I got some logs before doing that. The name of the rule is "UpdateBB".
Thanks,

from the logs I can see you apparently want the script to be invoked immediately when lock screen is activated. The idle condition is optimized on the other hand for longer periods for power consumption, so it can be that in these cases the script can be triggered 1-4 seconds after locking screen. And if the device is unlucked during this time, the script is not executed. Can this be the case here? If this is a realworld problem I can see for a different, more immediate, handling for the "0 minute" idle case.

If this is not the case here, do you remember anymore at what time did this problem happen?

From the logs I see the script was fired at these times:

Code:
ma tammikuuta 14 08:06:35 2013 RulesManager::refresh()
ma tammikuuta 14 08:07:45 2013 RulesManager::refresh()
ma tammikuuta 14 08:09:44 2013 RulesManager::refresh()
ma tammikuuta 14 08:09:59 2013 RulesManager::refresh()
Judging by the logs everything happened as it should... but I may have missed something that more information could reveal.
__________________
My N9/N950 projects:

Last edited by ajalkane; 2013-01-18 at 23:59.
 

The Following User Says Thank You to ajalkane For This Useful Post:
Posts: 277 | Thanked: 319 times | Joined on Jan 2010
#1025
It was like that all morning. I waited a while for the script to fire before unlocking but nothing happened. Like I said, a reboot cured it and I haven't seen this behaviour after that. If I see it again, do you have any suggestions what information to collect?

A completely different question:

I started writing a simple dbus listener in python which listens to dbus messages from the timed daemon and updates a profilematic rule's activation time or active status according to the message.

I wanted to know if using the updateRule method this way would have any adverse effects?
 
Posts: 1,313 | Thanked: 2,977 times | Joined on Jun 2011 @ Finland
#1026
Originally Posted by slarti View Post
It was like that all morning. I waited a while for the script to fire before unlocking but nothing happened. Like I said, a reboot cured it and I haven't seen this behaviour after that. If I see it again, do you have any suggestions what information to collect?
Logs as now are useful. But as I said in the logs it was clear that the script was launched, so it's probably something that the script does that doesn't work. If that happens again try running the script manually and see if it does anything: First run it through ProfileMatic's UI with Test button in custom action. If that doesn't work, run it from terminal. See if there's any output.

I started writing a simple dbus listener in python which listens to dbus messages from the timed daemon and updates a profilematic rule's activation time or active status according to the message.

I wanted to know if using the updateRule method this way would have any adverse effects?
That's safe, but I'm surprised that you can use it. It takes as parameter a serialized C++ object. I don't even know how it looks like building that from python or using dbus-send. Out of curiosity do you have some working sample?

The only caveat is that the object usually changes between each ProfileMatic release. But of course if you take an existing rule and only modify the parts you want, then that's pretty future proof also.
__________________
My N9/N950 projects:
 
Posts: 277 | Thanked: 319 times | Joined on Jan 2010
#1027
Originally Posted by ajalkane View Post
Logs as now are useful. But as I said in the logs it was clear that the script was launched, so it's probably something that the script does that doesn't work. If that happens again try running the script manually and see if it does anything: First run it through ProfileMatic's UI with Test button in custom action. If that doesn't work, run it from terminal. See if there's any output.
I think I did run the script in terminal and it worked. I should have remembered the test button since I'm the one who requested it. I'll keep my eyes open for similar cases.

Originally Posted by ajalkane View Post
That's safe, but I'm surprised that you can use it. It takes as parameter a serialized C++ object. I don't even know how it looks like building that from python or using dbus-send. Out of curiosity do you have some working sample?

The only caveat is that the object usually changes between each ProfileMatic release. But of course if you take an existing rule and only modify the parts you want, then that's pretty future proof also.
I have no idea how to build the object from scratch. I just dumped an existing rule's object and modify that.

I told you it's simple...

At the moment it just listens for the next_bootup_event signal which just so happens to be an epoch timestamp or zero for no alarms. This example works but is pretty stupid at the moment.

You'll need python python-dbus and python-gobject.
Attached Files
File Type: txt modifyrule.txt (2.4 KB, 110 views)
 

The Following User Says Thank You to slarti For This Useful Post:
Posts: 277 | Thanked: 319 times | Joined on Jan 2010
#1028
Want your phone to do something when an alarm with a certain name goes off? Use this:

The basic idea is to set a special profilematic 'alarm rule' which executes its actions when an alarm with a certain title goes off. The rule gets deactivated when the next active alarm is not one with the set title or there are no alarms. The alarm title is set in the script as the passwd variable. By default, it's Test.

When the script is running, it will create an 'empty' alarm rule once you set or unset any alarm in the clock application. You can modify the rule freely in profilematic, but don't change the name (probably a good idea to not have another rule with the same name). The time and day will be set by the alarm. This rule is basically meant for 'one-shot' actions so design the actions with that in mind.

If you want to try it out, you'll need to apt-get install python python-dbus python-gobject (as root). Start the script and leave it running in terminal. Try setting and unsetting various alarms and see what happens in profilematic.

To make it run on startup, add it to the default rule as custom action.

The script can be found here.

I've tested this for months without any problems or battery drain.

Added some screenshots to maybe make this a little clearer.


Last edited by slarti; 2013-12-04 at 19:57. Reason: Updated for PM 2.4.2
 

The Following 2 Users Say Thank You to slarti For This Useful Post:
Posts: 1,313 | Thanked: 2,977 times | Joined on Jun 2011 @ Finland
#1029
Originally Posted by slarti View Post
The basic idea is to set a special profilematic 'alarm rule' which executes its actions when an alarm with a certain title goes off. The rule gets deactivated when the next active alarm is not one with the set title or there are no alarms. The alarm title is set in the script as the passwd variable. By default, it's Test.
Very nice.

A couple of questions:
- Is this basically implementing the functionality you've requested about alarms?
- I see you require only one rule, but since ProfileMatic's interface only provides getting all rules, you need to iterate through them. Would a getRule(ruleId) be something that'd be useful for this?

Now, how to make it run as a daemon on startup?
Easiest way is to put it into ProfileMatic's Default rule's custom action. That way it gets started during every reboot of the phone (after the customary 2-4 minutes beyond homescreen becoming visible).

A more robust way, which will have the benefit of restarting the service if it crashes, is to use Upstart. Simply create a configuration file into /etc/init/apps. You can see profilematicd.conf for example, or anything else that is there. More comprehensive help is in harmattan dev docs and of course in Upstart's docs.
__________________
My N9/N950 projects:
 

The Following User Says Thank You to ajalkane For This Useful Post:
Posts: 277 | Thanked: 319 times | Joined on Jan 2010
#1030
Thanks, I went with the default rule as that seems to be enough for now. Should have thought of that myself.

Yes, a getRule(ruleid) method would help getting rid of iterating through a list for a list containing a string. On the other hand the weakness of the script is probably more in the way it creates the alarm rule if one doesn't exist and the way that everything is relying on the string 'Alarm rule'. It seems that the appendRule method doesn't care what ruleid it's fed, it creates a new id for it anyway. That's why the script has to ask for it after creating the rule. Of course, this only applies when there isn't an Alarm rule and I guess I wont be deleting it all the time.

This script does do the job for reacting to an alarm but I still like your idea for setting an alarm as an action.
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 00:21.