Active Topics

 


Reply
Thread Tools
Posts: 277 | Thanked: 319 times | Joined on Jan 2010
#1141
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.

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
Other ProfileMatic actions can be executed by modifying certain parts of the actions_struct. I can post the relevant indices if anyone is interested.

Last edited by slarti; 2013-12-04 at 19:49. Reason: Edited to be compatible with PM 2.4.2
 

The Following 2 Users Say Thank You to slarti For This Useful Post:
Posts: 1,313 | Thanked: 2,978 times | Joined on Jun 2011 @ Finland
#1142
Originally Posted by slarti View Post
Turns out setting an alarm from the command line is now extremely simple thanks to PMs executeAction method. Was that always there?
It's been there as long as long press has had "run rule's actions". For few versions I think.
__________________
My N9/N950 projects:

Last edited by ajalkane; 2013-02-23 at 17:13.
 

The Following User Says Thank You to ajalkane For This Useful Post:
lorenzo's Avatar
Posts: 491 | Thanked: 299 times | Joined on Jul 2012 @ Pordenone IT
#1143
hello.
anyone tried to load a custom cpu profile (from opptimizer)?
 

The Following 2 Users Say Thank You to lorenzo For This Useful Post:
Posts: 11 | Thanked: 3 times | Joined on May 2012
#1144
Hi, I'm running this on my N9, and ever since I updated to the latest, I've been having battery drain issues.

I don't use my phone much. Generally my N9 lasts me about 2 days between charges. But since I got 2.0.1, my phone won't last a day. I haven't changed anything else on my phone.

The only thing PM does is it puts my phone silent for a few (3) cell towers.

It could be my battery but this is the only app I use aside form the stock apps.
 
Posts: 1,313 | Thanked: 2,978 times | Joined on Jun 2011 @ Finland
#1145
Originally Posted by Scorp1us View Post
Hi, I'm running this on my N9, and ever since I updated to the latest, I've been having battery drain issues.
What was the previous version you had before experiencing battery drain? 2.0.0 or 1.9?

The only thing PM does is it puts my phone silent for a few (3) cell towers.

It could be my battery but this is the only app I use aside form the stock apps.
Such simple rule should not cause any drain, except if there's some bug in code. However N9 is a bit temperamental and some background tasks can go haywire causing battery drain that's unrelated to ProfileMatic. How long have you had this battery drain as an issue?

Can you look using Terminal and launching launching "top" what processes are eating CPU?

If that doesn't reveal anything, I'd suggest disabling ProfileMatic (menu -> Deactivate rules) and see if there's no longer battery drain. If disabling PM removes the battery drain, then it points to some bug in ProfileMatic that gets triggered by your rule(s).
__________________
My N9/N950 projects:
 
Posts: 594 | Thanked: 1,094 times | Joined on Aug 2012 @ Rhine
#1146
Hi, there is this new feature, to start an application, when a rule becomes active.

Do you think, it is possible without too much effort, to add this possibility, when a rule becomes inactive?

This way, you could start all appllications you need in the morning before you are awake, when a "night-rule" ends for example...
 
Posts: 1,313 | Thanked: 2,978 times | Joined on Jun 2011 @ Finland
#1147
Originally Posted by Leinad View Post
Hi, there is this new feature, to start an application, when a rule becomes active.

Do you think, it is possible without too much effort, to add this possibility, when a rule becomes inactive?

This way, you could start all appllications you need in the morning before you are awake, when a "night-rule" ends for example...
It's not hard to implement, and I considered doing it. But since it wasn't requested at the time I thought it's better to leave it as simple as can be.

Now I don't have much time for ProfileMatic updates, and probably I'll concentrate on translations when I have a bit time.

But creating that use scenario should not be hard. Usually when one rule ends, another becomes active. For example a night time rule, at least for me, activates power saving and flight mode. In the morning those deactivate so WLAN is connected. I could put there the applications to start. So there's ways around it anyway to do what you want usually.
__________________
My N9/N950 projects:
 

The Following 3 Users Say Thank You to ajalkane For This Useful Post:
Posts: 1,313 | Thanked: 2,978 times | Joined on Jun 2011 @ Finland
#1148
Originally Posted by lorenzo View Post
I recently flashed my N9 and now when i type sh script.sh it says #!/bin/sh not found, what i forgot to reinstall?
There's nothing you forgot to install. Your script probably includes (non-visible) characters. The most usual scenario is windows end of line markings. You should create the script in n9's nano editor for example to avoid that situation.
__________________
My N9/N950 projects:
 
lorenzo's Avatar
Posts: 491 | Thanked: 299 times | Joined on Jul 2012 @ Pordenone IT
#1149
Originally Posted by ajalkane View Post
There's nothing you forgot to install. Your script probably includes (non-visible) characters. The most usual scenario is windows end of line markings. You should create the script in n9's nano editor for example to avoid that situation.
but before flashing everithing was ok
this is the script
and the output
Code:
sh /home/user/scripts/auto-wall.sh 
/home/user/scripts/auto-wall.sh: line 1: #!/bin/sh: not found 
sed: /etc/osso-af-init/%gconf.xml: Permission denied 
sh: mywall1.png: unknown operand 
sh: mywall2.png: unknown operand 
sh: mywall3.png: unknown operand 
sh: mywall4.png: unknown operand 
sh: mywall5.png: unknown operand 
sh: mywall6.png: unknown operand 
sh: mywall7.png: unknown operand
Attached Files
File Type: txt auto-wall.txt (2.8 KB, 86 views)

Last edited by lorenzo; 2013-03-03 at 07:46.
 
Posts: 1,313 | Thanked: 2,978 times | Joined on Jun 2011 @ Finland
#1150
Originally Posted by lorenzo View Post
but before flashing everithing was ok
this is the script
and the output
Code:
sh /home/user/scripts/auto-wall.sh 
/home/user/scripts/auto-wall.sh: line 1: #!/bin/sh: not found 
sed: /etc/osso-af-init/%gconf.xml: Permission denied 
sh: mywall1.png: unknown operand 
sh: mywall2.png: unknown operand 
sh: mywall3.png: unknown operand 
sh: mywall4.png: unknown operand 
sh: mywall5.png: unknown operand 
sh: mywall6.png: unknown operand 
sh: mywall7.png: unknown operand
Two problems:

1) Apparently edited with Notepad or something. There is UTF-8 byte order mark in the start of the file (3 bytes). This is what causes "#!/bin/sh not found" error.

2) The script must be run as root. This causes permission denied and all the later errors are related to that.
__________________
My N9/N950 projects:
 

The Following User Says Thank You to ajalkane For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 02:58.