Active Topics

 


Reply
Thread Tools
Posts: 104 | Thanked: 16 times | Joined on Sep 2012 @ german (cologne)
#881
it is possible that the unit automatically shuts off and restarts?

Due to save energy
 
Posts: 1,313 | Thanked: 2,977 times | Joined on Jun 2011 @ Finland
#882
Originally Posted by warypopp View Post
it is possible that the unit automatically shuts off and restarts?
Shutting down the device is pretty easy using custom action.

But starting it automatically after that after some time? I really don't know. Alarms supposedly will wake the device, I don't know if you set an alarm if it would work. No idea honestly.

Due to save energy
The easiest way to save energy, is to put Flight Mode and Power Saving mode on during night or when you don't need the phone.

For example I have a condition that when my phone has been Idle for 1 hour in night, Flight Mode and Power Saving mode are activated.
__________________
My N9/N950 projects:
 

The Following User Says Thank You to ajalkane For This Useful Post:
Posts: 335 | Thanked: 285 times | Joined on Sep 2012 @ Trento, Italy
#883
Hi guys, I'm not able to run this script: http://talk.maemo.org/showpost.php?p...&postcount=825. I put the battery.sh file in /home/user/scripts/battery.sh and then added "sh /home/user/scripts/battery.sh" as custom action but it doesn't work. Did I forget something?
 
Posts: 1,313 | Thanked: 2,977 times | Joined on Jun 2011 @ Finland
#884
Some Custom Actions require running as root.

You can run scripts as root from ProfileMatic for example like this:

Code:
sh -c "echo rootme |*devel-su -c '/sbin/initctl restart xsession/icd2'"
(that restarts internet service, ie the icd2 daemon). rootme is by default the root's password, if you have changed it then modify accordingly.

Another way that is more convenient in some situations, is to create a helper script that can run commands as root:

Create a folder where to put scripts if you don't have one already:

Code:
mkdir /home/user/scripts
Inside that create a new file named "execroot.sh" with following contents:

Code:
#!/bin/sh

