Enable/Disable Stamina Mode with Shell Script

Search This thread

DarknessFox

New member
Feb 19, 2014
2
11
Hello people.
First, I must apologize for my bad English. I speak and write not often in English.
So now back to the topic.
I have searched for a way to Stamina mode also be able to control via script, so you can use it for example in combination with Tasker.
Now I have found the solution and wanted to share with you. :)

The script is just an example of how to use it and can of course be reprogrammed.
The prerequisite is your Smartphone must be rooted.

Script:
#!/system/bin/sh
if [ "$USER" != "root" ]; then
su - root -s "$0" && exit;
elif [ "$(content query --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --projection name=enabled --where "name='0'")" == "Row: 0 enabled=false" ]; then
content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:true --where "name='0'";
else
content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:false --where "name='0'";
fi;
 

peca89

Member
Aug 14, 2010
31
14
Hello people.
First, I must apologize for my bad English. I speak and write not often in English.
So now back to the topic.
I have searched for a way to Stamina mode also be able to control via script, so you can use it for example in combination with Tasker.
Now I have found the solution and wanted to share with you. :)

The script is just an example of how to use it and can of course be reprogrammed.
The prerequisite is your Smartphone must be rooted.

Script:

I get this error when trying to execute this on Z1 Compact running 4.4.4:
Code:
[ERROR] Unsupported argument: vider/xssm/enabled
 
  • Like
Reactions: mnsk

DarknessFox

New member
Feb 19, 2014
2
11
I'm sorry, I have found a mistake in my post. Between pro and vider, must not be a space. So it must be written provider. My Post I have edited.
 
  • Like
Reactions: Shahnewaz

peca89

Member
Aug 14, 2010
31
14
That's more like it! Thanks very much. I feel so stupid for not figuring that out myself :'(

BTW, should I worry about this output when executing?

Code:
root@D5503:/ # /tmp/toggle_stamina.sh
WARNING: linker: app_process has text relocations. This is wasting memory and is a security risk. Please fix.
WARNING: linker: app_process has text relocations. This is wasting memory and is a security risk. Please fix.
WARNING: linker: app_process has text relocations. This is wasting memory and is a security risk. Please fix.
WARNING: linker: app_process has text relocations. This is wasting memory and is a security risk. Please fix.
root@D5503:/ #

Edit: I just figured out that this is caused by xposed and that there is nothing to worry about. Thanks once again.

Sent from my D5503 using XDA Free mobile app
 
Last edited:

sravanz

Senior Member
Apr 6, 2011
227
28
Hello people.
First, I must apologize for my bad English. I speak and write not often in English.
So now back to the topic.
I have searched for a way to Stamina mode also be able to control via script, so you can use it for example in combination with Tasker.
Now I have found the solution and wanted to share with you. :)

The script is just an example of how to use it and can of course be reprogrammed.
The prerequisite is your Smartphone must be rooted.

Script:

Hey can you explain me how to do this.. I am faily new to tasker and shell.. I want to enable stamina mode automatically at 11:00Pm and disable it at 7:00Am. An help would be appreciated.

Thanks
 
  • Like
Reactions: gkm812301

jaime4272

Senior Member
Jul 26, 2008
644
88
Earth
Can someone tell me why stamina mode won't enable wireless data when I move away from WiFi and how can I fix it thanks
 

the gladiator

Senior Member
Dec 16, 2010
319
51
Fantastic!!! Is this a script to toggle Stamina Mode? How should it be changed to have only the enable or disable mode?
 

paffo

Senior Member
Mar 16, 2010
196
64
Fantastic!!! Is this a script to toggle Stamina Mode? How should it be changed to have only the enable or disable mode?

Code:
#!/system/bin/sh

SCR=$(basename $0)
SET=$1

case $SET in
  "on")
    content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:true --where "name='0'";
  ;;
  "off")
    content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:false --where "name='0'";
  ;;                                                                                                                                              
  *)
    echo "USAGE: $SCR <on/off>"
esac
 

mnsk

Senior Member
Aug 12, 2012
507
88
Code:
#!/system/bin/sh

SCR=$(basename $0)
SET=$1

case $SET in
  "on")
    content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:true --where "name='0'";
  ;;
  "off")
    content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:false --where "name='0'";
  ;;                                                                                                                                              
  *)
    echo "USAGE: $SCR <on/off>"
esac
Can't toggle stamina mode with tasker.
"USAGE: tmp-mksh <on/off>" this is what i am getting as output.
 

paffo

Senior Member
Mar 16, 2010
196
64
Can't toggle stamina mode with tasker.
"USAGE: tmp-mksh <on/off>" this is what i am getting as output.

You used my proposition for script that need to be run with parameter.
Did you tried in terminal at all ? :)

USAGE: <scriptname> <on/off>
means
place all code in one file, EX: /system/xbin/staminamode
give execute attrib to this file
run with parameter "on" or "off"
 

mnsk

Senior Member
Aug 12, 2012
507
88
You used my proposition for script that need to be run with parameter.
Did you tried in terminal at all ? :)

USAGE: <scriptname> <on/off>
means
place all code in one file, EX: /system/xbin/staminamode
give execute attrib to this file
run with parameter "on" or "off"

I don't have much knowledge of this. I just tried running the script with tasker with root and show you the output.
If i have to run it with terminal doesn't i have to do it every time?
Please tell how to run it with tasker.
 

paffo

Senior Member
Mar 16, 2010
196
64
I don't have much knowledge of this. I just tried running the script with tasker with root and show you the output.
If i have to run it with terminal doesn't i have to do it every time?
Please tell how to run it with tasker.

As I said, save this in a file, place in xbin folder, and give executive attribute. In tasker you will have to only run "scriptname on" or "scriptname off"
Dont know how deep is your knowledge, but its crucial to know anything to not break your android.

You can simply place in tasker to run such command for turning on stammina:
Code:
content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:true --where "name='0'";

And for turning off staminna next task with:
Code:
content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:false --where "name='0'";
 

mnsk

Senior Member
Aug 12, 2012
507
88
As I said, save this in a file, place in xbin folder, and give executive attribute. In tasker you will have to only run "scriptname on" or "scriptname off"
Dont know how deep is your knowledge, but its crucial to know anything to not break your android.

You can simply place in tasker to run such command for turning on stammina:
Code:
content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:true --where "name='0'";

And for turning off staminna next task with:
Code:
content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:false --where "name='0'";

Okay! help me out..Please check the steps
-save your code in staminamode file
-give it 755 permissions (read only attribute)
- put it in system/xbin
-run shell command from tasker "staminamode on" with root
Is that it?
 

paffo

Senior Member
Mar 16, 2010
196
64
Okay! help me out..Please check the steps
-save your code in staminamode file
-give it 755 permissions (read only attribute)
- put it in system/xbin
-run shell command from tasker "staminamode on" with root
Is that it?

Yes.
Be aware, that giving 755 permissions not mean read only :) (7 means read,write,executable, 5 means read,executable), also owner should be "root", so:
Code:
chown root:root /system/xbin/staminamode
chmod 755 /system/xbin/staminamode
 

mnsk

Senior Member
Aug 12, 2012
507
88
Yes.
Be aware, that giving 755 permissions not mean read only :) (7 means read,write,executable, 5 means read,executable), also owner should be "root", so:
Code:
chown root:root /system/xbin/staminamode
chmod 755 /system/xbin/staminamode

Now running shell command staminamode on is giving this error
"/system/bin/sh: SCR=$(basename $0) SET=$1 case $SET in "on") content update --uri content://com.sonymobile.superstamina.xperia: No such file or directory"
 

paffo

Senior Member
Mar 16, 2010
196
64
Now running shell command staminamode on is giving this error
"/system/bin/sh: SCR=$(basename $0) SET=$1 case $SET in "on") content update --uri content://com.sonymobile.superstamina.xperia: No such file or directory"

Try attached file as your script and please try to run this from adb shell.
 

Attachments

  • staminamode.txt
    668 bytes · Views: 123

flechaig

Senior Member
Apr 11, 2010
71
13
NANTES
I found an answer

I found a way to toggle STAMINA mode with Tasker.
In Tasker, just create a new task of type "Send Intent". Then in "Action" field, enter :
Code:
com.sonymobile.superstamina.appwidget.TOGGLE_STAMINA_MODE
Then exist Task.

Now, when you enter this Task with a profile, STAMINA mode is toggled on or off. You can check this by adding the STAMINA widget on your home, or by looking at the "+" sign near the battery indicator.

Hope this helps !
 

Top Liked Posts

  • There are no posts matching your filters.
  • 10
    Hello people.
    First, I must apologize for my bad English. I speak and write not often in English.
    So now back to the topic.
    I have searched for a way to Stamina mode also be able to control via script, so you can use it for example in combination with Tasker.
    Now I have found the solution and wanted to share with you. :)

    The script is just an example of how to use it and can of course be reprogrammed.
    The prerequisite is your Smartphone must be rooted.

    Script:
    #!/system/bin/sh
    if [ "$USER" != "root" ]; then
    su - root -s "$0" && exit;
    elif [ "$(content query --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --projection name=enabled --where "name='0'")" == "Row: 0 enabled=false" ]; then
    content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:true --where "name='0'";
    else
    content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:false --where "name='0'";
    fi;
    2
    Fantastic!!! Is this a script to toggle Stamina Mode? How should it be changed to have only the enable or disable mode?

    Code:
    #!/system/bin/sh
    
    SCR=$(basename $0)
    SET=$1
    
    case $SET in
      "on")
        content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:true --where "name='0'";
      ;;
      "off")
        content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:false --where "name='0'";
      ;;                                                                                                                                              
      *)
        echo "USAGE: $SCR <on/off>"
    esac
    2
    I found an answer

    I found a way to toggle STAMINA mode with Tasker.
    In Tasker, just create a new task of type "Send Intent". Then in "Action" field, enter :
    Code:
    com.sonymobile.superstamina.appwidget.TOGGLE_STAMINA_MODE
    Then exist Task.

    Now, when you enter this Task with a profile, STAMINA mode is toggled on or off. You can check this by adding the STAMINA widget on your home, or by looking at the "+" sign near the battery indicator.

    Hope this helps !
    1
    Hello people.
    First, I must apologize for my bad English. I speak and write not often in English.
    So now back to the topic.
    I have searched for a way to Stamina mode also be able to control via script, so you can use it for example in combination with Tasker.
    Now I have found the solution and wanted to share with you. :)

    The script is just an example of how to use it and can of course be reprogrammed.
    The prerequisite is your Smartphone must be rooted.

    Script:

    I get this error when trying to execute this on Z1 Compact running 4.4.4:
    Code:
    [ERROR] Unsupported argument: vider/xssm/enabled
    1
    I'm sorry, I have found a mistake in my post. Between pro and vider, must not be a space. So it must be written provider. My Post I have edited.