if [ $# -ne 1 ]
then
        echo "Usage: $0 command"
        exit 1
fi

echo rootme | devel-su -c "$1"
Make sure the script is executable:

Code:
chmod a+rx /home/user/scripts/execroot.sh
Example of using to reboot the phone. Put into Custom action:

Code:
sh /home/user/scripts/execroot.sh /sbin/reboot
* Disclaimer: Not tested :P

Thanks to MFaroTusino for the original exec as root method.
__________________
My N9/N950 projects:

Last edited by ajalkane; 2014-01-17 at 01:00.
 

The Following 7 Users Say Thank You to ajalkane For This Useful Post:
Posts: 1,313 | Thanked: 2,977 times | Joined on Jun 2011 @ Finland
#885
This recipe will try to fix the sudden battery level drop to 4%. It will take around 20 seconds before some of the battery level is restored after the sudden drop.

Create a new script /home/user/scripts/restartbme.sh with following content:

Code:
#!/bin/sh

sleep_stop=10
sleep_start=10

echo Sleeping $sleep_stop seconds before stop bme
sleep $sleep_stop 
stop=$(/sbin/stop bme)
# Following is used to show a notification. Remove or comment out the line if you don't like it
dbus-send --print-reply --dest=com.meego.core.MNotificationManager/notificationmanager com.meego.core.MNotificationManager.addNotification uint32:0 uint32:0 string:'device' string:'' string:"$stop" string:'' string:'' uint32:0

echo Sleeping $sleep_start seconds before start bme
sleep $sleep_start 
start=$(/sbin/start bme)
# Following is used to show a notification. Remove or comment out the line if you don't like it
dbus-send --print-reply --dest=com.meego.core.MNotificationManager/notificationmanager com.meego.core.MNotificationManager.addNotification uint32:0 uint32:0 string:'device' string:'' string:"$start" string:'' string:'' uint32:0
Make sure the script is executable:

Code:
chmod a+rx /home/user/scripts/restartbme.sh
In ProfileMatic:

- Create a new rule in ProfileMatic with for example name "Fix battery level"
- Condition: Battery Level, min 0, max 8
- Action: Custom action with the following entry in "Custom action on rule activate":

Code:
sh -c "echo rootme | devel-su -c /home/user/scripts/restartbme.sh
Or if you use execroot script:

Code:
sh /home/user/scripts/execroot.sh /home/user/scripts/restartbme.sh
Save the rule.

Thanks to rooster13 for the original bme restarting script, and to thedead1440 for the mostly working timeouts and the notification addition.
__________________
My N9/N950 projects:

Last edited by ajalkane; 2014-01-17 at 01:07.
 

The Following 16 Users Say Thank You to ajalkane For This Useful Post:
Posts: 1,313 | Thanked: 2,977 times | Joined on Jun 2011 @ Finland
#886
Originally Posted by Lucazz990 View Post
Hi guys, I'm not able to run this script: http://talk.maemo.org/showpost.php?p...&postcount=825. I put the battery.sh file in /home/user/scripts/battery.sh and then added "sh /home/user/scripts/battery.sh" as custom action but it doesn't work. Did I forget something?
See post http://talk.maemo.org/showpost.php?p...&postcount=885

Let me know if there's a problem.
__________________
My N9/N950 projects:
 
Posts: 1,313 | Thanked: 2,977 times | Joined on Jun 2011 @ Finland
#887
I have started to collect some "recipes" to help people with custom actions (but other kind of condition/action combinations are welcome too). I intend to list them to the first post for easy reference. I know there's been quite a few people have done.

So for common good I do want to collect them for easy reference. So if you have some good recipes, please post them here. Just try to make them as easy and straightforward as possible. Perhaps see examples written by me, and if there's a problem in my examples let me know and I'll correct them.
__________________
My N9/N950 projects:
 

The Following User Says Thank You to ajalkane For This Useful Post:
Posts: 1,313 | Thanked: 2,977 times | Joined on Jun 2011 @ Finland
#888
ProfileMatic does not currently have direct support for launching applications as an action. But you can use custom action to do it. Here's an example how to do it:

First find the file that describes the application to launch. As an example, let's suppose we want to launch the "Maps" application.

In terminal, find the file that describes the application "Maps":

Code:
~ $ grep -l Maps /usr/share/applications/*
/usr/share/applications/maps.desktop
/usr/share/applications/mapsi.desktop
From here I see /usr/share/applications/maps.desktop is the correct file.

In ProfileMatic:
Put into Custom Action the following code to start the application:
Code:
xdg-open /usr/share/applications/maps.desktop
__________________
My N9/N950 projects:
 

The Following 3 Users Say Thank You to ajalkane For This Useful Post:
Moderator | Posts: 5,320 | Thanked: 4,464 times | Joined on Oct 2009
#889
Originally Posted by ajalkane View Post
I have started to collect some "recipes" to help people with custom actions (but other kind of condition/action combinations are welcome too). I intend to list them to the first post for easy reference. I know there's been quite a few people have done.

So for common good I do want to collect them for easy reference. So if you have some good recipes, please post them here. Just try to make them as easy and straightforward as possible. Perhaps see examples written by me, and if there's a problem in my examples let me know and I'll correct them.
Great initiative, this is sorely needed, perhaps better would be to create a Profilematic Rules & Custom Actions entry in the Wiki?
Then you don't have to constantly update the OP, you/everyone can add new content there, this has worked well for Wazapp & other projects.
Sadly I think the damn thing is still down ATM, maybe you could link to a Google doc from the OP instead...

Last edited by jalyst; 2012-11-21 at 17:11.
 

The Following User Says Thank You to jalyst For This Useful Post:
Posts: 335 | Thanked: 285 times | Joined on Sep 2012 @ Trento, Italy
#890
Originally Posted by ajalkane View Post
See post http://talk.maemo.org/showpost.php?p...&postcount=885

Let me know if there's a problem.
Ok it seems to work now! It was just the most stupid mistake ever while creating the sh script...
My fault, I'm soooooo noob
thank you bro
 
Reply


 
Forum Jump


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